コード例 #1
0
boolean OCI_API OCI_ElemSetColl2(OCI_Library *pOCILib, OCI_Elem *elem, OCI_Coll *value, ExceptionSink* xsink)
{
    boolean res  = TRUE;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, FALSE);

    if (elem->typinf->cols[0].type != OCI_CDT_COLLECTION) {
       QoreStringNode* desc = new QoreStringNode("cannot bind a collection value to element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }

    if (value == NULL)
    {
        res = OCI_ElemSetNull2(pOCILib, elem);
    }
    else
    {
        if (elem->obj == NULL)
        {
            OCI_CollInit(pOCILib, elem->con, (OCI_Coll **) &elem->obj,
                         (OCIColl  *) elem->handle,
                         elem->typinf->cols[0].typinf, xsink);
        }

        if (elem->obj != NULL)
        {
	   res = OCI_CollAssign(pOCILib, (OCI_Coll *) elem->obj, value, xsink);
            
            if (res == TRUE)
            {
                OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL);

                elem->handle = ((OCI_Coll *) elem->obj)->handle;
            }
        }
    }

    OCI_RESULT(pOCILib, res);

    return res;
}
コード例 #2
0
OCI_Coll * OCI_API OCI_ElemGetColl2(OCI_Library *pOCILib, OCI_Elem *elem, ExceptionSink* xsink)
{
    boolean res    = TRUE;
    OCI_Coll *coll = NULL;

    OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, NULL);

    if (elem->typinf->cols[0].type != OCI_CDT_COLLECTION) {
       QoreStringNode* desc = new QoreStringNode("cannot retrieve a collection from element '");
       if (elem->typinf->schema) {
	  desc->concat(elem->typinf->schema);
	  desc->concat('.');
       }
       desc->sprintf("%s' of type '%s'", elem->typinf->name, OCI_GetColumnTypeName(elem->typinf->cols[0].type));
       return FALSE;
    }

    if (elem->ind != OCI_IND_NULL)
    {
        if (elem->init == FALSE)
        {
            coll = OCI_CollInit(pOCILib, elem->con, (OCI_Coll **) &elem->obj, 
                                (OCIColl *) elem->handle, 
                                elem->typinf->cols[0].typinf, xsink);

            elem->init = (coll != NULL);
        }
        else
            coll = (OCI_Coll *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(pOCILib, res);

    return coll;
}
コード例 #3
0
boolean OCI_ArrayInit
(
    OCI_Array    *arr,
    OCI_TypeInfo *typinf
)
{
    unsigned int i;

    for (i = 0; i < arr->nb_elem; i++)
    {
        void *handle = NULL;

        if (OCI_CDT_DATETIME == arr->elem_type)
        {
            handle = &(((OCIDate *)(arr->mem_handle))[i]);
        }
        else
        {
            handle = ((void **)(arr->mem_handle))[i];
        }

        arr->tab_obj[i] = ((char *) arr->mem_struct) + (arr->struct_size * i);

        ((OCI_Datatype *) (arr->tab_obj[i]))->hstate = OCI_OBJECT_ALLOCATED_ARRAY;

        switch (arr->elem_type)
        {
            case OCI_CDT_DATETIME:
            {
                OCI_DateInit(arr->con, (OCI_Date **) &arr->tab_obj[i],
                             (OCIDate *) handle, FALSE, FALSE);
                break;
            }
            case OCI_CDT_LOB:
            {
                OCI_LobInit(arr->con, (OCI_Lob **) &arr->tab_obj[i],
                            (OCILobLocator *) handle, arr->elem_subtype);
                break;
            }
            case OCI_CDT_FILE:
            {
                OCI_FileInit(arr->con, (OCI_File **) &arr->tab_obj[i],
                             (OCILobLocator *) handle, arr->elem_subtype);
                break;
            }
            case OCI_CDT_TIMESTAMP:
            {
                OCI_TimestampInit(arr->con, (OCI_Timestamp **) &arr->tab_obj[i],
                                  (OCIDateTime *) handle, arr->elem_subtype);
                break;
            }
            case OCI_CDT_INTERVAL:
            {
                OCI_IntervalInit(arr->con, (OCI_Interval **) &arr->tab_obj[i],
                                 (OCIInterval *) handle, arr->elem_subtype);
                break;
            }
            case OCI_CDT_OBJECT:
            {
                OCI_ObjectInit(arr->con, (OCI_Object **) &arr->tab_obj[i],
                               handle, typinf, NULL, -1, TRUE);
                break;
            }
            case OCI_CDT_COLLECTION:
            {
                OCI_CollInit(arr->con, (OCI_Coll **) &arr->tab_obj[i], handle, typinf);
                break;
            }
            case OCI_CDT_REF:
            {
                OCI_RefInit(arr->con, &typinf, (OCI_Ref **) &arr->tab_obj[i], handle);
                break;
            }
        }
    }

    return TRUE;
}