📄 object.c
字号:
if (index >= 0)
{
OCIInd ind = 0;
OCIType *tdo = NULL;
OCIColl **value = NULL;
res = OCI_ObjectGetAttr(obj, attr, (dvoid **) (dvoid *) &value, &ind, &tdo);
if ((res == TRUE) && (value != NULL) && (ind == OCI_IND_NOTNULL))
{
coll = OCI_CollInit(obj->con,
(OCI_Coll **) &obj->objs[index],
(OCIColl *) value,
obj->typinf->cols[index].typinf);
res = (coll != NULL);
}
}
OCI_RESULT(res);
return coll;
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectGetObject
* ------------------------------------------------------------------------ */
OCI_Object * OCI_API OCI_ObjectGetObject(OCI_Object *obj, const mtext *attr)
{
OCI_Object *obj2 = NULL;
boolean res = FALSE;
int index = OCI_ObjectGetIndex(obj, attr, OCI_CDT_OBJECT);
if (index >= 0)
{
OCIInd ind = 0;
OCIType *tdo = NULL;
void *value = NULL;
res = OCI_ObjectGetAttr(obj, attr, (void **) &value, &ind, &tdo);
if ((res == TRUE) && (value != NULL) && (ind == OCI_IND_NOTNULL))
{
obj2 = OCI_ObjectInit(obj->con, (OCI_Object **) &obj->objs[index],
value, obj->typinf->cols[index].typinf,
obj->tab_ind, index, FALSE);
res = (obj2 != NULL);
}
}
OCI_RESULT(res);
return obj2;
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectGetLob
* ------------------------------------------------------------------------ */
OCI_Lob * OCI_API OCI_ObjectGetLob(OCI_Object *obj, const mtext *attr)
{
OCI_Lob *lob = NULL;
boolean res = FALSE;
int index = OCI_ObjectGetIndex(obj, attr, OCI_CDT_LOB);
if (index >= 0)
{
OCIInd ind = 0;
OCIType *tdo = NULL;
OCILobLocator **value = NULL;
res = OCI_ObjectGetAttr(obj, attr, (dvoid **) (dvoid *) &value, &ind, &tdo);
if ((res == TRUE) && (value != NULL) && (ind == OCI_IND_NOTNULL))
{
lob = OCI_LobInit(obj->con, (OCI_Lob **) &obj->objs[index],
*value, obj->typinf->cols[index].subtype);
res = (lob != NULL);
}
}
OCI_RESULT(res);
return lob;
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectGetFile
* ------------------------------------------------------------------------ */
OCI_File * OCI_API OCI_ObjectGetFile(OCI_Object *obj, const mtext *attr)
{
OCI_File *file = NULL;
boolean res = FALSE;
int index = OCI_ObjectGetIndex(obj, attr, OCI_CDT_FILE);
if (index >= 0)
{
OCIInd ind = 0;
OCIType *tdo = NULL;
OCILobLocator **value = NULL;
res = OCI_ObjectGetAttr(obj, attr, (dvoid **) (dvoid *) &value, &ind, &tdo);
if ((res == TRUE) && (value != NULL) && (ind == OCI_IND_NOTNULL))
{
file = OCI_FileInit(obj->con, (OCI_File **) &obj->objs[index],
*value, obj->typinf->cols[index].subtype);
res = (file != NULL);
}
}
OCI_RESULT(res);
return file;
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectGetRef
* ------------------------------------------------------------------------ */
OCI_Ref * OCI_API OCI_ObjectGetRef(OCI_Object *obj, const mtext *attr)
{
OCI_Ref *ref = NULL;
boolean res = FALSE;
int index = OCI_ObjectGetIndex(obj, attr, OCI_CDT_REF);
if (index >= 0)
{
OCIInd ind = 0;
OCIType *tdo = NULL;
OCIRef **value = NULL;
res = OCI_ObjectGetAttr(obj, attr, (dvoid **) (dvoid *) &value, &ind, &tdo);
if ((res == TRUE) && (value != NULL) && (ind == OCI_IND_NOTNULL))
{
ref = OCI_RefInit(obj->con, NULL, (OCI_Ref **) &obj->objs[index],
*value);
res = (ref != NULL);
}
}
OCI_RESULT(res);
return ref;
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetShort
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetShort(OCI_Object *obj, const mtext *attr, short value)
{
return OCI_ObjectSetNumber(obj, attr, &value, sizeof(value),
(uword) OCI_NUM_SHORT);
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetUnsignedShort
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetUnsignedShort(OCI_Object *obj, const mtext *attr,
unsigned short value)
{
return OCI_ObjectSetNumber(obj, attr, &value, sizeof(value),
(uword) OCI_NUM_USHORT);
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetInt
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetInt(OCI_Object *obj, const mtext *attr, int value)
{
return OCI_ObjectSetNumber(obj, attr, &value, sizeof(value),
(uword) OCI_NUM_INT);
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetUnsignedInt
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetUnsignedInt(OCI_Object *obj, const mtext *attr,
unsigned int value)
{
return OCI_ObjectSetNumber(obj, attr, &value, sizeof(value),
(uword) OCI_NUM_UINT);
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetBigInt
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetBigInt(OCI_Object *obj, const mtext *attr,
big_int value)
{
return OCI_ObjectSetNumber(obj, attr, &value, sizeof(value),
(uword) OCI_NUM_BIGINT);
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetUnsignedBigInt
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetUnsignedBigInt(OCI_Object *obj, const mtext *attr,
big_uint value)
{
return OCI_ObjectSetNumber(obj, attr, &value, sizeof(value),
(uword) OCI_NUM_BIGUINT);
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetDouble
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetDouble(OCI_Object *obj, const mtext *attr,
double value)
{
return OCI_ObjectSetNumber(obj, attr, &value, sizeof(value),
(uword) OCI_NUM_DOUBLE);
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetString
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetString(OCI_Object *obj, const mtext *attr,
const dtext *value)
{
boolean res = TRUE;
if (value == NULL)
{
res = OCI_ObjectSetNull(obj, attr);
}
else
{
int index = OCI_ObjectGetIndex(obj, attr, OCI_CDT_TEXT);
if (index >= 0)
{
OCIString *str = NULL;
res = OCI_StringToStringPtr(&str, obj->con->err, (void *) value,
&obj->buf, &obj->buflen);
if (res == TRUE)
res = OCI_ObjectSetAttr(obj, attr, (void *) str, 0);
}
else
res = FALSE;
}
OCI_RESULT(res);
return res;
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetRaw
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetRaw(OCI_Object *obj, const mtext *attr,
void* value, unsigned int len)
{
boolean res = TRUE;
if (value == NULL)
{
res = OCI_ObjectSetNull(obj, attr);
}
else
{
int index;
OCI_CHECK_MIN(obj->con, NULL, len, 1, FALSE);
index = OCI_ObjectGetIndex(obj, attr, OCI_CDT_RAW);
if (index >= 0)
{
OCIRaw *raw = NULL;
OCI_CALL2
(
res, obj->con,
OCIRawAssignBytes(OCILib.env, obj->con->err, (ub1*) value, len,
&raw)
)
if (res == TRUE)
res = OCI_ObjectSetAttr(obj, attr, (void *) raw, 0);
}
else
res = FALSE;
}
OCI_RESULT(res);
return res;
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetDate
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetDate(OCI_Object *obj, const mtext *attr,
OCI_Date *value)
{
boolean res = FALSE;
if (value == NULL)
{
res = OCI_ObjectSetNull(obj, attr);
}
else
{
int index = OCI_ObjectGetIndex(obj, attr, OCI_CDT_DATETIME);
if (index >= 0)
{
OCI_Date *date = (OCI_Date *) obj->objs[index];
if (date == NULL)
{
date = OCI_DateInit(obj->con, (OCI_Date **) &obj->objs[index],
NULL, TRUE, FALSE);
}
if (date != NULL)
{
res = (OCI_DateAssign(date, value) &&
OCI_ObjectSetAttr(obj, attr, (void *) date->handle,
OCI_IND_NOTNULL));
}
}
}
OCI_RESULT(res);
return res;
}
/* ------------------------------------------------------------------------ *
* OCI_ObjectSetTimestamp
* ------------------------------------------------------------------------ */
boolean OCI_API OCI_ObjectSetTimestamp(OCI_Object *obj, const mtext *attr,
OCI_Timestamp *value)
{
boolean res = FALSE;
if (value == NULL)
{
res = OCI_ObjectSetNull(obj, attr);
}
else
{
int index = OCI_ObjectGetIndex(obj, attr, OCI_CDT_TIMESTAMP);
if (index >= 0)
{
OCI_Timestamp *tmsp = (OCI_Timestamp *) obj->objs[index];
if (tmsp == NULL)
{
tmsp = OCI_TimestampInit(obj->con,
(OCI_Timestamp **) &obj->objs[index],
NULL, obj->typinf->cols[index].subtype);
}
if (tmsp != NULL)
{
res = (OCI_TimestampAssign(tmsp, value) &&
OCI_ObjectSetAttr(obj, attr, (void *) tmsp->handle,
OCI_IND_NOTNULL));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -