Oracle collections (Varrays and Nested Tables)


Detailed Description

OCILIB supports all Oracle collections :

PL/SQL tables are implemented by binding regular C arrays with the array interface (using OCI_BindArrayOfXXX() calls)

Varrays and Nested tables are implemented in OCILIB with the type OCI_Coll. It's possible to bind and fetch Varrays and Nested tables using OCI_Coll handle.

It's also possible to declare local collections based on some database type without using queries

OCI (and thus OCILIB) offers the possibility to access collection elements :

Collection Items are implemented through the type OCI_Elem and use the series of calls OCI_ElemGetXXX() and OCI_ElemSetXXX() to manipulate elements content values

Example
#include "ocilib.h"

int main(void)
{
    OCI_Connection *cn;
    OCI_Statement *st;
    OCI_Resultset *rs;
    OCI_Coll *coll;
    OCI_Iter *iter;
    OCI_Elem *elem;
    OCI_TypeInfo *type;
    OCI_Object *obj;
    int i, n;

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

    cn = OCI_ConnectionCreate("db", "usr", "pwd", OCI_SESSION_DEFAULT);


    /* Varray binding -------------------------------------------------------- */

    st = OCI_StatementCreate(cn);

    /* create the collection */

    type = OCI_TypeInfoGet(cn, "Varray_type", OCI_TIF_TYPE);
    coll = OCI_CollCreate(type);

    /* bind the local collection to a PL/SQL procedure */
    
    OCI_Prepare(st, "begin load_array(:array); end;");
    OCI_BindColl(st, ":array", coll);
    OCI_Execute(st);
 
    /* the procedure has filled the collection and 
       we can iterate it using an iterator */
    
    iter = OCI_IterCreate(coll);
    elem = OCI_IterGetNext(iter);

    while (elem != NULL)
    {
        printf("value %s\n", OCI_ElemGetString(elem));
        elem = OCI_IterGetNext(iter);
    }

    OCI_IterFree(iter);
    OCI_CollFree(coll);
 
    /* Varray SQL fetch ------------------------------------------------------- */
  
    /* query on a table with varray column */
 
    OCI_ExecuteStmt(st, "SELECT * from table_article");

    rs = OCI_GetResultset(st);

    while (OCI_FetchNext(rs))
    {
        /* iterate the collection using an iterator */

        coll = OCI_GetColl(rs, 2);

        iter = OCI_IterCreate(coll);
        elem = OCI_IterGetNext(iter);

        printf("article #%d\n", OCI_GetInt(rs, 1));

        while (elem != NULL)
        {
            obj = OCI_ElemGetObject(elem);
            printf(".... code %d, name%s \n", OCI_ObjectGetInt(obj, "ID"),
                                              OCI_ObjectGetString(obj, "NAME"));
            elem = OCI_IterGetNext(iter);
        }

        OCI_IterFree(iter);
    }

    /* Nested table fetch ------------------------------------------------------- */
    
    /* query on a table with nested table column */
 
    OCI_ExecuteStmt(st, "SELECT * from table_sales");

    rs = OCI_GetResultset(st);

    while (OCI_FetchNext(rs))
    {
        coll = OCI_GetColl(rs, 2);

        printf("Sale #%d\n", OCI_GetInt(rs, 1));

        /* iterate the collection by accessing element by index */
   
        n = OCI_CollGetSize(coll);

        for(i = 1; i <= n; i++)
        {
            elem = OCI_CollGetAt(coll, i);
            obj  = OCI_ElemGetObject(elem);

            printf(".... employee %s, amount %s \n", OCI_ObjectGetString(obj, "EMP"),
                                                     OCI_ObjectGetString(obj, "AMOUNT"));
        }
    }

    OCI_Cleanup();
    
    return EXIT_SUCCESS;
}


Functions

OCI_EXPORT OCI_Coll *OCI_API OCI_CollCreate (OCI_TypeInfo *typinf)
 Create a local collection instance.
OCI_EXPORT boolean OCI_API OCI_CollFree (OCI_Coll *coll)
 Free a local collection.
OCI_EXPORT boolean OCI_API OCI_CollAssign (OCI_Coll *coll, OCI_Coll *coll_src)
 Assign a collection to another one.
OCI_EXPORT OCI_TypeInfo *OCI_API OCI_CollGetTypeInfo (OCI_Coll *coll)
 Return the type info object associated to the collection.
OCI_EXPORT unsigned int OCI_API OCI_CollGetType (OCI_Coll *coll)
 Return the collection type.
OCI_EXPORT unsigned int OCI_API OCI_CollGetMax (OCI_Coll *coll)
 Returns the maximum number of elements of the given collection.
OCI_EXPORT unsigned int OCI_API OCI_CollGetSize (OCI_Coll *coll)
 Returns the current number of elements of the given collection.
OCI_EXPORT boolean OCI_API OCI_CollTrim (OCI_Coll *coll, unsigned int nb_elem)
 Trims the given number of elements from the end of the collection.
OCI_EXPORT boolean OCI_API OCI_CollClear (OCI_Coll *coll)
 clear all items of the given collection
OCI_EXPORT OCI_Elem *OCI_API OCI_CollGetAt (OCI_Coll *coll, unsigned int index)
 Return the element at the given position in the collection.
OCI_EXPORT boolean OCI_API OCI_CollSetAt (OCI_Coll *coll, unsigned int index, OCI_Elem *elem)
 Assign the given element value to the element at the given position in the collection.
OCI_EXPORT boolean OCI_API OCI_CollAppend (OCI_Coll *coll, OCI_Elem *elem)
 Append the given element at the end of the collection.
OCI_EXPORT OCI_Iter *OCI_API OCI_IterCreate (OCI_Coll *coll)
 Create an iterator handle to iterate through a collection.
OCI_EXPORT boolean OCI_API OCI_IterFree (OCI_Iter *iter)
 Free an iterator handle.
OCI_EXPORT OCI_Elem *OCI_API OCI_IterGetNext (OCI_Iter *iter)
 Get the next element in the collection.
OCI_EXPORT OCI_Elem *OCI_API OCI_IterGetPrev (OCI_Iter *iter)
 Get the previous element in the collection.
OCI_EXPORT OCI_Elem *OCI_API OCI_ElemCreate (OCI_TypeInfo *typinf)
 Create a local collection element instance based on a collection type descriptor.
OCI_EXPORT boolean OCI_API OCI_ElemFree (OCI_Elem *elem)
 Free a local collection element.
OCI_EXPORT short OCI_API OCI_ElemGetShort (OCI_Elem *elem)
 Return the short value of the given collection element.
OCI_EXPORT unsigned short OCI_API OCI_ElemGetUnsignedShort (OCI_Elem *elem)
 Return the unsigned short value of the given collection element.
OCI_EXPORT int OCI_API OCI_ElemGetInt (OCI_Elem *elem)
 Return the int value of the given collection element.
OCI_EXPORT unsigned int OCI_API OCI_ElemGetUnsignedInt (OCI_Elem *elem)
 Return the unsigned int value of the given collection element.
OCI_EXPORT big_int OCI_API OCI_ElemGetBigInt (OCI_Elem *elem)
 Return the big int value of the given collection element.
OCI_EXPORT big_uint OCI_API OCI_ElemGetUnsignedBigInt (OCI_Elem *elem)
 Return the unsigned big int value of the given collection element.
OCI_EXPORT double OCI_API OCI_ElemGetDouble (OCI_Elem *elem)
 Return the Double value of the given collection element.
OCI_EXPORT const dtext *OCI_API OCI_ElemGetString (OCI_Elem *elem)
 Return the String value of the given collection element.
OCI_EXPORT unsigned int OCI_API OCI_ElemGetRaw (OCI_Elem *elem, void *value, unsigned int len)
 Read the RAW value of the collection element into the given buffer.
OCI_EXPORT OCI_Date *OCI_API OCI_ElemGetDate (OCI_Elem *elem)
 Return the Date value of the given collection element.
OCI_EXPORT OCI_Timestamp *OCI_API OCI_ElemGetTimeStamp (OCI_Elem *elem)
 Return the Timestamp value of the given collection element.
OCI_EXPORT OCI_Interval *OCI_API OCI_ElemGetInterval (OCI_Elem *elem)
 Return the Interval value of the given collection element.
OCI_EXPORT OCI_Lob *OCI_API OCI_ElemGetLob (OCI_Elem *elem)
 Return the Lob value of the given collection element.
OCI_EXPORT OCI_File *OCI_API OCI_ElemGetFile (OCI_Elem *elem)
 Return the File value of the given collection element.
OCI_EXPORT OCI_Object *OCI_API OCI_ElemGetObject (OCI_Elem *elem)
 Return the object value of the given collection element.
OCI_EXPORT OCI_Coll *OCI_API OCI_ElemGetColl (OCI_Elem *elem)
 Return the collection value of the given collection element.
OCI_EXPORT OCI_Ref *OCI_API OCI_ElemGetRef (OCI_Elem *elem)
 Return the Ref value of the given collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetShort (OCI_Elem *elem, short value)
 Set a short value to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedShort (OCI_Elem *elem, unsigned short value)
 Set a unsigned short value to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetInt (OCI_Elem *elem, int value)
 Set a int value to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedInt (OCI_Elem *elem, unsigned int value)
 Set a unsigned int value to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetBigInt (OCI_Elem *elem, big_int value)
 Set a big int value to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedBigInt (OCI_Elem *elem, big_uint value)
 Set a unsigned big_int value to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetDouble (OCI_Elem *elem, double value)
 Set a double value to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetString (OCI_Elem *elem, const dtext *value)
 Set a string value to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetRaw (OCI_Elem *elem, void *value, unsigned int len)
 Set a RAW value to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetDate (OCI_Elem *elem, OCI_Date *value)
 Assign a Date handle to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetTimestamp (OCI_Elem *elem, OCI_Timestamp *value)
 Assign a Timestamp handle to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetInterval (OCI_Elem *elem, OCI_Interval *value)
 Assign an Interval handle to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetColl (OCI_Elem *elem, OCI_Coll *value)
 Assign a Collection handle to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetObject (OCI_Elem *elem, OCI_Object *value)
 Assign an Object handle to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetLob (OCI_Elem *elem, OCI_Lob *value)
 Assign a Lob handle to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetFile (OCI_Elem *elem, OCI_File *value)
 Assign a File handle to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemSetRef (OCI_Elem *elem, OCI_Ref *value)
 Assign a Ref handle to a collection element.
OCI_EXPORT boolean OCI_API OCI_ElemIsNull (OCI_Elem *elem)
 Check if the collection element value is null.
OCI_EXPORT boolean OCI_API OCI_ElemSetNull (OCI_Elem *elem)
 Set a collection element value to null.


Function Documentation

OCI_EXPORT boolean OCI_API OCI_CollAppend ( OCI_Coll coll,
OCI_Elem elem 
)

Append the given element at the end of the collection.

Parameters:
coll - Collection handle
elem - Element handle to add
Note:
Returns:
TRUE on success otherwise FALSE

Definition at line 330 of file collection.c.

References OCI_TypeInfo::cols, OCI_Coll::con, OCI_Connection::err, OCI_Coll::handle, OCI_Elem::handle, OCI_Elem::pind, OCI_Column::type, OCI_Coll::typinf, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_CollAssign ( OCI_Coll coll,
OCI_Coll coll_src 
)

Assign a collection to another one.

Parameters:
coll - Destination Collection handle
coll_src - Source Collection handle
Note:
Oracle proceeds to a deep copy of the collection content
Returns:
TRUE on success otherwise FALSE

Definition at line 157 of file collection.c.

References OCI_TypeInfo::cols, OCI_Coll::con, OCI_Connection::err, OCI_Coll::handle, OCI_Column::icode, and OCI_Coll::typinf.

Referenced by OCI_ElemSetColl(), and OCI_ObjectSetColl().

OCI_EXPORT boolean OCI_API OCI_CollClear ( OCI_Coll coll  ) 

clear all items of the given collection

Parameters:
coll - Collection handle
Returns:
TRUE on success otherwise FALSE

Definition at line 369 of file collection.c.

References OCI_CollGetSize(), and OCI_CollTrim().

OCI_EXPORT OCI_Coll* OCI_API OCI_CollCreate ( OCI_TypeInfo typinf  ) 

Create a local collection instance.

Parameters:
typinf - Type info handle of the collection type descriptor
Returns:
Return the collection object handle on success otherwise NULL on failure

Definition at line 104 of file collection.c.

References OCI_TypeInfo::ccode, and OCI_TypeInfo::con.

OCI_EXPORT boolean OCI_API OCI_CollFree ( OCI_Coll coll  ) 

Free a local collection.

Parameters:
coll - Collection handle
Warning:
Only collection created with OCI_CollCreate() should be freed by OCI_CollFree()
Returns:
TRUE on success otherwise FALSE

Definition at line 124 of file collection.c.

References OCI_TypeInfo::con, OCI_Coll::elem, OCI_Connection::err, OCI_Coll::handle, OCI_Coll::hstate, OCI_Elem::hstate, OCI_ElemFree(), and OCI_Coll::typinf.

Referenced by OCI_ElemFree().

OCI_EXPORT OCI_Elem* OCI_API OCI_CollGetAt ( OCI_Coll coll,
unsigned int  index 
)

Return the element at the given position in the collection.

Parameters:
coll - Collection handle
index - Index of the destination element
Note:
Collection indexes start at position 1.

Up to 3.3.0, the library checked that the input index was fitting into the collection bounds. From 3.3.1, this check has been removed for some internal reasons. An exception will be still thrown in case of out of bounds index but the exception type is now an OCI exception instead of an OCILIB one.

Returns:
Element handle on success otherwise FALSE

Definition at line 271 of file collection.c.

References OCI_Coll::con, OCI_Coll::elem, OCI_Connection::err, OCI_Coll::handle, and OCI_Coll::typinf.

OCI_EXPORT unsigned int OCI_API OCI_CollGetMax ( OCI_Coll coll  ) 

Returns the maximum number of elements of the given collection.

Parameters:
coll - Collection handle

Definition at line 204 of file collection.c.

References OCI_Coll::handle.

OCI_EXPORT unsigned int OCI_API OCI_CollGetSize ( OCI_Coll coll  ) 

Returns the current number of elements of the given collection.

Parameters:
coll - Collection handle

Definition at line 221 of file collection.c.

References OCI_Coll::con, OCI_Connection::err, and OCI_Coll::handle.

Referenced by OCI_CollClear(), and OCI_CollTrim().

OCI_EXPORT unsigned int OCI_API OCI_CollGetType ( OCI_Coll coll  ) 

Return the collection type.

Parameters:
coll - Collection handle
Note:
Current collection types are :

Returns:
Collection type or OCI_UNKNOWN if the collection handle is null

Definition at line 184 of file collection.c.

References OCI_TypeInfo::ccode, and OCI_Coll::typinf.

OCI_EXPORT OCI_TypeInfo* OCI_API OCI_CollGetTypeInfo ( OCI_Coll coll  ) 

Return the type info object associated to the collection.

Parameters:
coll - Collection handle

Definition at line 356 of file collection.c.

References OCI_Coll::typinf.

OCI_EXPORT boolean OCI_API OCI_CollSetAt ( OCI_Coll coll,
unsigned int  index,
OCI_Elem elem 
)

Assign the given element value to the element at the given position in the collection.

Parameters:
coll - Collection handle
index - Index of the destination element
elem - Source element handle to assign
Note:
Collection indexes start at position 1.

Up to 3.3.0, the library checked that the input index was fitting into the collection bounds. From 3.3.1, this check has been removed for some internal reasons. An exception will be still thrown in case of out of bounds index but the exception type is now an OCI exception instead of an OCILIB one.

Returns:
TRUE on success otherwise FALSE

Definition at line 304 of file collection.c.

References OCI_TypeInfo::cols, OCI_Coll::con, OCI_Connection::err, OCI_Coll::handle, OCI_Elem::handle, OCI_Elem::pind, OCI_Column::type, OCI_Coll::typinf, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_CollTrim ( OCI_Coll coll,
unsigned int  nb_elem 
)

Trims the given number of elements from the end of the collection.

Parameters:
coll - Collection handle
nb_elem - Number of elements to trim
Returns:
TRUE on success otherwise FALSE

Definition at line 244 of file collection.c.

References OCI_Coll::con, OCI_Connection::err, OCI_Coll::handle, and OCI_CollGetSize().

Referenced by OCI_CollClear().

OCI_EXPORT OCI_Elem* OCI_API OCI_ElemCreate ( OCI_TypeInfo typinf  ) 

Create a local collection element instance based on a collection type descriptor.

Parameters:
typinf - Type info handle
Returns:
Return the collection element handle on success otherwise NULL on failure

Definition at line 190 of file element.c.

References OCI_TypeInfo::con.

OCI_EXPORT boolean OCI_API OCI_ElemFree ( OCI_Elem elem  ) 

Free a local collection element.

Parameters:
elem - Element handle
Warning:
Only element created with OCI_ElemCreate() should be freed by OCI_ElemFree()
Returns:
TRUE on success otherwise FALSE

Definition at line 208 of file element.c.

References OCI_Elem::buf, OCI_TypeInfo::cols, OCI_Elem::handle, OCI_Elem::init, OCI_Elem::obj, OCI_CollFree(), OCI_DateFree(), OCI_FileFree(), OCI_IntervalFree(), OCI_LobFree(), OCI_ObjectFree(), OCI_TimestampFree(), OCI_Column::type, and OCI_Elem::typinf.

Referenced by OCI_CollFree(), and OCI_IterFree().

OCI_EXPORT big_int OCI_API OCI_ElemGetBigInt ( OCI_Elem elem  ) 

Return the big int value of the given collection element.

Parameters:
elem - Element handle
Returns:
Big int value or 0 on failure

Definition at line 343 of file element.c.

OCI_EXPORT OCI_Coll* OCI_API OCI_ElemGetColl ( OCI_Elem elem  ) 

Return the collection value of the given collection element.

Parameters:
elem - Element handle
Returns:
Collection handle or NULL on failure

Definition at line 691 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::ind, OCI_Elem::init, OCI_Elem::obj, OCI_Column::type, OCI_Column::typinf, and OCI_Elem::typinf.

OCI_EXPORT OCI_Date* OCI_API OCI_ElemGetDate ( OCI_Elem elem  ) 

Return the Date value of the given collection element.

Parameters:
elem - Element handle
Returns:
Date handle or NULL on failure

Definition at line 454 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::ind, OCI_Elem::init, OCI_Elem::obj, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT double OCI_API OCI_ElemGetDouble ( OCI_Elem elem  ) 

Return the Double value of the given collection element.

Parameters:
elem - Element handle
Returns:
Double value or 0 on failure

Definition at line 375 of file element.c.

OCI_EXPORT OCI_File* OCI_API OCI_ElemGetFile ( OCI_Elem elem  ) 

Return the File value of the given collection element.

Parameters:
elem - Element handle
Returns:
File handle or NULL on failure

Definition at line 589 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::ind, OCI_Elem::init, OCI_Elem::obj, OCI_Column::subtype, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT int OCI_API OCI_ElemGetInt ( OCI_Elem elem  ) 

Return the int value of the given collection element.

Parameters:
elem - Element handle
Returns:
Int value or 0 on failure

Definition at line 311 of file element.c.

OCI_EXPORT OCI_Interval* OCI_API OCI_ElemGetInterval ( OCI_Elem elem  ) 

Return the Interval value of the given collection element.

Parameters:
elem - Element handle
Returns:
Interval handle or NULL on failure

Definition at line 521 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::ind, OCI_Elem::init, OCI_Elem::obj, OCI_Column::subtype, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT OCI_Lob* OCI_API OCI_ElemGetLob ( OCI_Elem elem  ) 

Return the Lob value of the given collection element.

Parameters:
elem - Element handle
Returns:
Lob handle or NULL on failure

Definition at line 555 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::ind, OCI_Elem::init, OCI_Elem::obj, OCI_Column::subtype, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT OCI_Object* OCI_API OCI_ElemGetObject ( OCI_Elem elem  ) 

Return the object value of the given collection element.

Parameters:
elem - Element handle
Returns:
Object handle or NULL on failure

Definition at line 657 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::ind, OCI_Elem::init, OCI_Elem::obj, OCI_Column::type, OCI_Column::typinf, and OCI_Elem::typinf.

OCI_EXPORT unsigned int OCI_API OCI_ElemGetRaw ( OCI_Elem elem,
void *  value,
unsigned int  len 
)

Read the RAW value of the collection element into the given buffer.

Parameters:
elem - Element handle
value - Buffer to store the RAW value
len - Size of the buffer
Returns:
Number of bytes read from the RAW value or 0 on failure

Definition at line 417 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Connection::err, OCI_Elem::handle, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT OCI_Ref* OCI_API OCI_ElemGetRef ( OCI_Elem elem  ) 

Return the Ref value of the given collection element.

Parameters:
elem - Element handle
Returns:
Ref handle or NULL on failure

Definition at line 623 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::ind, OCI_Elem::init, OCI_Elem::obj, OCI_Column::type, OCI_Column::typinf, and OCI_Elem::typinf.

OCI_EXPORT short OCI_API OCI_ElemGetShort ( OCI_Elem elem  ) 

Return the short value of the given collection element.

Parameters:
elem - Element handle
Returns:
Short value or 0 on failure

Definition at line 279 of file element.c.

OCI_EXPORT const dtext* OCI_API OCI_ElemGetString ( OCI_Elem elem  ) 

Return the String value of the given collection element.

Parameters:
elem - Element handle
Returns:
String value or NULL on failure

Definition at line 391 of file element.c.

References OCI_Elem::buf, OCI_Elem::buflen, OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT OCI_Timestamp* OCI_API OCI_ElemGetTimeStamp ( OCI_Elem elem  ) 

Return the Timestamp value of the given collection element.

Parameters:
elem - Element handle
Returns:
Timestamp handle or NULL on failure

Definition at line 487 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::ind, OCI_Elem::init, OCI_Elem::obj, OCI_Column::subtype, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT big_uint OCI_API OCI_ElemGetUnsignedBigInt ( OCI_Elem elem  ) 

Return the unsigned big int value of the given collection element.

Parameters:
elem - Element handle
Returns:
Unsigned big int value or 0 on failure

Definition at line 359 of file element.c.

OCI_EXPORT unsigned int OCI_API OCI_ElemGetUnsignedInt ( OCI_Elem elem  ) 

Return the unsigned int value of the given collection element.

Parameters:
elem - Element handle
Returns:
Unsigned int value or 0 on failure

Definition at line 327 of file element.c.

OCI_EXPORT unsigned short OCI_API OCI_ElemGetUnsignedShort ( OCI_Elem elem  ) 

Return the unsigned short value of the given collection element.

Parameters:
elem - Element handle
Returns:
Unsigned short value or 0 on failure

Definition at line 295 of file element.c.

OCI_EXPORT boolean OCI_API OCI_ElemIsNull ( OCI_Elem elem  ) 

Check if the collection element value is null.

Parameters:
elem - Element handle
Returns:
TRUE if it's null otherwise FALSE

Definition at line 1175 of file element.c.

References OCI_Elem::pind.

OCI_EXPORT boolean OCI_API OCI_ElemSetBigInt ( OCI_Elem elem,
big_int  value 
)

Set a big int value to a collection element.

Parameters:
elem - Element handle
value - big int value
Returns:
TRUE on success otherwise FALSE

Definition at line 765 of file element.c.

OCI_EXPORT boolean OCI_API OCI_ElemSetColl ( OCI_Elem elem,
OCI_Coll value 
)

Assign a Collection handle to a collection element.

Parameters:
elem - Element handle
value - Collection Handle
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 977 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::obj, OCI_CollAssign(), OCI_ElemSetNull(), OCI_Column::type, OCI_Column::typinf, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetDate ( OCI_Elem elem,
OCI_Date value 
)

Assign a Date handle to a collection element.

Parameters:
elem - Element handle
value - Date Handle
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 860 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::obj, OCI_DateAssign(), OCI_ElemSetNull(), OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetDouble ( OCI_Elem elem,
double  value 
)

Set a double value to a collection element.

Parameters:
elem - Element handle
value - Double value
Returns:
TRUE on success otherwise FALSE

Definition at line 785 of file element.c.

OCI_EXPORT boolean OCI_API OCI_ElemSetFile ( OCI_Elem elem,
OCI_File value 
)

Assign a File handle to a collection element.

Parameters:
elem - Element handle
value - File Handle
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 1096 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::obj, OCI_ElemSetNull(), OCI_FileAssign(), OCI_Column::subtype, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetInt ( OCI_Elem elem,
int  value 
)

Set a int value to a collection element.

Parameters:
elem - Element handle
value - Int value
Returns:
TRUE on success otherwise FALSE

Definition at line 745 of file element.c.

OCI_EXPORT boolean OCI_API OCI_ElemSetInterval ( OCI_Elem elem,
OCI_Interval value 
)

Assign an Interval handle to a collection element.

Parameters:
elem - Element handle
value - Interval Handle
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 938 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::obj, OCI_ElemSetNull(), OCI_IntervalAssign(), OCI_Column::subtype, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetLob ( OCI_Elem elem,
OCI_Lob value 
)

Assign a Lob handle to a collection element.

Parameters:
elem - Element handle
value - Lob Handle
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 1057 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::obj, OCI_ElemSetNull(), OCI_LobAssign(), OCI_Column::subtype, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetNull ( OCI_Elem elem  ) 

Set a collection element value to null.

Parameters:
elem - Element handle
Returns:
TRUE on success otherwise FALSE

Definition at line 1195 of file element.c.

Referenced by OCI_ElemSetColl(), OCI_ElemSetDate(), OCI_ElemSetFile(), OCI_ElemSetInterval(), OCI_ElemSetLob(), OCI_ElemSetObject(), OCI_ElemSetRaw(), OCI_ElemSetRef(), OCI_ElemSetString(), and OCI_ElemSetTimestamp().

OCI_EXPORT boolean OCI_API OCI_ElemSetObject ( OCI_Elem elem,
OCI_Object value 
)

Assign an Object handle to a collection element.

Parameters:
elem - Element handle
value - Object Handle
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 1016 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Object::handle, OCI_Elem::handle, OCI_Elem::obj, OCI_ElemSetNull(), OCI_ObjectAssign(), OCI_Column::type, OCI_Column::typinf, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetRaw ( OCI_Elem elem,
void *  value,
unsigned int  len 
)

Set a RAW value to a collection element.

Parameters:
elem - Element handle
value - Raw value
len - Size of the raw value
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 825 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Connection::err, OCI_Elem::handle, OCI_ElemSetNull(), OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetRef ( OCI_Elem elem,
OCI_Ref value 
)

Assign a Ref handle to a collection element.

Parameters:
elem - Element handle
value - Ref Handle
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 1136 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::obj, OCI_ElemSetNull(), OCI_RefAssign(), OCI_Column::type, OCI_Column::typinf, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetShort ( OCI_Elem elem,
short  value 
)

Set a short value to a collection element.

Parameters:
elem - Element handle
value - Short value
Returns:
TRUE on success otherwise FALSE

Definition at line 725 of file element.c.

OCI_EXPORT boolean OCI_API OCI_ElemSetString ( OCI_Elem elem,
const dtext *  value 
)

Set a string value to a collection element.

Parameters:
elem - Element handle
value - String value
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 795 of file element.c.

References OCI_Elem::buf, OCI_Elem::buflen, OCI_TypeInfo::cols, OCI_Elem::con, OCI_Connection::err, OCI_Elem::handle, OCI_ElemSetNull(), OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetTimestamp ( OCI_Elem elem,
OCI_Timestamp value 
)

Assign a Timestamp handle to a collection element.

Parameters:
elem - Element handle
value - Timestamp Handle
Note:
passing a null pointer for value calls OCI_ElemSetNull()
Returns:
TRUE on success otherwise FALSE

Definition at line 899 of file element.c.

References OCI_TypeInfo::cols, OCI_Elem::con, OCI_Elem::handle, OCI_Elem::obj, OCI_ElemSetNull(), OCI_TimestampAssign(), OCI_Column::subtype, OCI_Column::type, and OCI_Elem::typinf.

OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedBigInt ( OCI_Elem elem,
big_uint  value 
)

Set a unsigned big_int value to a collection element.

Parameters:
elem - Element handle
value - Unsigned big int value
Returns:
TRUE on success otherwise FALSE

Definition at line 775 of file element.c.

OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedInt ( OCI_Elem elem,
unsigned int  value 
)

Set a unsigned int value to a collection element.

Parameters:
elem - Element handle
value - Unsigned int value
Returns:
TRUE on success otherwise FALSE

Definition at line 755 of file element.c.

OCI_EXPORT boolean OCI_API OCI_ElemSetUnsignedShort ( OCI_Elem elem,
unsigned short  value 
)

Set a unsigned short value to a collection element.

Parameters:
elem - Element handle
value - Unsigned short value
Returns:
TRUE on success otherwise FALSE

Definition at line 735 of file element.c.

OCI_EXPORT OCI_Iter* OCI_API OCI_IterCreate ( OCI_Coll coll  ) 

Create an iterator handle to iterate through a collection.

Parameters:
coll - Collection handle
Returns:
Return the iterator handle on success otherwise NULL on failure

Definition at line 45 of file iterator.c.

References OCI_Iter::boc, OCI_Iter::coll, OCI_Coll::con, OCI_Iter::elem, OCI_Iter::eoc, OCI_Connection::err, OCI_Iter::handle, OCI_Coll::handle, OCI_IterFree(), and OCI_Coll::typinf.

OCI_EXPORT boolean OCI_API OCI_IterFree ( OCI_Iter iter  ) 

Free an iterator handle.

Parameters:
iter - Iterator handle
Returns:
TRUE on success otherwise FALSE

Definition at line 104 of file iterator.c.

References OCI_Iter::coll, OCI_Coll::con, OCI_Iter::elem, OCI_Connection::err, OCI_Iter::handle, and OCI_ElemFree().

Referenced by OCI_IterCreate().

OCI_EXPORT OCI_Elem* OCI_API OCI_IterGetNext ( OCI_Iter iter  ) 

Get the next element in the collection.

Parameters:
iter - Iterator handle
Returns:
TRUE on success otherwise FALSE if :
  • Empty collection
  • Iterator already positioned on the last collection element
  • An error occurred

Definition at line 143 of file iterator.c.

References OCI_Iter::coll, OCI_Coll::con, OCI_Iter::elem, OCI_Iter::eoc, OCI_Connection::err, OCI_Elem::handle, OCI_Iter::handle, OCI_Elem::ind, OCI_Elem::init, and OCI_Elem::pind.

OCI_EXPORT OCI_Elem* OCI_API OCI_IterGetPrev ( OCI_Iter iter  ) 

Get the previous element in the collection.

Parameters:
iter - Iterator handle
Returns:
TRUE on success otherwise FALSE if :
  • Empty collection
  • Iterator already positioned on the first collection element
  • An error occurred

Definition at line 178 of file iterator.c.

References OCI_Iter::boc, OCI_Iter::coll, OCI_Coll::con, OCI_Iter::elem, OCI_Connection::err, OCI_Elem::handle, OCI_Iter::handle, OCI_Elem::ind, OCI_Elem::init, and OCI_Elem::pind.


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