⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 element.c

📁 oci的源码,可以在任何平台上编译,相当方便实用
💻 C
📖 第 1 页 / 共 3 页
字号:
            
            OCIRawAllocSize(OCILib.env, elem->con->err, raw, (ub4*) &raw_len)
        )

        if (res == TRUE)
        {
            if (len > raw_len)
                len = raw_len;

            memcpy(value, OCIRawPtr(OCILib.env, raw), len);
        }
    }

    OCI_RESULT(res);

    return len; 
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemGetDate
 * ------------------------------------------------------------------------ */

OCI_Date * OCI_API  OCI_ElemGetDate(OCI_Elem *elem)
{
    boolean res    = TRUE;
    OCI_Date *date = NULL;

    OCI_CHECK_PTR(OCI_IPC_ELEMENT, elem, NULL);
    OCI_CHECK_COMPAT(elem->con, elem->typinf->cols[0].type == OCI_CDT_DATETIME, NULL);

    if (*(elem->ind) == OCI_IND_NOTNULL)
    {
        OCIDate *handle = (OCIDate *) elem->handle;

        if (elem->init == FALSE)
        {
            date = OCI_DateInit(elem->con, (OCI_Date **) &elem->obj, handle , 
                                FALSE, FALSE);

            elem->init = (date != NULL);
        }
        else
            date = (OCI_Date *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(res);

    return date;
}
/* ------------------------------------------------------------------------ *
 * OCI_ElemGetTimeStamp
 * ------------------------------------------------------------------------ */

OCI_Timestamp * OCI_API  OCI_ElemGetTimeStamp(OCI_Elem *elem)
{
    boolean res = TRUE;
    OCI_Timestamp *tmsp = NULL;

    OCI_CHECK_PTR(OCI_IPC_ELEMENT, elem, NULL);
    OCI_CHECK_COMPAT(elem->con, elem->typinf->cols[0].type == OCI_CDT_TIMESTAMP, NULL);

    if (*(elem->ind) == OCI_IND_NOTNULL)
    {
        OCIDateTime *handle = (OCIDateTime *) elem->handle;

        if (elem->init == FALSE)
        {
            tmsp = OCI_TimestampInit(elem->con, (OCI_Timestamp **) &elem->obj, 
                                     handle, elem->typinf->cols[0].subtype);

            elem->init = (tmsp != NULL);
        }
        else
            tmsp = (OCI_Timestamp *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(res);

    return tmsp;
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemGetInterval
 * ------------------------------------------------------------------------ */

OCI_Interval * OCI_API OCI_ElemGetInterval(OCI_Elem *elem)
{
    boolean res = TRUE;
    OCI_Interval *itv = NULL;

    OCI_CHECK_PTR(OCI_IPC_ELEMENT, elem, NULL);
    OCI_CHECK_COMPAT(elem->con, elem->typinf->cols[0].type == OCI_CDT_INTERVAL, NULL);

    if (*(elem->ind) == OCI_IND_NOTNULL)
    {
        OCIInterval *handle = (OCIInterval *) elem->handle;

        if (elem->init == FALSE)
        {
            itv = OCI_IntervalInit(elem->con, (OCI_Interval **) &elem->obj, 
                                   handle, elem->typinf->cols[0].subtype);

            elem->init = (itv != NULL);
        }
        else
            itv = (OCI_Interval *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(res);

    return itv;
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemGetLob
 * ------------------------------------------------------------------------ */

OCI_Lob * OCI_API  OCI_ElemGetLob(OCI_Elem *elem)
{
    boolean res  = TRUE;
    OCI_Lob *lob = NULL;

    OCI_CHECK_PTR(OCI_IPC_ELEMENT, elem, NULL);
    OCI_CHECK_COMPAT(elem->con, elem->typinf->cols[0].type == OCI_CDT_LOB, NULL);

    if (*(elem->ind) == OCI_IND_NOTNULL)
    {
        OCILobLocator *handle = *(OCILobLocator **) elem->handle;
        
        if (elem->init == FALSE)
        {
            lob = OCI_LobInit(elem->con, (OCI_Lob **) &elem->obj, handle,
                              elem->typinf->cols[0].subtype);

            elem->init = (lob != NULL);
        }
        else
            lob = (OCI_Lob *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(res);

    return lob;
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemGetFile
 * ------------------------------------------------------------------------ */

OCI_File * OCI_API  OCI_ElemGetFile(OCI_Elem *elem)
{
    boolean res    = TRUE;
    OCI_File *file = NULL;

    OCI_CHECK_PTR(OCI_IPC_ELEMENT, elem, NULL);
    OCI_CHECK_COMPAT(elem->con, elem->typinf->cols[0].type == OCI_CDT_FILE, NULL);

    if (*(elem->ind) == OCI_IND_NOTNULL)
    {
        OCILobLocator *handle = *(OCILobLocator **) elem->handle;

        if (elem->init == FALSE)
        {
            file = OCI_FileInit(elem->con, (OCI_File **) &elem->obj, handle, 
                                elem->typinf->cols[0].subtype);

            elem->init = (file != NULL);
        }
        else
            file = (OCI_File *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(res);

    return file;
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemGetRef
 * ------------------------------------------------------------------------ */

OCI_Ref * OCI_API  OCI_ElemGetRef(OCI_Elem *elem)
{
    boolean res  = TRUE;
    OCI_Ref *ref = NULL;

    OCI_CHECK_PTR(OCI_IPC_ELEMENT, elem, NULL);
    OCI_CHECK_COMPAT(elem->con, elem->typinf->cols[0].type == OCI_CDT_REF, NULL);

    if (*(elem->ind) == OCI_IND_NOTNULL)
    {
        OCIRef *handle = *(OCIRef **) elem->handle;
        
        if (elem->init == FALSE)
        {
            ref = OCI_RefInit(elem->con, elem->typinf->cols[0].typinf, 
                              (OCI_Ref **) &elem->obj, handle);

            elem->init = (ref != NULL);
        }
        else
            ref = (OCI_Ref *) elem->obj;

        res = elem->init;
    }

    OCI_RESULT(res);

    return ref;
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemGetObject
 * ------------------------------------------------------------------------ */

OCI_Object * OCI_API OCI_ElemGetObject(OCI_Elem *elem)
{
    boolean res = TRUE;
    OCI_Object *obj = NULL;

    OCI_CHECK_PTR(OCI_IPC_ELEMENT, elem, NULL);
    OCI_CHECK_COMPAT(elem->con, elem->typinf->cols[0].type == OCI_CDT_OBJECT, NULL);

    if (*(elem->ind) == OCI_IND_NOTNULL)
    {
        void * handle = elem->handle;

        if (elem->init == FALSE)
        {
            obj = OCI_ObjectInit(elem->con, (OCI_Object **) &elem->obj,
                                 handle, elem->typinf->cols[0].typinf, NULL, -1, TRUE);

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

        res = elem->init;
    }

    OCI_RESULT(res);

    return obj;
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemGetColl
 * ------------------------------------------------------------------------ */

OCI_Coll * OCI_API OCI_ElemGetColl(OCI_Elem *elem)
{
    boolean res    = TRUE;
    OCI_Coll *coll = NULL;

    OCI_CHECK_PTR(OCI_IPC_ELEMENT, elem, NULL);
    OCI_CHECK_COMPAT(elem->con, elem->typinf->cols[0].type == OCI_CDT_COLLECTION, NULL);

    if (*(elem->ind) == OCI_IND_NOTNULL)
    {
        OCIColl *handle = (OCIColl *) elem->handle;

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

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

        res = elem->init;
    }

    OCI_RESULT(res);

    return coll;
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemSetShort
 * ------------------------------------------------------------------------ */

boolean OCI_API OCI_ElemSetShort(OCI_Elem *elem, short value)
{
    return OCI_ElemSetNumber(elem, (void *) &value, (uword) sizeof(value), 
                             (uword) OCI_NUM_SHORT);
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemSetUnsignedShort
 * ------------------------------------------------------------------------ */

boolean OCI_API OCI_ElemSetUnsignedShort(OCI_Elem *elem, unsigned short value)
{
    return OCI_ElemSetNumber(elem, (void *) &value, (uword) sizeof(value), 
                             (uword) OCI_NUM_USHORT);
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemSetInt
 * ------------------------------------------------------------------------ */

boolean OCI_API OCI_ElemSetInt(OCI_Elem *elem, int value)
{
    return OCI_ElemSetNumber(elem, (void *) &value, (uword) sizeof(value), 
                             (uword) OCI_NUM_INT);
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemSetUnsignedInt
 * ------------------------------------------------------------------------ */

boolean OCI_API OCI_ElemSetUnsignedInt(OCI_Elem *elem, unsigned int value)
{
    return OCI_ElemSetNumber(elem, (void *) &value, (uword) sizeof(value), 
                             (uword) OCI_NUM_UINT);
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemSetBigInt
 * ------------------------------------------------------------------------ */

boolean OCI_API OCI_ElemSetBigInt(OCI_Elem *elem, big_int value)
{
    return OCI_ElemSetNumber(elem, (void *) &value, (uword) sizeof(value), 
                             (uword) OCI_NUM_BIGINT);
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemSetUnsignedBigInt
 * ------------------------------------------------------------------------ */

boolean OCI_API OCI_ElemSetUnsignedBigInt(OCI_Elem *elem, big_uint value)
{
    return OCI_ElemSetNumber(elem, (void *) &value, (uword) sizeof(value), 
                             (uword) OCI_NUM_BIGUINT);
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemSetDouble
 * ------------------------------------------------------------------------ */

boolean OCI_API OCI_ElemSetDouble(OCI_Elem *elem, double value)
{
    return OCI_ElemSetNumber(elem, (void *) &value, (uword) sizeof(value), 
                             (uword) OCI_NUM_DOUBLE);
}

/* ------------------------------------------------------------------------ *
 * OCI_ElemSetString
 * ------------------------------------------------------------------------ */

boolean OCI_API OCI_ElemSetString(OCI_Elem *elem, const dtext *value)
{
    boolean res  = TRUE;

    OCI_CHECK_PTR(OCI_IPC_ELEMENT, elem, FALSE);
    OCI_CHECK_COMPAT(elem->con, elem->typinf->cols[0].type == OCI_CDT_TEXT, FALSE);

    if (value == NULL)
    {
        res = OCI_ElemSetNull(elem);
    }
    else
    {
        OCIString **str = (OCIString **) elem->handle;

        res = OCI_StringToStringPtr(str, elem->con->err, (void *) value, 
                                    &elem->buf, &elem->buflen);
    }

    OCI_RESULT(res);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -