/* boolean OCI_API OCI_IntervalSetYearMonth(OCI_Interval *itv, int year, int month) { return OCI_IntervalSetYearMonth2(&OCILib, itv, year, month); } */ boolean OCI_API OCI_IntervalSetYearMonth2(OCI_Library *pOCILib, OCI_Interval *itv, int year, int month, ExceptionSink* xsink) { boolean res = TRUE; OCI_CHECK_PTR(pOCILib, OCI_IPC_INTERVAL, itv, FALSE); OCI_CHECK_INTERVAL_ENABLED(pOCILib, itv->con, FALSE, xsink); #if OCI_VERSION_COMPILE >= OCI_9_0 OCI_CALL4Q ( pOCILib, res, itv->err, itv->con, OCIIntervalSetYearMonth((dvoid *) pOCILib->env, itv->err, (sb4) year, (sb4) month, itv->handle), xsink ) #else OCI_NOT_USED(year); OCI_NOT_USED(month); #endif OCI_RESULT(pOCILib, res); return res; }
/* boolean OCI_API OCI_IntervalGetDaySecond(OCI_Interval *itv, int *day, int *hour, int *min, int *sec, int *fsec) { return OCI_IntervalGetDaySecond2(&OCILib, itv, day, hour, min, sec, fsec); } */ boolean OCI_API OCI_IntervalGetDaySecond2(OCI_Library *pOCILib, OCI_Interval *itv, int *day, int *hour, int *min, int *sec, int *fsec, ExceptionSink* xsink) { boolean res = TRUE; OCI_CHECK_PTR(pOCILib, OCI_IPC_INTERVAL, itv, FALSE); OCI_CHECK_PTR(pOCILib, OCI_IPC_INT, hour, FALSE); OCI_CHECK_PTR(pOCILib, OCI_IPC_INT, min , FALSE); OCI_CHECK_PTR(pOCILib, OCI_IPC_INT, sec, FALSE); OCI_CHECK_PTR(pOCILib, OCI_IPC_INT, fsec, FALSE); OCI_CHECK_INTERVAL_ENABLED(pOCILib, itv->con, FALSE, xsink); *day = 0; *hour = 0; *min = 0; *sec = 0; *fsec = 0; #if OCI_VERSION_COMPILE >= OCI_9_0 OCI_CALL4Q ( pOCILib, res, itv->err, itv->con, OCIIntervalGetDaySecond((dvoid *) pOCILib->env, itv->err, (sb4 *) day, (sb4 *) hour, (sb4 *) min, (sb4 *) sec, (sb4 *) fsec, itv->handle), xsink ) #else OCI_NOT_USED(day); OCI_NOT_USED(hour); OCI_NOT_USED(min); OCI_NOT_USED(sec); OCI_NOT_USED(fsec); #endif OCI_RESULT(pOCILib, res); return res; }
OCI_Interval * OCI_API OCI_IntervalCreate2(OCI_Library *pOCILib, OCI_Connection *con, unsigned int type, ExceptionSink* xsink) { OCI_Interval *itv = NULL; OCI_CHECK_INITIALIZED2(pOCILib, NULL); OCI_CHECK_INTERVAL_ENABLED(pOCILib, con, NULL, xsink); #if OCI_VERSION_COMPILE >= OCI_9_0 itv = OCI_IntervalInit(pOCILib, con, &itv, NULL, type); #else OCI_NOT_USED(type); #endif OCI_RESULT(pOCILib, itv != NULL); return itv; }
OCI_EXPORT boolean OCI_API OCI_DequeueSubscribe ( OCI_Dequeue *dequeue, unsigned int port, unsigned int timeout, POCI_NOTIFY_AQ callback ) { boolean res = TRUE; ub4 oci_namespace = OCI_SUBSCR_NAMESPACE_AQ; #if OCI_VERSION_COMPILE >= OCI_10_2 ub4 oci_port = (ub4) port; ub4 oci_timeout = (ub4) timeout; ub4 oci_protocol = OCI_SUBSCR_PROTO_OCI; ub4 oci_msgpres = OCI_SUBSCR_PRES_DEFAULT; #endif OCI_Connection *con = NULL; OCI_CHECK_INITIALIZED(FALSE); OCI_CHECK_DATABASE_NOTIFY_ENABLED(FALSE); OCI_CHECK_PTR(OCI_IPC_DEQUEUE, dequeue, FALSE); con = dequeue->typinf->con; /* clear any previous subscription */ OCI_DequeueUnsubscribe(dequeue); /* allocate subcription handle */ res = (OCI_SUCCESS == OCI_HandleAlloc(con->env, (dvoid **) (void *) &dequeue->subhp, OCI_HTYPE_SUBSCRIPTION, (size_t) 0, (dvoid **) NULL)); #if OCI_VERSION_COMPILE >= OCI_10_2 /* set port number */ if (oci_port > 0) { OCI_CALL3 ( res, con->err, OCIAttrSet((dvoid *) dequeue->subhp, (ub4) OCI_HTYPE_SUBSCRIPTION, (dvoid *) &oci_port, (ub4) sizeof (oci_port), (ub4) OCI_ATTR_SUBSCR_PORTNO, con->err) ) } /* set timeout */ if (oci_timeout > 0) { OCI_CALL3 ( res, con->err, OCIAttrSet((dvoid *) dequeue->subhp, (ub4) OCI_HTYPE_SUBSCRIPTION, (dvoid *) &oci_timeout, (ub4) sizeof (oci_timeout), (ub4) OCI_ATTR_SUBSCR_TIMEOUT, con->err) ) } /* set protocol */ OCI_CALL3 ( res, con->err, OCIAttrSet((dvoid *) dequeue->subhp, (ub4) OCI_HTYPE_SUBSCRIPTION, (dvoid *) &oci_protocol, (ub4) sizeof(oci_protocol), (ub4) OCI_ATTR_SUBSCR_RECPTPROTO, con->err) ) /* set presentation */ OCI_CALL3 ( res, con->err, OCIAttrSet((dvoid *) dequeue->subhp, (ub4) OCI_HTYPE_SUBSCRIPTION, (dvoid *) &oci_msgpres, (ub4) sizeof(oci_msgpres), (ub4) OCI_ATTR_SUBSCR_RECPTPRES, con->err) ) #else OCI_NOT_USED(port); OCI_NOT_USED(timeout); #endif /* set name */ if (dequeue->name != NULL) { /* for AQ subscription, the name should be "[shema.]queue[:consumer]" */ mtext buffer[(OCI_SIZE_OBJ_NAME*2) + 2] = MT(""); mtext *str = NULL; size_t size = sizeof(buffer)/sizeof(mtext); void *ostr = NULL; int osize = -1; mtsncat(buffer, dequeue->name, size); if (dequeue->consumer != NULL) { size -= mtslen(dequeue->name); mtsncat(buffer, MT(":"), size); size -= (size_t) 1; mtsncat(buffer, dequeue->consumer, size); } /* queue name must be uppercase */ for (str = buffer; *str != 0; str++) { *str = (mtext) mttoupper(*str); } ostr = OCI_GetInputMetaString(buffer, &osize); OCI_CALL3 ( res, con->err, OCIAttrSet((dvoid *) dequeue->subhp, (ub4) OCI_HTYPE_SUBSCRIPTION, (dvoid *) ostr, (ub4) osize, (ub4) OCI_ATTR_SUBSCR_NAME, con->err) ) OCI_ReleaseMetaString(ostr); } /* set namespace */ OCI_CALL3 ( res, con->err, OCIAttrSet((dvoid *) dequeue->subhp, (ub4) OCI_HTYPE_SUBSCRIPTION, (dvoid *) &oci_namespace, (ub4) sizeof(oci_namespace), (ub4) OCI_ATTR_SUBSCR_NAMESPACE, con->err) ) /* set context pointer to dequeue structure */ OCI_CALL3 ( res, con->err, OCIAttrSet((dvoid *) dequeue->subhp, (ub4) OCI_HTYPE_SUBSCRIPTION, (dvoid *) dequeue, (ub4) 0, (ub4) OCI_ATTR_SUBSCR_CTX, con->err) ) /* internal callback handler */ OCI_CALL3 ( res, con->err, OCIAttrSet((dvoid *) dequeue->subhp, (ub4) OCI_HTYPE_SUBSCRIPTION, (dvoid *) OCI_ProcNotifyMessages, (ub4) 0, (ub4) OCI_ATTR_SUBSCR_CALLBACK, con->err) ) /* all attributes set, let's register the subscription ! */ OCI_CALL3 ( res, con->err, OCISubscriptionRegister(con->cxt, &dequeue->subhp, (ub2) 1, con->err,(ub4) OCI_DEFAULT) ) /* set callback on success */ if (res) { dequeue->callback = callback; } else { /* clear subscription on failure */ OCI_DequeueUnsubscribe(dequeue); } OCI_RESULT(res); return res; }
boolean OCI_NumberGet ( OCI_Connection *con, void *number, uword size, uword type, int sqlcode, void *out_value ) { boolean res = TRUE; OCI_CHECK(con == NULL, FALSE); OCI_CHECK(number == NULL, FALSE); OCI_CHECK(out_value == NULL, FALSE); #if OCI_VERSION_COMPILE < OCI_10_1 OCI_NOT_USED(sqlcode); #endif if (type == OCI_NUM_NUMBER) { memcpy(out_value, number, size); } else if (type & OCI_NUM_DOUBLE || type & OCI_NUM_FLOAT) { #if OCI_VERSION_COMPILE >= OCI_10_1 if ((OCILib.version_runtime >= OCI_10_1) && ((sqlcode != SQLT_VNU))) { if (((type & OCI_NUM_DOUBLE) && (sqlcode == SQLT_BDOUBLE)) || ((type & OCI_NUM_FLOAT ) && (sqlcode == SQLT_BFLOAT ))) { memcpy(out_value, number, size); } else if (type & OCI_NUM_DOUBLE && sqlcode == SQLT_BFLOAT) { *((double *) out_value) = (double) *((float *) number); } else if (type & OCI_NUM_FLOAT && sqlcode == SQLT_BDOUBLE) { *((float *) out_value) = (float) *((double *) number); } } else #endif { OCI_CALL2 ( res, con, OCINumberToReal(con->err, (OCINumber *) number, size, out_value) ) } } else {
OCI_Interval * OCI_IntervalInit(OCI_Library *pOCILib, OCI_Connection *con, OCI_Interval **pitv, OCIInterval *buffer, ub4 type) { OCI_Interval *itv = NULL; #if OCI_VERSION_COMPILE >= OCI_9_0 boolean res = TRUE; OCI_CHECK(pitv == NULL, NULL); if (*pitv == NULL) *pitv = (OCI_Interval *) OCI_MemAlloc2(pOCILib, OCI_IPC_INTERVAL, sizeof(*itv), (size_t) 1, TRUE); if (*pitv != NULL) { itv = *pitv; itv->con = con; itv->handle = buffer; itv->type = type; /* get the right error handle */ if (con != NULL) itv->err = con->err; else itv->err = pOCILib->err; /* allocate buffer if needed */ if ((itv->handle == NULL) || (itv->hstate == OCI_OBJECT_ALLOCATED_ARRAY)) { ub4 htype = 0; if (itv->type == OCI_INTERVAL_YM) htype = OCI_DTYPE_INTERVAL_YM; else if (itv->type == OCI_INTERVAL_DS) htype = OCI_DTYPE_INTERVAL_DS; if (itv->hstate != OCI_OBJECT_ALLOCATED_ARRAY) { res = (OCI_SUCCESS == OCI_DescriptorAlloc2(pOCILib, (dvoid *) pOCILib->env, (dvoid **) (void *) &itv->handle, (ub4 ) htype, (size_t) 0, (dvoid **) NULL)); itv->hstate = OCI_OBJECT_ALLOCATED; } } else itv->hstate = OCI_OBJECT_FETCHED_CLEAN; } else res = FALSE; /* check for failure */ if (res == FALSE) { OCI_IntervalFree2(pOCILib, itv); itv = NULL; } #else OCI_NOT_USED(con); OCI_NOT_USED(pitv); OCI_NOT_USED(type); OCI_NOT_USED(buffer); #endif return itv; }