Exemplo n.º 1
0
/*
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;
}
Exemplo n.º 2
0
OCIInterval *oci8_set_ociinterval_ym(OCIInterval *intvl, VALUE val)
{
    sb4 year;
    sb4 month;

    Check_Type(val, T_ARRAY);
    if (RARRAY_LEN(val) != 2) {
        rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
    }
    year = NUM2INT(RARRAY_PTR(val)[0]);
    month = NUM2INT(RARRAY_PTR(val)[1]);
    if (oracle_client_version >= ORAVERNUM(9, 2, 0, 3, 0)) {
        chkerr(OCIIntervalSetYearMonth(oci8_envhp, oci8_errhp,
                                       year, month, intvl));
    } else {
        /* Workaround for Bug 2227982 */
        char buf[64];
        const char *sign = "";

        if (year < 0 && month != 0) {
            year += 1;
            month -= 12;
        }
        if (year < 0 || month < 0) {
            sign = "-";
            year = -year;
            month = -month;
        }
        sprintf(buf, "%s%d-%d", sign, year, month);
        chkerr(OCIIntervalFromText(oci8_envhp, oci8_errhp, (text*)buf, strlen(buf), intvl));
    }
    return intvl;
}
Exemplo n.º 3
0
OCIInterval *oci8_set_ociinterval_ym(OCIInterval *intvl, VALUE val)
{
    sb4 year;
    sb4 month;

    Check_Type(val, T_ARRAY);
    if (RARRAY_LEN(val) != 2) {
        rb_raise(rb_eRuntimeError, "invalid array size %ld", RARRAY_LEN(val));
    }
    year = NUM2INT(RARRAY_AREF(val, 0));
    month = NUM2INT(RARRAY_AREF(val, 1));
    chkerr(OCIIntervalSetYearMonth(oci8_envhp, oci8_errhp,
                                   year, month, intvl));
    return intvl;
}