Formatted functions


Detailed Description

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

Note:
OCI_Immediate() and OCI_ImmediateFmt() support all OCILIB supported types for output result, except :

In the parameter list, every output placeholder MUST be preceded by an integer parameter that indicates the type of the placeholder in order to handle correctly the given pointer.

Possible values for indicating placeholders type :

Note:
For output strings and Raws, returned data is copied to the given buffer instead of returning a pointer the real data. So theses buffers must be big enough to hold the column content. No size check is performed.

Warning:
Input parameters for formatted function only support a restricted set of datatypes !
Supported input identifiers :

Example
#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,...)
 Parse and execute a formatted SQL statement or PL/SQL block.


Function Documentation

OCI_EXPORT boolean OCI_ExecuteStmtFmt ( OCI_Statement stmt,
const mtext *  sql,
  ... 
)

Parse and execute a formatted SQL statement or PL/SQL block.

Parameters:
stmt - Statement handle
sql - SQL statement
... - List of program values to format the SQL
Returns:
TRUE on success otherwise FALSE

Definition at line 1634 of file statement.c.

References OCI_Execute(), and OCI_Prepare().

OCI_EXPORT boolean OCI_Immediate ( OCI_Connection con,
const mtext *  sql,
  ... 
)

Perform 3 calls (prepare+execute+fetch) in 1 call.

Parameters:
con - Connection handle
sql - SQL statement
... - List of program variables address to store the result of fetch operation
Note:
Every output parameter MUST be preceded by an integer parameter that indicates the type of the placeholder in order to handle correctly the given pointer.
TRUE on success otherwise FALSE

Definition at line 1687 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.

Parameters:
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 1725 of file statement.c.

References OCI_Execute(), 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.

Parameters:
stmt - Statement handle
sql - SQL statement
... - List of program values to format the SQL
Returns:
TRUE on success otherwise FALSE

Definition at line 1581 of file statement.c.

References OCI_Prepare().


Generated on Thu Jul 30 17:41:55 2009 for OCILIB (C Driver for Oracle) by  doxygen 1.5.4