OCILIB (C Driver for Oracle) 3.9.2
|
OCILIB offers some smart routines that takes a variable number of arguments in order to minimize OCILIB function calls and reduce the amount of code lines
On Windows platforms, the target programming language must support the __cdecl calling convention
Possible values for indicating placeholders type :
Supported input identifiers :
#include "ocilib.h" int main(void) { OCI_Connection *cn; OCI_Statement *st; OCI_Resultset *rs; int code = 1; char name[50]; if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT)) return EXIT_FAILURE; cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT); st = OCI_StatementCreate(cn); /* sql format with params ----------------------------------------------- */ OCI_ExecuteStmtFmt(st, "select article from test_fetch where code = %i", code); rs = OCI_GetResultset(st); while (OCI_FetchNext(rs)) printf("article : %s\n", OCI_GetString(rs, 1)); /* sql immediate (parse, exec, one fetch) ------------------------------- */ OCI_Immediate(cn, "select code, article from test_fetch where code = 1", OCI_ARG_INT, &code, OCI_ARG_TEXT, name); printf("article : %s - code %i\n", name, code); /* sql immediate (parse, exec, one fetch) with params ------------------- */ OCI_ImmediateFmt(cn, "select article from test_fetch where code = %i", code, OCI_ARG_TEXT, name); printf("article : %s\n", name); OCI_Cleanup(); return EXIT_SUCCESS; }
Functions | |
OCI_EXPORT boolean | OCI_Immediate (OCI_Connection *con, const mtext *sql,...) |
Perform 3 calls (prepare+execute+fetch) in 1 call. | |
OCI_EXPORT boolean | OCI_ImmediateFmt (OCI_Connection *con, const mtext *sql,...) |
Performs 4 call (prepare+bind+execute+fetch) in 1 call. | |
OCI_EXPORT boolean | OCI_PrepareFmt (OCI_Statement *stmt, const mtext *sql,...) |
Prepare a formatted SQL statement or PL/SQL block. | |
OCI_EXPORT boolean | OCI_ExecuteStmtFmt (OCI_Statement *stmt, const mtext *sql,...) |
Execute a formatted SQL statement or PL/SQL block. | |
OCI_EXPORT boolean | OCI_ParseFmt (OCI_Statement *stmt, const mtext *sql,...) |
Parse a formatted SQL statement or PL/SQL block. | |
OCI_EXPORT boolean | OCI_DescribeFmt (OCI_Statement *stmt, const mtext *sql,...) |
Describe the select list of a formatted SQL select statement. |
OCI_EXPORT boolean OCI_Immediate | ( | OCI_Connection * | con, |
const mtext * | sql, | ||
... | |||
) |
Perform 3 calls (prepare+execute+fetch) in 1 call.
con | - Connection handle |
sql | - SQL statement |
... | - List of program variables address to store the result of fetch operation |
TRUE on success otherwise FALSE
Definition at line 2349 of file statement.c.
References OCI_ExecuteStmt(), OCI_GetStatementType(), OCI_StatementCreate(), and OCI_StatementFree().
OCI_EXPORT boolean OCI_ImmediateFmt | ( | OCI_Connection * | con, |
const mtext * | sql, | ||
... | |||
) |
Performs 4 call (prepare+bind+execute+fetch) in 1 call.
con | - Connection handle |
sql | - SQL statement |
... | - List of program values to format the SQL followed by the output variables addresses for the fetch operation |
TRUE on success otherwise FALSE
Definition at line 2397 of file statement.c.
References OCI_GetStatementType(), OCI_Prepare(), OCI_StatementCreate(), and OCI_StatementFree().
OCI_EXPORT boolean OCI_PrepareFmt | ( | OCI_Statement * | stmt, |
const mtext * | sql, | ||
... | |||
) |
Prepare a formatted SQL statement or PL/SQL block.
stmt | - Statement handle |
sql | - SQL statement |
... | - List of program values to format the SQL |
Definition at line 2121 of file statement.c.
References OCI_Prepare().
OCI_EXPORT boolean OCI_ExecuteStmtFmt | ( | OCI_Statement * | stmt, |
const mtext * | sql, | ||
... | |||
) |
Execute a formatted SQL statement or PL/SQL block.
stmt | - Statement handle |
sql | - SQL statement |
... | - List of program values to format the SQL |
Definition at line 2178 of file statement.c.
References OCI_Prepare().
OCI_EXPORT boolean OCI_ParseFmt | ( | OCI_Statement * | stmt, |
const mtext * | sql, | ||
... | |||
) |
Parse a formatted SQL statement or PL/SQL block.
stmt | - Statement handle |
sql | - SQL statement |
... | - List of program values to format the SQL |
Definition at line 2235 of file statement.c.
References OCI_Prepare().
OCI_EXPORT boolean OCI_DescribeFmt | ( | OCI_Statement * | stmt, |
const mtext * | sql, | ||
... | |||
) |
Describe the select list of a formatted SQL select statement.
stmt | - Statement handle |
sql | - SQL statement |
... | - List of program values to format the SQL |
Definition at line 2292 of file statement.c.
References OCI_Prepare().