boolean OCI_API OCI_ElemSetObject2(OCI_Library *pOCILib, OCI_Elem *elem, OCI_Object *value, ExceptionSink* xsink) { boolean res = TRUE; OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, FALSE); if (elem->typinf->cols[0].type != OCI_CDT_OBJECT) { QoreStringNode* desc = new QoreStringNode("cannot bind an object 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_ObjectInit(pOCILib, elem->con, (OCI_Object **) &elem->obj, elem->handle, elem->typinf->cols[0].typinf, NULL, -1, TRUE, xsink); } if (elem->obj != NULL) { res = OCI_ObjectAssign2(pOCILib, (OCI_Object *) elem->obj, value, xsink); if (res == TRUE) { OCI_ElemSetNullIndicator(elem, OCI_IND_NOTNULL); elem->handle = ((OCI_Object *) elem->obj)->handle; } } } OCI_RESULT(pOCILib, res); return res; }
OCI_Object * OCI_API OCI_ElemGetObject2(OCI_Library * pOCILib, OCI_Elem *elem, ExceptionSink* xsink) { boolean res = TRUE; OCI_Object *obj = NULL; OCI_CHECK_PTR(pOCILib, OCI_IPC_ELEMENT, elem, NULL); if (elem->typinf->cols[0].type != OCI_CDT_OBJECT) { QoreStringNode* desc = new QoreStringNode("cannot retrieve an object value 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) { obj = OCI_ObjectInit(pOCILib, elem->con, (OCI_Object **) &elem->obj, elem->handle, elem->typinf->cols[0].typinf, NULL, -1, TRUE, xsink); elem->init = (obj != NULL); } else obj = (OCI_Object *) elem->obj; res = elem->init; } OCI_RESULT(pOCILib, res); return obj; }
OCI_Msg * OCI_API OCI_DequeueGet ( OCI_Dequeue *dequeue ) { boolean res = TRUE; sword ret = OCI_SUCCESS; OCI_Msg *msg = NULL; void *p_ind = NULL; OCI_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue, NULL); /* reset message */ res = OCI_MsgReset(dequeue->msg); if (res == TRUE) { void *ostr = NULL; int osize = -1; ostr = OCI_GetInputMetaString(dequeue->name, &osize); if (dequeue->typinf->tcode == OCI_UNKNOWN) { p_ind = &dequeue->msg->ind; } /* dequeue message */ ret = OCIAQDeq(dequeue->typinf->con->cxt, dequeue->typinf->con->err, ostr, dequeue->opth, dequeue->msg->proph, dequeue->typinf->tdo, &dequeue->msg->payload, (void **) &p_ind, &dequeue->msg->id, OCI_DEFAULT); OCI_ReleaseMetaString(ostr); /* check returned error code */ if (ret == OCI_ERROR) { sb4 code = 0; OCIErrorGet((dvoid *) dequeue->typinf->con->err, (ub4) 1, (OraText *) NULL, &code, (OraText *) NULL, (ub4) 0, (ub4) OCI_HTYPE_ERROR); /* raise error only if the call has not been timed out */ if (code != OCI_ERR_AQ_DEQUEUE_TIMEOUT) { OCI_ExceptionOCI(dequeue->typinf->con->err, dequeue->typinf->con, NULL, FALSE); res = FALSE; } } } /* reset message */ if ((res == TRUE) && (ret == OCI_SUCCESS)) { /* get payload */ if (dequeue->typinf->tcode != OCI_UNKNOWN) { if ((p_ind != NULL) && ((*(OCIInd *) p_ind) != OCI_IND_NULL)) { dequeue->msg->ind = *(OCIInd *) p_ind; dequeue->msg->obj = OCI_ObjectInit(dequeue->typinf->con, (OCI_Object **) &dequeue->msg->obj, dequeue->msg->payload, dequeue->typinf, NULL, -1, TRUE); res = dequeue->msg->obj != NULL; } } } /* on success return internla message handle */ if ((res == TRUE) && (ret == OCI_SUCCESS)) { msg = dequeue->msg; } OCI_RESULT(res); return msg; }
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; }