Binding variables and arrays


Detailed Description

OCILIB supports OCI data binding APIs

Programs variables can be binded to an Oracle SQL PL/SQL statement in order to :

OCILIB provides a set of binding functions to use with :

To use binding :

OCILIB supports the OCI array Interface by binding arrays of C scalar types and OCILIB object types.

OCILIB does not pre-parse statements (like other frameworks such as JDBC, ...) and lets Oracle recognize input variables embedded within the SQL statements.

Bind variables must be preceded in the SQL code by the character ':'.

Oracle and OCILIB supports two ways of binding :

OCILIB Default binding mode is OCI_BIND_BY_NAME.

When using binding by position, provide the position to OCI_BindXXXX() call through the name parameter. Within this mode the bind name must be the position preceded by a semicolon like ':1', ':2', ....

Basic input bind Example
#include "ocilib.h"

int main(void)
{
    OCI_Connection *cn;
    OCI_Statement *st;

    int code;

    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT))
        return EXIT_FAILURE;

    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
 
    st = OCI_StatementCreate(cn);
  
    OCI_Prepare(st, "delete from test_fetch where code = :code");
    OCI_BindInt(st, ":code", &code);
    
    code = 5;
    OCI_Execute(st);

    code = 12;
    OCI_Execute(st);
   
    OCI_Commit(cn);

    OCI_Cleanup();
 
    return EXIT_SUCCESS;
}
Array interface Example
#include "ocilib.h"

int main(void)
{
    OCI_Connection *cn;
    OCI_Statement  *st;
    OCI_Error      *err;

    int tab_int[1000];
    char tab_str[1000][21];

    int i;

    if (!OCI_Initialize(NULL, NULL, OCI_ENV_DEFAULT | OCI_ENV_CONTEXT))
        return EXIT_FAILURE;

    /* ... create connection and statement ... */

    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);
    st = OCI_StatementCreate(cn);
 
    /* binding */

    OCI_Prepare(st, "insert into products values(:i, :s)");
    OCI_BindArraySetSize(st, 1000);
    OCI_BindArrayOfInts(st, ":i", (int*) tab_int, 0);
    OCI_BindArrayOfStrings(st, ":s", (char*) tab_str, 20, 0);

    /* filling arrays */

    for(i=0;i<1000;i++)
    {
        tab_int[i] = i+1;
        sprintf(tab_str[i],"Name %d",i+1);
    }

    /* execute */

    if (!OCI_Execute(st))
    {
        printf("Number of DML array errors : %d\n", OCI_GetBatchErrorCount(st));       

        err = OCI_GetBatchError(st);

        while (err)
        {
            printf("Error at row %d : %s\n", OCI_ErrorGetRow(err), OCI_ErrorGetString(err));       

            err = OCI_GetBatchError(st);
        }
    }
 
    printf("row processed : %d\n", OCI_GetAffectedRows(st));

    OCI_Commit(cn);

    OCI_Cleanup();

    return EXIT_SUCCESS;
}


Functions

OCI_EXPORT boolean OCI_API OCI_BindArraySetSize (OCI_Statement *stmt, unsigned int size)
 Set the input array size for bulk operations.
OCI_EXPORT unsigned int OCI_API OCI_BindArrayGetSize (OCI_Statement *stmt)
 Return the current input array size for bulk operations.
OCI_EXPORT boolean OCI_API OCI_AllowRebinding (OCI_Statement *stmt, boolean value)
 Allow different host variables to be binded using the same bind name or position between execution of a prepared statement.
OCI_EXPORT boolean OCI_API OCI_BindShort (OCI_Statement *stmt, const mtext *name, short *data)
 Bind an short variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfShorts (OCI_Statement *stmt, const mtext *name, short *data, unsigned int nbelem)
 Bind an array of shorts.
OCI_EXPORT boolean OCI_API OCI_BindUnsignedShort (OCI_Statement *stmt, const mtext *name, unsigned short *data)
 Bind an unsigned short variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedShorts (OCI_Statement *stmt, const mtext *name, unsigned short *data, unsigned int nbelem)
 Bind an array of unsigned shorts.
OCI_EXPORT boolean OCI_API OCI_BindInt (OCI_Statement *stmt, const mtext *name, int *data)
 Bind an integer variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfInts (OCI_Statement *stmt, const mtext *name, int *data, unsigned int nbelem)
 Bind an array of integers.
OCI_EXPORT boolean OCI_API OCI_BindUnsignedInt (OCI_Statement *stmt, const mtext *name, unsigned int *data)
 Bind an unsigned integer variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedInts (OCI_Statement *stmt, const mtext *name, unsigned int *data, unsigned int nbelem)
 Bind an array of unsigned integers.
OCI_EXPORT boolean OCI_API OCI_BindBigInt (OCI_Statement *stmt, const mtext *name, big_int *data)
 Bind a big integer variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfBigInts (OCI_Statement *stmt, const mtext *name, big_int *data, unsigned int nbelem)
 Bind an array of big integers.
OCI_EXPORT boolean OCI_API OCI_BindUnsignedBigInt (OCI_Statement *stmt, const mtext *name, big_uint *data)
 Bind an unsigned big integer variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedBigInts (OCI_Statement *stmt, const mtext *name, big_uint *data, unsigned int nbelem)
 Bind an array of unsigned big integers.
OCI_EXPORT boolean OCI_API OCI_BindString (OCI_Statement *stmt, const mtext *name, dtext *data, unsigned int len)
 Bind a string variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfStrings (OCI_Statement *stmt, const mtext *name, dtext *data, unsigned int len, unsigned int nbelem)
 Bind an array of strings.
OCI_EXPORT boolean OCI_API OCI_BindRaw (OCI_Statement *stmt, const mtext *name, void *data, unsigned int len)
 Bind a raw buffer.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfRaws (OCI_Statement *stmt, const mtext *name, void *data, unsigned int len, unsigned int nbelem)
 Bind an array of raw buffers.
OCI_EXPORT boolean OCI_API OCI_BindDouble (OCI_Statement *stmt, const mtext *name, double *data)
 Bind a double variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfDoubles (OCI_Statement *stmt, const mtext *name, double *data, unsigned int nbelem)
 Bind an array of doubles.
OCI_EXPORT boolean OCI_API OCI_BindDate (OCI_Statement *stmt, const mtext *name, OCI_Date *data)
 Bind a date variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfDates (OCI_Statement *stmt, const mtext *name, OCI_Date **data, unsigned int nbelem)
 Bind an array of dates.
OCI_EXPORT boolean OCI_API OCI_BindTimestamp (OCI_Statement *stmt, const mtext *name, OCI_Timestamp *data)
 Bind a timestamp variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfTimestamps (OCI_Statement *stmt, const mtext *name, OCI_Timestamp **data, unsigned int type, unsigned int nbelem)
 Bind an array of timestamp handles.
OCI_EXPORT boolean OCI_API OCI_BindInterval (OCI_Statement *stmt, const mtext *name, OCI_Interval *data)
 Bind an interval variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfIntervals (OCI_Statement *stmt, const mtext *name, OCI_Interval **data, unsigned int type, unsigned int nbelem)
 Bind an array of interval handles.
OCI_EXPORT boolean OCI_API OCI_BindLob (OCI_Statement *stmt, const mtext *name, OCI_Lob *data)
 Bind a Lob variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfLobs (OCI_Statement *stmt, const mtext *name, OCI_Lob **data, unsigned int type, unsigned int nbelem)
 Bind an array of Lob handles.
OCI_EXPORT boolean OCI_API OCI_BindFile (OCI_Statement *stmt, const mtext *name, OCI_File *data)
 Bind a File variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfFiles (OCI_Statement *stmt, const mtext *name, OCI_File **data, unsigned int type, unsigned int nbelem)
 Bind an array of File handles.
OCI_EXPORT boolean OCI_API OCI_BindObject (OCI_Statement *stmt, const mtext *name, OCI_Object *data)
 Bind an object (named type) variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfObjects (OCI_Statement *stmt, const mtext *name, OCI_Object **data, OCI_TypeInfo *typinf, unsigned int nbelem)
 Bind an array of object handles.
OCI_EXPORT boolean OCI_API OCI_BindColl (OCI_Statement *stmt, const mtext *name, OCI_Coll *data)
 Bind a Collection variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfColls (OCI_Statement *stmt, const mtext *name, OCI_Coll **data, OCI_TypeInfo *typinf, unsigned int nbelem)
 Bind an array of Collection handles.
OCI_EXPORT boolean OCI_API OCI_BindRef (OCI_Statement *stmt, const mtext *name, OCI_Ref *data)
 Bind a Ref variable.
OCI_EXPORT boolean OCI_API OCI_BindArrayOfRefs (OCI_Statement *stmt, const mtext *name, OCI_Ref **data, OCI_TypeInfo *typinf, unsigned int nbelem)
 Bind an array of Ref handles.
OCI_EXPORT boolean OCI_API OCI_BindStatement (OCI_Statement *stmt, const mtext *name, OCI_Statement *data)
 Bind a Statement variable (PL/SQL Ref Cursor).
OCI_EXPORT boolean OCI_API OCI_BindLong (OCI_Statement *stmt, const mtext *name, OCI_Long *data, unsigned int size)
 Bind a Long variable.
OCI_EXPORT OCI_Error *OCI_API OCI_GetBatchError (OCI_Statement *stmt)
 Returns the first or next error that occured within a DML array statement.
OCI_EXPORT unsigned int OCI_API OCI_GetBatchErrorCount (OCI_Statement *stmt)
 Returns the number of errors that occured within the last DML array statement.
OCI_EXPORT unsigned int OCI_API OCI_GetBindCount (OCI_Statement *st)
 Return the number of binds currently associated to a statement.
OCI_EXPORT OCI_Bind *OCI_API OCI_GetBind (OCI_Statement *stmt, unsigned int index)
 Return the bind handle at the given index in the internal array of bind handle.
OCI_EXPORT OCI_Bind *OCI_API OCI_GetBind2 (OCI_Statement *stmt, const mtext *name)
 Return a bind handle from its name.
OCI_EXPORT const mtext *OCI_API OCI_BindGetName (OCI_Bind *bnd)
 Return the name of the given bind.
OCI_EXPORT unsigned int OCI_API OCI_BindGetType (OCI_Bind *bnd)
 Return the type of the given bind.
OCI_EXPORT unsigned int OCI_API OCI_BindGetSubtype (OCI_Bind *bnd)
 Return the OCILIB object subtype of the given bind.
OCI_EXPORT unsigned int OCI_API OCI_BindGetDataCount (OCI_Bind *bnd)
 Return the number of elements of the bind handle.
OCI_EXPORT void *OCI_API OCI_BindGetData (OCI_Bind *bnd)
 Return the user defined data associated with a bind handle.
OCI_EXPORT OCI_Statement *OCI_API OCI_BindGetStatement (OCI_Bind *bnd)
 Return the statement handle associated with a bind handle.
OCI_EXPORT boolean OCI_API OCI_BindSetDataSize (OCI_Bind *bnd, unsigned int size)
 Set the actual size of the element held by the given bind handle.
OCI_EXPORT boolean OCI_API OCI_BindSetDataSizeAtPos (OCI_Bind *bnd, unsigned int position, unsigned int size)
 Set the size of the element at the given position in the bind input array.
OCI_EXPORT unsigned int OCI_API OCI_BindGetDataSize (OCI_Bind *bnd)
 Return the actual size of the element held by the given bind handle.
OCI_EXPORT unsigned int OCI_API OCI_BindGetDataSizeAtPos (OCI_Bind *bnd, unsigned int position)
 Return the actual size of the element at the given position in the bind input array.
OCI_EXPORT boolean OCI_API OCI_BindSetNull (OCI_Bind *bnd)
 Set the bind variable to null.
OCI_EXPORT boolean OCI_API OCI_BindSetNullAtPos (OCI_Bind *bnd, unsigned int position)
 Set to null the entry in the bind variable input array.
OCI_EXPORT boolean OCI_API OCI_BindIsNull (OCI_Bind *bnd)
 Check if the current value of the binded variable is marked as NULL.
OCI_EXPORT boolean OCI_API OCI_BindIsNullAtPos (OCI_Bind *bnd, unsigned int position)
 Check if the current entry value at the given index of the binded array is marked as NULL.


Function Documentation

OCI_EXPORT boolean OCI_API OCI_AllowRebinding ( OCI_Statement stmt,
boolean  value 
)

Allow different host variables to be binded using the same bind name or position between execution of a prepared statement.

Parameters:
stmt - Statement handle
value - Rebinding mode allowed
Note:
Default value is FALSE
Returns:
TRUE on success otherwise FALSE

Definition at line 1842 of file statement.c.

References OCI_Statement::bind_reuse.

OCI_EXPORT unsigned int OCI_API OCI_BindArrayGetSize ( OCI_Statement stmt  ) 

Return the current input array size for bulk operations.

Parameters:
stmt - Statement handle
Returns:
Array size value or 0 if OCI_BindArraySetSize() has not been called

Definition at line 1829 of file statement.c.

References OCI_Statement::nb_iters.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfBigInts ( OCI_Statement stmt,
const mtext *  name,
big_int *  data,
unsigned int  nbelem 
)

Bind an array of big integers.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of big int
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 1974 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfColls ( OCI_Statement stmt,
const mtext *  name,
OCI_Coll **  data,
OCI_TypeInfo typinf,
unsigned int  nbelem 
)

Bind an array of Collection handles.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of Collection handle
typinf - Type info handle
nbelem - Number of element in the array
Note:
See OCI_CollCreate() for possible values of parameter 'type'
Returns:
TRUE on success otherwise FALSE

Definition at line 2447 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfDates ( OCI_Statement stmt,
const mtext *  name,
OCI_Date **  data,
unsigned int  nbelem 
)

Bind an array of dates.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of date handle
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 2117 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfDoubles ( OCI_Statement stmt,
const mtext *  name,
double *  data,
unsigned int  nbelem 
)

Bind an array of doubles.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of double
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 2091 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfFiles ( OCI_Statement stmt,
const mtext *  name,
OCI_File **  data,
unsigned int  type,
unsigned int  nbelem 
)

Bind an array of File handles.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of File handle
type - File type
nbelem - Number of element in the array
Note:
See OCI_FileCreate() for possible values of parameter 'type'
Returns:
TRUE on success otherwise FALSE

Definition at line 2383 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfIntervals ( OCI_Statement stmt,
const mtext *  name,
OCI_Interval **  data,
unsigned int  type,
unsigned int  nbelem 
)

Bind an array of interval handles.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of Interval handle
type - Interval type
nbelem - Number of element in the array
Note:
See OCI_IntervalCreate() for possible values of parameter 'type'
Returns:
TRUE on success otherwise FALSE

Definition at line 2247 of file statement.c.

References OCI_Statement::con.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfInts ( OCI_Statement stmt,
const mtext *  name,
int *  data,
unsigned int  nbelem 
)

Bind an array of integers.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of int
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 1922 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfLobs ( OCI_Statement stmt,
const mtext *  name,
OCI_Lob **  data,
unsigned int  type,
unsigned int  nbelem 
)

Bind an array of Lob handles.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of Lob handle
type - Lob type
nbelem - Number of element in the array
Note:
See OCI_LobCreate() for possible values of parameter 'type'
Returns:
TRUE on success otherwise FALSE

Definition at line 2338 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfObjects ( OCI_Statement stmt,
const mtext *  name,
OCI_Object **  data,
OCI_TypeInfo typinf,
unsigned int  nbelem 
)

Bind an array of object handles.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of object handle
typinf - type info handle
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 2300 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfRaws ( OCI_Statement stmt,
const mtext *  name,
void *  data,
unsigned int  len,
unsigned int  nbelem 
)

Bind an array of raw buffers.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of buffers
len - Size in bytes on a single RAW array element
nbelem - Number of element in the array
Note:
The buffer must be a contiguous block of data elements

If len <= 0, it returns FALSE

Returns:
TRUE on success otherwise FALSE

Definition at line 2062 of file statement.c.

References OCI_Statement::con.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfRefs ( OCI_Statement stmt,
const mtext *  name,
OCI_Ref **  data,
OCI_TypeInfo typinf,
unsigned int  nbelem 
)

Bind an array of Ref handles.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of Ref handle
typinf - type info handle
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 2418 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfShorts ( OCI_Statement stmt,
const mtext *  name,
short *  data,
unsigned int  nbelem 
)

Bind an array of shorts.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of shorts
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 1869 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfStrings ( OCI_Statement stmt,
const mtext *  name,
dtext *  data,
unsigned int  len,
unsigned int  nbelem 
)

Bind an array of strings.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of string
len - Max length of a single string element (in character without the zero null terminal character)
nbelem - Number of element in the array
Note:
if len <= 0, it returns FALSE
Returns:
TRUE on success otherwise FALSE

Definition at line 2031 of file statement.c.

References OCI_Statement::con.

Referenced by OCI_ServerEnableOutput().

OCI_EXPORT boolean OCI_API OCI_BindArrayOfTimestamps ( OCI_Statement stmt,
const mtext *  name,
OCI_Timestamp **  data,
unsigned int  type,
unsigned int  nbelem 
)

Bind an array of timestamp handles.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of Timestamp handle
type - Timestamp type
nbelem - Number of element in the array
Note:
See OCI_TimestampCreate() for possible values of parameter 'type'
Returns:
TRUE on success otherwise FALSE

Definition at line 2169 of file statement.c.

References OCI_Statement::con.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedBigInts ( OCI_Statement stmt,
const mtext *  name,
big_uint *  data,
unsigned int  nbelem 
)

Bind an array of unsigned big integers.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of unsigned big int
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 2000 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedInts ( OCI_Statement stmt,
const mtext *  name,
unsigned int *  data,
unsigned int  nbelem 
)

Bind an array of unsigned integers.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of unsigned int
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 1948 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArrayOfUnsignedShorts ( OCI_Statement stmt,
const mtext *  name,
unsigned short *  data,
unsigned int  nbelem 
)

Bind an array of unsigned shorts.

Parameters:
stmt - Statement handle
name - Variable name
data - Array of unsigned shorts
nbelem - Number of element in the array
Returns:
TRUE on success otherwise FALSE

Definition at line 1895 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindArraySetSize ( OCI_Statement stmt,
unsigned int  size 
)

Set the input array size for bulk operations.

Parameters:
stmt - Statement handle
size - Array size
Warning:
Do not use OCI_BindArraySetSize() for PL/SQL tables binding
Note:
OCI_BindArraySetSize() is used to set the size of input bind array when using arrays for DML statements. OCI_BindArraySetSize() MUST be called to set the maximum size of the arrays to bind to the statement before any of its execution. This initial call must be bone after OCI_Prepare() and any OCI_BindArrayOfxxx() call.

OCI_BindArraySetSize can optionally be called before any later OCI_Execute() call in order to notify the statement of the exact number of elements populating the input arrays for the next execution. The array size passed to later OCI_BindArraySetSize() calls cannot be greater than the initial size otherwise an exception will be thrown.

Returns:
TRUE on success otherwise FALSE

Definition at line 1793 of file statement.c.

References OCI_Statement::bind_array, OCI_Bind::buf, OCI_Statement::con, OCI_Statement::nb_iters, OCI_Statement::nb_ubinds, and OCI_Statement::ubinds.

OCI_EXPORT boolean OCI_API OCI_BindBigInt ( OCI_Statement stmt,
const mtext *  name,
big_int *  data 
)

Bind a big integer variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Pointer to big int variable
Returns:
TRUE on success otherwise FALSE

Definition at line 1961 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindColl ( OCI_Statement stmt,
const mtext *  name,
OCI_Coll data 
)

Bind a Collection variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Collection handle to bind
Returns:
TRUE on success otherwise FALSE

Definition at line 2432 of file statement.c.

References OCI_Coll::typinf.

OCI_EXPORT boolean OCI_API OCI_BindDate ( OCI_Statement stmt,
const mtext *  name,
OCI_Date data 
)

Bind a date variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Date handle
Returns:
TRUE on success otherwise FALSE

Definition at line 2104 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindDouble ( OCI_Statement stmt,
const mtext *  name,
double *  data 
)

Bind a double variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Pointer to double variable
Returns:
TRUE on success otherwise FALSE

Definition at line 2078 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindFile ( OCI_Statement stmt,
const mtext *  name,
OCI_File data 
)

Bind a File variable.

Parameters:
stmt - Statement handle
name - Variable name
data - File handle
Returns:
TRUE on success otherwise FALSE

Definition at line 2361 of file statement.c.

References OCI_File::type.

OCI_EXPORT void* OCI_API OCI_BindGetData ( OCI_Bind bnd  ) 

Return the user defined data associated with a bind handle.

Parameters:
bnd - Bind handle
Returns:
  • The pointer to variable/array passed to an OCIBindXXX() or OCI_BindArrayOfXXX() call

Definition at line 133 of file bind.c.

References OCI_Bind::input.

OCI_EXPORT unsigned int OCI_API OCI_BindGetDataCount ( OCI_Bind bnd  ) 

Return the number of elements of the bind handle.

Parameters:
bnd - Bind handle
Returns:
  • For single binds, it returns 1
  • For array binds, it returns the number of element in the array

Definition at line 120 of file bind.c.

References OCI_Bind::buf.

OCI_EXPORT unsigned int OCI_API OCI_BindGetDataSize ( OCI_Bind bnd  ) 

Return the actual size of the element held by the given bind handle.

Parameters:
bnd - bind handle
Note:
See OCI_BindSetDataSize() for supported datatypes
Warning:
For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in number of characters.

Definition at line 201 of file bind.c.

References OCI_BindGetDataSizeAtPos().

OCI_EXPORT unsigned int OCI_API OCI_BindGetDataSizeAtPos ( OCI_Bind bnd,
unsigned int  position 
)

Return the actual size of the element at the given position in the bind input array.

Parameters:
bnd - bind handle
position - Position in the array
Note:
See OCI_BindSetDataSize() for supported datatypes
Warning:
For binds of type OCI_CDT_TEXT (strings), the returned value is expressed in number of characters.

Definition at line 210 of file bind.c.

References OCI_Bind::buf, OCI_Statement::con, OCI_Bind::size, OCI_Bind::stmt, and OCI_Bind::type.

Referenced by OCI_BindGetDataSize().

OCI_EXPORT const mtext* OCI_API OCI_BindGetName ( OCI_Bind bnd  ) 

Return the name of the given bind.

Parameters:
bnd - Bind handle

Definition at line 70 of file bind.c.

References OCI_Bind::name.

OCI_EXPORT OCI_Statement* OCI_API OCI_BindGetStatement ( OCI_Bind bnd  ) 

Return the statement handle associated with a bind handle.

Parameters:
bnd - bind handle

Definition at line 146 of file bind.c.

References OCI_Bind::stmt.

OCI_EXPORT unsigned int OCI_API OCI_BindGetSubtype ( OCI_Bind bnd  ) 

Return the OCILIB object subtype of the given bind.

Parameters:
bnd - Bind handle
Note:
See OCI_GetColumnSubType() for possible values
Returns:
The column type or OCI_CDT_UNKNOWN if index is out of bounds

Definition at line 96 of file bind.c.

References OCI_Bind::subtype, and OCI_Bind::type.

OCI_EXPORT unsigned int OCI_API OCI_BindGetType ( OCI_Bind bnd  ) 

Return the type of the given bind.

Parameters:
bnd - Bind handle
Note:
See OCI_GetColumnType() for possible values
Returns:
The column type or OCI_CDT_UNKNOWN if index is out of bounds

Definition at line 83 of file bind.c.

References OCI_Bind::type.

OCI_EXPORT boolean OCI_API OCI_BindInt ( OCI_Statement stmt,
const mtext *  name,
int *  data 
)

Bind an integer variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Pointer to int variable
Returns:
TRUE on success otherwise FALSE

Definition at line 1910 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindInterval ( OCI_Statement stmt,
const mtext *  name,
OCI_Interval data 
)

Bind an interval variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Interval handle
Returns:
TRUE on success otherwise FALSE

Definition at line 2211 of file statement.c.

References OCI_Statement::con, and OCI_Interval::type.

OCI_EXPORT boolean OCI_API OCI_BindIsNull ( OCI_Bind bnd  ) 

Check if the current value of the binded variable is marked as NULL.

Parameters:
bnd - Bind handle
Returns:
TRUE if it's null otherwise FALSE

Definition at line 285 of file bind.c.

References OCI_BindIsNullAtPos().

OCI_EXPORT boolean OCI_API OCI_BindIsNullAtPos ( OCI_Bind bnd,
unsigned int  position 
)

Check if the current entry value at the given index of the binded array is marked as NULL.

Parameters:
bnd - Bind handle
position - Position in the array
Warning:
Position starts with 1
Returns:
TRUE on success otherwise FALSE

Definition at line 266 of file bind.c.

References OCI_Bind::buf, OCI_Statement::con, and OCI_Bind::stmt.

Referenced by OCI_BindIsNull().

OCI_EXPORT boolean OCI_API OCI_BindLob ( OCI_Statement stmt,
const mtext *  name,
OCI_Lob data 
)

Bind a Lob variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Lob handle
Returns:
TRUE on success otherwise FALSE

Definition at line 2316 of file statement.c.

References OCI_Lob::type.

OCI_EXPORT boolean OCI_API OCI_BindLong ( OCI_Statement stmt,
const mtext *  name,
OCI_Long data,
unsigned int  size 
)

Bind a Long variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Long handle
size - Size of the long buffer in bytes or characters
Note:
Size is expressed in :
  • Bytes for BLONGs
  • Characters for CLONGs
Returns:
TRUE on success otherwise FALSE

Definition at line 2490 of file statement.c.

References OCI_Long::type.

OCI_EXPORT boolean OCI_API OCI_BindObject ( OCI_Statement stmt,
const mtext *  name,
OCI_Object data 
)

Bind an object (named type) variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Object handle
Returns:
TRUE on success otherwise FALSE

Definition at line 2287 of file statement.c.

References OCI_Object::typinf.

OCI_EXPORT boolean OCI_API OCI_BindRaw ( OCI_Statement stmt,
const mtext *  name,
void *  data,
unsigned int  len 
)

Bind a raw buffer.

Parameters:
stmt - Statement handle
name - Variable name
data - buffer to bind
len - Max length of the buffer
Note:
if len <= 0, it returns false
Returns:
TRUE on success otherwise FALSE

Definition at line 2047 of file statement.c.

References OCI_Statement::con.

OCI_EXPORT boolean OCI_API OCI_BindRef ( OCI_Statement stmt,
const mtext *  name,
OCI_Ref data 
)

Bind a Ref variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Ref handle to bind
Returns:
TRUE on success otherwise FALSE

Definition at line 2406 of file statement.c.

References OCI_Ref::typinf.

OCI_EXPORT boolean OCI_API OCI_BindSetDataSize ( OCI_Bind bnd,
unsigned int  size 
)

Set the actual size of the element held by the given bind handle.

Parameters:
bnd - bind handle
size - data size
Note:
This call is not mandatory and should ONLY be called for RAWs binds to set the real size of the given data if different from the expected column or parameter size

It works as well with string based PL/SQL tables (in or in/out but NOT out) even if it's not necessary.

Warning:
For binds of type OCI_CDT_TEXT (strings), the parameter 'size' is expressed in number of characters.
Returns:
Data size if the bind type is listed above otherwise 0.

Definition at line 159 of file bind.c.

References OCI_BindSetDataSizeAtPos().

OCI_EXPORT boolean OCI_API OCI_BindSetDataSizeAtPos ( OCI_Bind bnd,
unsigned int  position,
unsigned int  size 
)

Set the size of the element at the given position in the bind input array.

Parameters:
bnd - bind handle
position - Position in the array
size - data size
Note:
See OCI_BindSetDataSize() for supported datatypes
Warning:
Before execution, it returns the max default size for the bind and not the real data size, unless a custom size has been set with OCI_BindSetDataSizeXXX() After execution, it returns the real data size.

For binds of type OCI_CDT_TEXT (strings), the parameter 'size' is expressed in number of characters.

Returns:
Data size if the bind type is listed above otherwise 0.

Definition at line 168 of file bind.c.

References OCI_Bind::buf, OCI_Statement::con, OCI_Bind::size, OCI_Bind::stmt, and OCI_Bind::type.

Referenced by OCI_BindSetDataSize().

OCI_EXPORT boolean OCI_API OCI_BindSetNull ( OCI_Bind bnd  ) 

Set the bind variable to null.

Parameters:
bnd - Bind handle
Note:
There is no notion of null value in C. It's necessary to explicitly tell Oracle that the bind has a null value. It must be done before an OCI_Execute() call

For handled based datatypes (non scalar types), OCILIB performs an extra check on handles and set the bind status to null is the handle is null

Returns:
TRUE on success otherwise FALSE

Definition at line 257 of file bind.c.

References OCI_BindSetNullAtPos().

OCI_EXPORT boolean OCI_API OCI_BindSetNullAtPos ( OCI_Bind bnd,
unsigned int  position 
)

Set to null the entry in the bind variable input array.

Parameters:
bnd - Bind handle
position - Position in the array
Note:
There is no notion of null value in C. It's necessary to explicitly tell Oracle that the bind has a null value. It must be done before an OCI_Execute() call
Warning:
Position starts with 1
Note:
For handled based datatypes (non scalar types), OCILIB performs an extra check on handles and set the bind status to null is the handle is null
Returns:
TRUE on success otherwise FALSE

Definition at line 240 of file bind.c.

References OCI_Bind::buf, OCI_Statement::con, and OCI_Bind::stmt.

Referenced by OCI_BindSetNull().

OCI_EXPORT boolean OCI_API OCI_BindShort ( OCI_Statement stmt,
const mtext *  name,
short *  data 
)

Bind an short variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Pointer to short variable
Returns:
TRUE on success otherwise FALSE

Definition at line 1857 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindStatement ( OCI_Statement stmt,
const mtext *  name,
OCI_Statement data 
)

Bind a Statement variable (PL/SQL Ref Cursor).

Parameters:
stmt - Statement handle
name - Variable name
data - Statement handle to bind
Returns:
TRUE on success otherwise FALSE

Definition at line 2462 of file statement.c.

References OCI_Statement::status, OCI_Statement::stmt, and OCI_Statement::type.

OCI_EXPORT boolean OCI_API OCI_BindString ( OCI_Statement stmt,
const mtext *  name,
dtext *  data,
unsigned int  len 
)

Bind a string variable.

Parameters:
stmt - Statement handle
name - Variable name
data - String to bind
len - Max length of the string (in character without the zero null terminal character)
Note:
if len == 0, len is set to the string size
Returns:
TRUE on success otherwise FALSE

Definition at line 2015 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindTimestamp ( OCI_Statement stmt,
const mtext *  name,
OCI_Timestamp data 
)

Bind a timestamp variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Timestamp handle
Returns:
TRUE on success otherwise FALSE

Definition at line 2130 of file statement.c.

References OCI_Statement::con, and OCI_Timestamp::type.

OCI_EXPORT boolean OCI_API OCI_BindUnsignedBigInt ( OCI_Statement stmt,
const mtext *  name,
big_uint *  data 
)

Bind an unsigned big integer variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Pointer to unsigned big int variable
Returns:
TRUE on success otherwise FALSE

Definition at line 1987 of file statement.c.

OCI_EXPORT boolean OCI_API OCI_BindUnsignedInt ( OCI_Statement stmt,
const mtext *  name,
unsigned int *  data 
)

Bind an unsigned integer variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Pointer to unsigned int variable
Returns:
TRUE on success otherwise FALSE

Definition at line 1935 of file statement.c.

Referenced by OCI_ServerEnableOutput().

OCI_EXPORT boolean OCI_API OCI_BindUnsignedShort ( OCI_Statement stmt,
const mtext *  name,
unsigned short *  data 
)

Bind an unsigned short variable.

Parameters:
stmt - Statement handle
name - Variable name
data - Pointer to unsigned short variable
Returns:
TRUE on success otherwise FALSE

Definition at line 1882 of file statement.c.

OCI_EXPORT OCI_Error* OCI_API OCI_GetBatchError ( OCI_Statement stmt  ) 

Returns the first or next error that occured within a DML array statement.

Parameters:
stmt - Statement handle
Note:
Returns:
The first or next error handle otherwise NULL

Definition at line 3215 of file statement.c.

References OCI_Statement::batch.

OCI_EXPORT unsigned int OCI_API OCI_GetBatchErrorCount ( OCI_Statement stmt  ) 

Returns the number of errors that occured within the last DML array statement.

Parameters:
stmt - Statement handle

Definition at line 3235 of file statement.c.

References OCI_Statement::batch.

OCI_EXPORT OCI_Bind* OCI_API OCI_GetBind ( OCI_Statement stmt,
unsigned int  index 
)

Return the bind handle at the given index in the internal array of bind handle.

Parameters:
stmt - Statement handle
index - Bind position
Note:
Index starts at 1.

Bind handle are created sequentially. By example, the third call to a OCI_BindXXX() generates a bind handle of index 3.

Returns:
The bind handle or NULL if index is out of bounds

Definition at line 3125 of file statement.c.

References OCI_Statement::con, OCI_Statement::nb_ubinds, and OCI_Statement::ubinds.

OCI_EXPORT OCI_Bind* OCI_API OCI_GetBind2 ( OCI_Statement stmt,
const mtext *  name 
)

Return a bind handle from its name.

Parameters:
stmt - Statement handle
name - Bind variable name
Note:
Bind names must include a semicolon at the beginning.
Returns:
The bind handle or NULL if not found

Definition at line 3139 of file statement.c.

References OCI_Statement::ubinds.

OCI_EXPORT unsigned int OCI_API OCI_GetBindCount ( OCI_Statement st  ) 

Return the number of binds currently associated to a statement.

Parameters:
st - Statement handle

Definition at line 3112 of file statement.c.

References OCI_Statement::nb_ubinds.


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