oracledb 3.0.0 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +135 -8
- package/README.md +6 -4
- package/build/Release/oracledb-abi48-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi48-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi48-linux-x64.node +0 -0
- package/build/Release/oracledb-abi48-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi48-win32-x64.node +0 -0
- package/build/Release/oracledb-abi48-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi57-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-linux-x64.node +0 -0
- package/build/Release/oracledb-abi57-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi57-win32-x64.node +0 -0
- package/build/Release/oracledb-abi57-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi64-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-linux-x64.node +0 -0
- package/build/Release/oracledb-abi64-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi64-win32-x64.node +0 -0
- package/build/Release/oracledb-abi64-win32-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-darwin-x64.node +0 -0
- package/build/Release/oracledb-abi67-darwin-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-linux-x64.node +0 -0
- package/build/Release/oracledb-abi67-linux-x64.node-buildinfo.txt +1 -0
- package/build/Release/oracledb-abi67-win32-x64.node +0 -0
- package/build/Release/oracledb-abi67-win32-x64.node-buildinfo.txt +1 -0
- package/lib/connection.js +18 -4
- package/lib/oracledb.js +44 -92
- package/lib/pool.js +36 -2
- package/lib/sodaCollection.js +1 -1
- package/lib/sodaDatabase.js +1 -1
- package/lib/util.js +82 -5
- package/package/README.md +32 -101
- package/package/install.js +139 -0
- package/package/prunebinaries.js +51 -0
- package/package.json +4 -11
- package/binding.gyp +0 -162
- package/lib/rel.txt +0 -1
- package/odpi/.npmignore +0 -4
- package/odpi/LICENSE.md +0 -218
- package/odpi/README.md +0 -61
- package/odpi/embed/README.md +0 -4
- package/odpi/embed/dpi.c +0 -50
- package/odpi/include/dpi.h +0 -1748
- package/odpi/src/dpiConn.c +0 -2089
- package/odpi/src/dpiContext.c +0 -296
- package/odpi/src/dpiData.c +0 -797
- package/odpi/src/dpiDebug.c +0 -184
- package/odpi/src/dpiDeqOptions.c +0 -370
- package/odpi/src/dpiEnqOptions.c +0 -174
- package/odpi/src/dpiEnv.c +0 -189
- package/odpi/src/dpiError.c +0 -204
- package/odpi/src/dpiErrorMessages.h +0 -86
- package/odpi/src/dpiGen.c +0 -303
- package/odpi/src/dpiGlobal.c +0 -292
- package/odpi/src/dpiHandleList.c +0 -117
- package/odpi/src/dpiHandlePool.c +0 -118
- package/odpi/src/dpiImpl.h +0 -1707
- package/odpi/src/dpiLob.c +0 -506
- package/odpi/src/dpiMsgProps.c +0 -386
- package/odpi/src/dpiObject.c +0 -897
- package/odpi/src/dpiObjectAttr.c +0 -115
- package/odpi/src/dpiObjectType.c +0 -326
- package/odpi/src/dpiOci.c +0 -3527
- package/odpi/src/dpiOracleType.c +0 -492
- package/odpi/src/dpiPool.c +0 -549
- package/odpi/src/dpiRowid.c +0 -136
- package/odpi/src/dpiSodaColl.c +0 -685
- package/odpi/src/dpiSodaCollCursor.c +0 -143
- package/odpi/src/dpiSodaDb.c +0 -432
- package/odpi/src/dpiSodaDoc.c +0 -230
- package/odpi/src/dpiSodaDocCursor.c +0 -143
- package/odpi/src/dpiStmt.c +0 -1797
- package/odpi/src/dpiSubscr.c +0 -674
- package/odpi/src/dpiUtils.c +0 -410
- package/odpi/src/dpiVar.c +0 -1794
- package/package/MAKEPKG.BAT +0 -156
- package/package/Makefile +0 -85
- package/package/createpackage.js +0 -186
- package/package/extractpackage.js +0 -76
- package/package/getversion.js +0 -37
- package/package/oracledbinstall.js +0 -497
- package/package/package.json +0 -54
- package/package/util.js +0 -286
- package/src/njsCommon.cpp +0 -1055
- package/src/njsCommon.h +0 -484
- package/src/njsConnection.cpp +0 -2926
- package/src/njsConnection.h +0 -227
- package/src/njsIntLob.cpp +0 -618
- package/src/njsIntLob.h +0 -179
- package/src/njsMessages.cpp +0 -122
- package/src/njsMessages.h +0 -118
- package/src/njsOracle.cpp +0 -1274
- package/src/njsOracle.h +0 -237
- package/src/njsPool.cpp +0 -482
- package/src/njsPool.h +0 -132
- package/src/njsResultSet.cpp +0 -478
- package/src/njsResultSet.h +0 -120
- package/src/njsSodaCollection.cpp +0 -507
- package/src/njsSodaCollection.h +0 -128
- package/src/njsSodaDatabase.cpp +0 -335
- package/src/njsSodaDatabase.h +0 -108
- package/src/njsSodaDocCursor.cpp +0 -203
- package/src/njsSodaDocCursor.h +0 -94
- package/src/njsSodaDocument.cpp +0 -412
- package/src/njsSodaDocument.h +0 -105
- package/src/njsSodaOperation.cpp +0 -557
- package/src/njsSodaOperation.h +0 -123
- package/src/njsSubscription.cpp +0 -388
- package/src/njsSubscription.h +0 -111
- package/src/njsUtils.cpp +0 -158
- package/src/njsUtils.h +0 -68
package/odpi/src/dpiObject.c
DELETED
|
@@ -1,897 +0,0 @@
|
|
|
1
|
-
//-----------------------------------------------------------------------------
|
|
2
|
-
// Copyright (c) 2016, 2018 Oracle and/or its affiliates. All rights reserved.
|
|
3
|
-
// This program is free software: you can modify it and/or redistribute it
|
|
4
|
-
// under the terms of:
|
|
5
|
-
//
|
|
6
|
-
// (i) the Universal Permissive License v 1.0 or at your option, any
|
|
7
|
-
// later version (http://oss.oracle.com/licenses/upl); and/or
|
|
8
|
-
//
|
|
9
|
-
// (ii) the Apache License v 2.0. (http://www.apache.org/licenses/LICENSE-2.0)
|
|
10
|
-
//-----------------------------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
//-----------------------------------------------------------------------------
|
|
13
|
-
// dpiObject.c
|
|
14
|
-
// Implementation of objects.
|
|
15
|
-
//-----------------------------------------------------------------------------
|
|
16
|
-
|
|
17
|
-
#include "dpiImpl.h"
|
|
18
|
-
|
|
19
|
-
//-----------------------------------------------------------------------------
|
|
20
|
-
// dpiObject__allocate() [INTERNAL]
|
|
21
|
-
// Allocate and initialize an object structure.
|
|
22
|
-
//-----------------------------------------------------------------------------
|
|
23
|
-
int dpiObject__allocate(dpiObjectType *objType, void *instance,
|
|
24
|
-
void *indicator, dpiObject *dependsOnObj, dpiObject **obj,
|
|
25
|
-
dpiError *error)
|
|
26
|
-
{
|
|
27
|
-
dpiObject *tempObj;
|
|
28
|
-
|
|
29
|
-
if (dpiGen__allocate(DPI_HTYPE_OBJECT, objType->env, (void**) &tempObj,
|
|
30
|
-
error) < 0)
|
|
31
|
-
return DPI_FAILURE;
|
|
32
|
-
dpiGen__setRefCount(objType, error, 1);
|
|
33
|
-
tempObj->type = objType;
|
|
34
|
-
tempObj->instance = instance;
|
|
35
|
-
tempObj->indicator = indicator;
|
|
36
|
-
if (dependsOnObj) {
|
|
37
|
-
dpiGen__setRefCount(dependsOnObj, error, 1);
|
|
38
|
-
tempObj->dependsOnObj = dependsOnObj;
|
|
39
|
-
}
|
|
40
|
-
if (!instance) {
|
|
41
|
-
if (dpiOci__objectNew(tempObj, error) < 0) {
|
|
42
|
-
dpiObject__free(tempObj, error);
|
|
43
|
-
return DPI_FAILURE;
|
|
44
|
-
}
|
|
45
|
-
if (dpiOci__objectGetInd(tempObj, error) < 0) {
|
|
46
|
-
dpiObject__free(tempObj, error);
|
|
47
|
-
return DPI_FAILURE;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
if (tempObj->instance && !dependsOnObj) {
|
|
51
|
-
if (dpiHandleList__addHandle(objType->conn->objects, tempObj,
|
|
52
|
-
&tempObj->openSlotNum, error) < 0) {
|
|
53
|
-
dpiObject__free(tempObj, error);
|
|
54
|
-
return DPI_FAILURE;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
*obj = tempObj;
|
|
58
|
-
return DPI_SUCCESS;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
//-----------------------------------------------------------------------------
|
|
63
|
-
// dpiObject__check() [INTERNAL]
|
|
64
|
-
// Determine if the object handle provided is available for use.
|
|
65
|
-
//-----------------------------------------------------------------------------
|
|
66
|
-
static int dpiObject__check(dpiObject *obj, const char *fnName,
|
|
67
|
-
dpiError *error)
|
|
68
|
-
{
|
|
69
|
-
if (dpiGen__startPublicFn(obj, DPI_HTYPE_OBJECT, fnName, 1, error) < 0)
|
|
70
|
-
return DPI_FAILURE;
|
|
71
|
-
return dpiConn__checkConnected(obj->type->conn, error);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
//-----------------------------------------------------------------------------
|
|
76
|
-
// dpiObject__checkIsCollection() [INTERNAL]
|
|
77
|
-
// Check if the object is a collection, and if not, raise an exception.
|
|
78
|
-
//-----------------------------------------------------------------------------
|
|
79
|
-
static int dpiObject__checkIsCollection(dpiObject *obj, const char *fnName,
|
|
80
|
-
dpiError *error)
|
|
81
|
-
{
|
|
82
|
-
if (dpiObject__check(obj, fnName, error) < 0)
|
|
83
|
-
return DPI_FAILURE;
|
|
84
|
-
if (!obj->type->isCollection)
|
|
85
|
-
return dpiError__set(error, "check collection", DPI_ERR_NOT_COLLECTION,
|
|
86
|
-
obj->type->schemaLength, obj->type->schema,
|
|
87
|
-
obj->type->nameLength, obj->type->name);
|
|
88
|
-
return DPI_SUCCESS;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
//-----------------------------------------------------------------------------
|
|
93
|
-
// dpiObject__clearOracleValue() [INTERNAL]
|
|
94
|
-
// Clear the Oracle value after use.
|
|
95
|
-
//-----------------------------------------------------------------------------
|
|
96
|
-
static void dpiObject__clearOracleValue(dpiObject *obj, dpiError *error,
|
|
97
|
-
dpiOracleDataBuffer *buffer, dpiOracleTypeNum oracleTypeNum)
|
|
98
|
-
{
|
|
99
|
-
switch (oracleTypeNum) {
|
|
100
|
-
case DPI_ORACLE_TYPE_CHAR:
|
|
101
|
-
case DPI_ORACLE_TYPE_NCHAR:
|
|
102
|
-
case DPI_ORACLE_TYPE_VARCHAR:
|
|
103
|
-
case DPI_ORACLE_TYPE_NVARCHAR:
|
|
104
|
-
if (buffer->asString)
|
|
105
|
-
dpiOci__stringResize(obj->env->handle, &buffer->asString, 0,
|
|
106
|
-
error);
|
|
107
|
-
break;
|
|
108
|
-
case DPI_ORACLE_TYPE_TIMESTAMP:
|
|
109
|
-
if (buffer->asTimestamp)
|
|
110
|
-
dpiOci__descriptorFree(buffer->asTimestamp,
|
|
111
|
-
DPI_OCI_DTYPE_TIMESTAMP);
|
|
112
|
-
break;
|
|
113
|
-
case DPI_ORACLE_TYPE_TIMESTAMP_TZ:
|
|
114
|
-
if (buffer->asTimestamp)
|
|
115
|
-
dpiOci__descriptorFree(buffer->asTimestamp,
|
|
116
|
-
DPI_OCI_DTYPE_TIMESTAMP_TZ);
|
|
117
|
-
break;
|
|
118
|
-
case DPI_ORACLE_TYPE_TIMESTAMP_LTZ:
|
|
119
|
-
if (buffer->asTimestamp)
|
|
120
|
-
dpiOci__descriptorFree(buffer->asTimestamp,
|
|
121
|
-
DPI_OCI_DTYPE_TIMESTAMP_LTZ);
|
|
122
|
-
break;
|
|
123
|
-
case DPI_ORACLE_TYPE_CLOB:
|
|
124
|
-
case DPI_ORACLE_TYPE_NCLOB:
|
|
125
|
-
case DPI_ORACLE_TYPE_BLOB:
|
|
126
|
-
case DPI_ORACLE_TYPE_BFILE:
|
|
127
|
-
if (buffer->asLobLocator) {
|
|
128
|
-
dpiOci__lobFreeTemporary(obj->type->conn, buffer->asLobLocator,
|
|
129
|
-
0, error);
|
|
130
|
-
dpiOci__descriptorFree(buffer->asLobLocator,
|
|
131
|
-
DPI_OCI_DTYPE_LOB);
|
|
132
|
-
}
|
|
133
|
-
default:
|
|
134
|
-
break;
|
|
135
|
-
};
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
//-----------------------------------------------------------------------------
|
|
140
|
-
// dpiObject__close() [INTERNAL]
|
|
141
|
-
// Close the object (frees the memory for the instance). This is needed to
|
|
142
|
-
// avoid trying to do so after the connection which created the object is
|
|
143
|
-
// closed. In some future release of the Oracle Client libraries this may not
|
|
144
|
-
// be needed, at which point this code and all of the code for managing the
|
|
145
|
-
// list of objects created by a collection can be removed.
|
|
146
|
-
//-----------------------------------------------------------------------------
|
|
147
|
-
int dpiObject__close(dpiObject *obj, int checkError, dpiError *error)
|
|
148
|
-
{
|
|
149
|
-
int closing;
|
|
150
|
-
|
|
151
|
-
// determine whether object is already being closed and if not, mark
|
|
152
|
-
// object as being closed; this MUST be done while holding the lock (if
|
|
153
|
-
// in threaded mode) to avoid race conditions!
|
|
154
|
-
if (obj->env->threaded)
|
|
155
|
-
dpiMutex__acquire(obj->env->mutex);
|
|
156
|
-
closing = obj->closing;
|
|
157
|
-
obj->closing = 1;
|
|
158
|
-
if (obj->env->threaded)
|
|
159
|
-
dpiMutex__release(obj->env->mutex);
|
|
160
|
-
|
|
161
|
-
// if object is already being closed, nothing needs to be done
|
|
162
|
-
if (closing)
|
|
163
|
-
return DPI_SUCCESS;
|
|
164
|
-
|
|
165
|
-
// perform actual work of closing object; if this fails, reset closing
|
|
166
|
-
// flag; again, this must be done while holding the lock (if in threaded
|
|
167
|
-
// mode) in order to avoid race conditions!
|
|
168
|
-
if (obj->instance && !obj->dependsOnObj) {
|
|
169
|
-
if (dpiOci__objectFree(obj, checkError, error) < 0) {
|
|
170
|
-
if (obj->env->threaded)
|
|
171
|
-
dpiMutex__acquire(obj->env->mutex);
|
|
172
|
-
obj->closing = 0;
|
|
173
|
-
if (obj->env->threaded)
|
|
174
|
-
dpiMutex__release(obj->env->mutex);
|
|
175
|
-
return DPI_FAILURE;
|
|
176
|
-
}
|
|
177
|
-
if (!obj->type->conn->closing)
|
|
178
|
-
dpiHandleList__removeHandle(obj->type->conn->objects,
|
|
179
|
-
obj->openSlotNum);
|
|
180
|
-
obj->instance = NULL;
|
|
181
|
-
obj->indicator = NULL;
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return DPI_SUCCESS;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
//-----------------------------------------------------------------------------
|
|
189
|
-
// dpiObject__free() [INTERNAL]
|
|
190
|
-
// Free the memory for an object.
|
|
191
|
-
//-----------------------------------------------------------------------------
|
|
192
|
-
void dpiObject__free(dpiObject *obj, dpiError *error)
|
|
193
|
-
{
|
|
194
|
-
dpiObject__close(obj, 0, error);
|
|
195
|
-
if (obj->type) {
|
|
196
|
-
dpiGen__setRefCount(obj->type, error, -1);
|
|
197
|
-
obj->type = NULL;
|
|
198
|
-
}
|
|
199
|
-
if (obj->dependsOnObj) {
|
|
200
|
-
dpiGen__setRefCount(obj->dependsOnObj, error, -1);
|
|
201
|
-
obj->dependsOnObj = NULL;
|
|
202
|
-
}
|
|
203
|
-
dpiUtils__freeMemory(obj);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
//-----------------------------------------------------------------------------
|
|
208
|
-
// dpiObject__fromOracleValue() [INTERNAL]
|
|
209
|
-
// Populate data from the Oracle value or return an error if this is not
|
|
210
|
-
// possible.
|
|
211
|
-
//-----------------------------------------------------------------------------
|
|
212
|
-
static int dpiObject__fromOracleValue(dpiObject *obj, dpiError *error,
|
|
213
|
-
const dpiDataTypeInfo *typeInfo, dpiOracleData *value,
|
|
214
|
-
int16_t *indicator, dpiNativeTypeNum nativeTypeNum, dpiData *data)
|
|
215
|
-
{
|
|
216
|
-
dpiOracleTypeNum valueOracleTypeNum;
|
|
217
|
-
dpiBytes *asBytes;
|
|
218
|
-
|
|
219
|
-
// null values are immediately returned (type is irrelevant)
|
|
220
|
-
if (*indicator == DPI_OCI_IND_NULL) {
|
|
221
|
-
data->isNull = 1;
|
|
222
|
-
return DPI_SUCCESS;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
// convert all other values
|
|
226
|
-
data->isNull = 0;
|
|
227
|
-
valueOracleTypeNum = typeInfo->oracleTypeNum;
|
|
228
|
-
switch (valueOracleTypeNum) {
|
|
229
|
-
case DPI_ORACLE_TYPE_CHAR:
|
|
230
|
-
case DPI_ORACLE_TYPE_NCHAR:
|
|
231
|
-
case DPI_ORACLE_TYPE_VARCHAR:
|
|
232
|
-
case DPI_ORACLE_TYPE_NVARCHAR:
|
|
233
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES) {
|
|
234
|
-
asBytes = &data->value.asBytes;
|
|
235
|
-
dpiOci__stringPtr(obj->env->handle, *value->asString,
|
|
236
|
-
&asBytes->ptr);
|
|
237
|
-
dpiOci__stringSize(obj->env->handle, *value->asString,
|
|
238
|
-
&asBytes->length);
|
|
239
|
-
if (valueOracleTypeNum == DPI_ORACLE_TYPE_NCHAR ||
|
|
240
|
-
valueOracleTypeNum == DPI_ORACLE_TYPE_NVARCHAR)
|
|
241
|
-
asBytes->encoding = obj->env->nencoding;
|
|
242
|
-
else asBytes->encoding = obj->env->encoding;
|
|
243
|
-
return DPI_SUCCESS;
|
|
244
|
-
}
|
|
245
|
-
break;
|
|
246
|
-
case DPI_ORACLE_TYPE_NATIVE_INT:
|
|
247
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_INT64)
|
|
248
|
-
return dpiDataBuffer__fromOracleNumberAsInteger(&data->value,
|
|
249
|
-
error, value->asNumber);
|
|
250
|
-
break;
|
|
251
|
-
case DPI_ORACLE_TYPE_NATIVE_FLOAT:
|
|
252
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_FLOAT) {
|
|
253
|
-
data->value.asFloat = *value->asFloat;
|
|
254
|
-
return DPI_SUCCESS;
|
|
255
|
-
}
|
|
256
|
-
break;
|
|
257
|
-
case DPI_ORACLE_TYPE_NATIVE_DOUBLE:
|
|
258
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) {
|
|
259
|
-
data->value.asDouble = *value->asDouble;
|
|
260
|
-
return DPI_SUCCESS;
|
|
261
|
-
}
|
|
262
|
-
break;
|
|
263
|
-
case DPI_ORACLE_TYPE_NUMBER:
|
|
264
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE)
|
|
265
|
-
return dpiDataBuffer__fromOracleNumberAsDouble(&data->value,
|
|
266
|
-
error, value->asNumber);
|
|
267
|
-
else if (nativeTypeNum == DPI_NATIVE_TYPE_INT64)
|
|
268
|
-
return dpiDataBuffer__fromOracleNumberAsInteger(&data->value,
|
|
269
|
-
error, value->asNumber);
|
|
270
|
-
else if (nativeTypeNum == DPI_NATIVE_TYPE_UINT64)
|
|
271
|
-
return dpiDataBuffer__fromOracleNumberAsUnsignedInteger(
|
|
272
|
-
&data->value, error, value->asNumber);
|
|
273
|
-
else if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES)
|
|
274
|
-
return dpiDataBuffer__fromOracleNumberAsText(&data->value,
|
|
275
|
-
obj->env, error, value->asNumber);
|
|
276
|
-
break;
|
|
277
|
-
case DPI_ORACLE_TYPE_DATE:
|
|
278
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP)
|
|
279
|
-
return dpiDataBuffer__fromOracleDate(&data->value,
|
|
280
|
-
value->asDate);
|
|
281
|
-
break;
|
|
282
|
-
case DPI_ORACLE_TYPE_TIMESTAMP:
|
|
283
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP)
|
|
284
|
-
return dpiDataBuffer__fromOracleTimestamp(&data->value,
|
|
285
|
-
obj->env, error, *value->asTimestamp, 0);
|
|
286
|
-
break;
|
|
287
|
-
case DPI_ORACLE_TYPE_TIMESTAMP_TZ:
|
|
288
|
-
case DPI_ORACLE_TYPE_TIMESTAMP_LTZ:
|
|
289
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP)
|
|
290
|
-
return dpiDataBuffer__fromOracleTimestamp(&data->value,
|
|
291
|
-
obj->env, error, *value->asTimestamp, 1);
|
|
292
|
-
break;
|
|
293
|
-
case DPI_ORACLE_TYPE_OBJECT:
|
|
294
|
-
if (typeInfo->objectType &&
|
|
295
|
-
nativeTypeNum == DPI_NATIVE_TYPE_OBJECT) {
|
|
296
|
-
void *instance = (typeInfo->objectType->isCollection) ?
|
|
297
|
-
*value->asCollection : value->asRaw;
|
|
298
|
-
dpiObject *tempObj;
|
|
299
|
-
if (dpiObject__allocate(typeInfo->objectType, instance,
|
|
300
|
-
indicator, obj, &tempObj, error) < 0)
|
|
301
|
-
return DPI_FAILURE;
|
|
302
|
-
data->value.asObject = tempObj;
|
|
303
|
-
return DPI_SUCCESS;
|
|
304
|
-
}
|
|
305
|
-
break;
|
|
306
|
-
case DPI_ORACLE_TYPE_BOOLEAN:
|
|
307
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_BOOLEAN) {
|
|
308
|
-
data->value.asBoolean = *(value->asBoolean);
|
|
309
|
-
return DPI_SUCCESS;
|
|
310
|
-
}
|
|
311
|
-
break;
|
|
312
|
-
case DPI_ORACLE_TYPE_CLOB:
|
|
313
|
-
case DPI_ORACLE_TYPE_NCLOB:
|
|
314
|
-
case DPI_ORACLE_TYPE_BLOB:
|
|
315
|
-
case DPI_ORACLE_TYPE_BFILE:
|
|
316
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_LOB) {
|
|
317
|
-
const dpiOracleType *lobType;
|
|
318
|
-
void *tempLocator;
|
|
319
|
-
dpiLob *tempLob;
|
|
320
|
-
lobType = dpiOracleType__getFromNum(typeInfo->oracleTypeNum,
|
|
321
|
-
error);
|
|
322
|
-
if (dpiLob__allocate(obj->type->conn, lobType, &tempLob,
|
|
323
|
-
error) < 0)
|
|
324
|
-
return DPI_FAILURE;
|
|
325
|
-
tempLocator = tempLob->locator;
|
|
326
|
-
tempLob->locator = *(value->asLobLocator);
|
|
327
|
-
if (dpiOci__lobLocatorAssign(tempLob, &tempLocator,
|
|
328
|
-
error) < 0) {
|
|
329
|
-
tempLob->locator = tempLocator;
|
|
330
|
-
dpiLob__free(tempLob, error);
|
|
331
|
-
return DPI_FAILURE;
|
|
332
|
-
}
|
|
333
|
-
tempLob->locator = tempLocator;
|
|
334
|
-
data->value.asLOB = tempLob;
|
|
335
|
-
return DPI_SUCCESS;
|
|
336
|
-
}
|
|
337
|
-
break;
|
|
338
|
-
default:
|
|
339
|
-
break;
|
|
340
|
-
};
|
|
341
|
-
|
|
342
|
-
return dpiError__set(error, "from Oracle value",
|
|
343
|
-
DPI_ERR_UNHANDLED_CONVERSION, valueOracleTypeNum, nativeTypeNum);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
//-----------------------------------------------------------------------------
|
|
348
|
-
// dpiObject__toOracleValue() [INTERNAL]
|
|
349
|
-
// Convert value from external type to the OCI data type required.
|
|
350
|
-
//-----------------------------------------------------------------------------
|
|
351
|
-
static int dpiObject__toOracleValue(dpiObject *obj, dpiError *error,
|
|
352
|
-
const dpiDataTypeInfo *dataTypeInfo, dpiOracleDataBuffer *buffer,
|
|
353
|
-
void **ociValue, int16_t *valueIndicator, void **objectIndicator,
|
|
354
|
-
dpiNativeTypeNum nativeTypeNum, dpiData *data)
|
|
355
|
-
{
|
|
356
|
-
dpiOracleTypeNum valueOracleTypeNum;
|
|
357
|
-
uint32_t handleType;
|
|
358
|
-
dpiObject *otherObj;
|
|
359
|
-
dpiBytes *bytes;
|
|
360
|
-
|
|
361
|
-
// nulls are handled easily
|
|
362
|
-
*objectIndicator = NULL;
|
|
363
|
-
if (data->isNull) {
|
|
364
|
-
*ociValue = NULL;
|
|
365
|
-
*valueIndicator = DPI_OCI_IND_NULL;
|
|
366
|
-
buffer->asRaw = NULL;
|
|
367
|
-
return DPI_SUCCESS;
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
// convert all other values
|
|
371
|
-
*valueIndicator = DPI_OCI_IND_NOTNULL;
|
|
372
|
-
valueOracleTypeNum = dataTypeInfo->oracleTypeNum;
|
|
373
|
-
switch (valueOracleTypeNum) {
|
|
374
|
-
case DPI_ORACLE_TYPE_CHAR:
|
|
375
|
-
case DPI_ORACLE_TYPE_NCHAR:
|
|
376
|
-
case DPI_ORACLE_TYPE_VARCHAR:
|
|
377
|
-
case DPI_ORACLE_TYPE_NVARCHAR:
|
|
378
|
-
buffer->asString = NULL;
|
|
379
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES) {
|
|
380
|
-
bytes = &data->value.asBytes;
|
|
381
|
-
if (dpiOci__stringAssignText(obj->env->handle, bytes->ptr,
|
|
382
|
-
bytes->length, &buffer->asString, error) < 0)
|
|
383
|
-
return DPI_FAILURE;
|
|
384
|
-
*ociValue = buffer->asString;
|
|
385
|
-
return DPI_SUCCESS;
|
|
386
|
-
}
|
|
387
|
-
break;
|
|
388
|
-
case DPI_ORACLE_TYPE_NATIVE_INT:
|
|
389
|
-
case DPI_ORACLE_TYPE_NUMBER:
|
|
390
|
-
*ociValue = &buffer->asNumber;
|
|
391
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_INT64)
|
|
392
|
-
return dpiDataBuffer__toOracleNumberFromInteger(&data->value,
|
|
393
|
-
error, &buffer->asNumber);
|
|
394
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE)
|
|
395
|
-
return dpiDataBuffer__toOracleNumberFromDouble(&data->value,
|
|
396
|
-
error, &buffer->asNumber);
|
|
397
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES)
|
|
398
|
-
return dpiDataBuffer__toOracleNumberFromText(&data->value,
|
|
399
|
-
obj->env, error, &buffer->asNumber);
|
|
400
|
-
break;
|
|
401
|
-
case DPI_ORACLE_TYPE_NATIVE_FLOAT:
|
|
402
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_FLOAT) {
|
|
403
|
-
buffer->asFloat = data->value.asFloat;
|
|
404
|
-
*ociValue = &buffer->asFloat;
|
|
405
|
-
return DPI_SUCCESS;
|
|
406
|
-
} else if (nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) {
|
|
407
|
-
buffer->asFloat = (float) data->value.asDouble;
|
|
408
|
-
*ociValue = &buffer->asFloat;
|
|
409
|
-
return DPI_SUCCESS;
|
|
410
|
-
}
|
|
411
|
-
break;
|
|
412
|
-
case DPI_ORACLE_TYPE_NATIVE_DOUBLE:
|
|
413
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_DOUBLE) {
|
|
414
|
-
buffer->asDouble = data->value.asDouble;
|
|
415
|
-
*ociValue = &buffer->asDouble;
|
|
416
|
-
return DPI_SUCCESS;
|
|
417
|
-
}
|
|
418
|
-
break;
|
|
419
|
-
case DPI_ORACLE_TYPE_DATE:
|
|
420
|
-
*ociValue = &buffer->asDate;
|
|
421
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP)
|
|
422
|
-
return dpiDataBuffer__toOracleDate(&data->value,
|
|
423
|
-
&buffer->asDate);
|
|
424
|
-
break;
|
|
425
|
-
case DPI_ORACLE_TYPE_TIMESTAMP:
|
|
426
|
-
case DPI_ORACLE_TYPE_TIMESTAMP_TZ:
|
|
427
|
-
case DPI_ORACLE_TYPE_TIMESTAMP_LTZ:
|
|
428
|
-
buffer->asTimestamp = NULL;
|
|
429
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP) {
|
|
430
|
-
if (valueOracleTypeNum == DPI_ORACLE_TYPE_TIMESTAMP)
|
|
431
|
-
handleType = DPI_OCI_DTYPE_TIMESTAMP;
|
|
432
|
-
else if (valueOracleTypeNum == DPI_ORACLE_TYPE_TIMESTAMP_TZ)
|
|
433
|
-
handleType = DPI_OCI_DTYPE_TIMESTAMP_TZ;
|
|
434
|
-
else handleType = DPI_OCI_DTYPE_TIMESTAMP_LTZ;
|
|
435
|
-
if (dpiOci__descriptorAlloc(obj->env->handle,
|
|
436
|
-
&buffer->asTimestamp, handleType, "allocate timestamp",
|
|
437
|
-
error) < 0)
|
|
438
|
-
return DPI_FAILURE;
|
|
439
|
-
*ociValue = buffer->asTimestamp;
|
|
440
|
-
return dpiDataBuffer__toOracleTimestamp(&data->value, obj->env,
|
|
441
|
-
error, buffer->asTimestamp,
|
|
442
|
-
(valueOracleTypeNum != DPI_ORACLE_TYPE_TIMESTAMP));
|
|
443
|
-
}
|
|
444
|
-
break;
|
|
445
|
-
case DPI_ORACLE_TYPE_OBJECT:
|
|
446
|
-
otherObj = data->value.asObject;
|
|
447
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_OBJECT) {
|
|
448
|
-
if (otherObj->type->tdo != dataTypeInfo->objectType->tdo)
|
|
449
|
-
return dpiError__set(error, "check type",
|
|
450
|
-
DPI_ERR_WRONG_TYPE, otherObj->type->schemaLength,
|
|
451
|
-
otherObj->type->schema, otherObj->type->nameLength,
|
|
452
|
-
otherObj->type->name,
|
|
453
|
-
dataTypeInfo->objectType->schemaLength,
|
|
454
|
-
dataTypeInfo->objectType->schema,
|
|
455
|
-
dataTypeInfo->objectType->nameLength,
|
|
456
|
-
dataTypeInfo->objectType->name);
|
|
457
|
-
*ociValue = otherObj->instance;
|
|
458
|
-
*objectIndicator = otherObj->indicator;
|
|
459
|
-
return DPI_SUCCESS;
|
|
460
|
-
}
|
|
461
|
-
break;
|
|
462
|
-
case DPI_ORACLE_TYPE_BOOLEAN:
|
|
463
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_BOOLEAN) {
|
|
464
|
-
buffer->asBoolean = data->value.asBoolean;
|
|
465
|
-
*ociValue = &buffer->asBoolean;
|
|
466
|
-
return DPI_SUCCESS;
|
|
467
|
-
}
|
|
468
|
-
break;
|
|
469
|
-
case DPI_ORACLE_TYPE_CLOB:
|
|
470
|
-
case DPI_ORACLE_TYPE_NCLOB:
|
|
471
|
-
case DPI_ORACLE_TYPE_BLOB:
|
|
472
|
-
case DPI_ORACLE_TYPE_BFILE:
|
|
473
|
-
buffer->asLobLocator = NULL;
|
|
474
|
-
if (nativeTypeNum == DPI_NATIVE_TYPE_LOB) {
|
|
475
|
-
*ociValue = data->value.asLOB->locator;
|
|
476
|
-
return DPI_SUCCESS;
|
|
477
|
-
} else if (nativeTypeNum == DPI_NATIVE_TYPE_BYTES) {
|
|
478
|
-
const dpiOracleType *lobType;
|
|
479
|
-
dpiLob *tempLob;
|
|
480
|
-
lobType = dpiOracleType__getFromNum(valueOracleTypeNum, error);
|
|
481
|
-
if (dpiLob__allocate(obj->type->conn, lobType, &tempLob,
|
|
482
|
-
error) < 0)
|
|
483
|
-
return DPI_FAILURE;
|
|
484
|
-
bytes = &data->value.asBytes;
|
|
485
|
-
if (dpiLob__setFromBytes(tempLob, bytes->ptr, bytes->length,
|
|
486
|
-
error) < 0) {
|
|
487
|
-
dpiLob__free(tempLob, error);
|
|
488
|
-
return DPI_FAILURE;
|
|
489
|
-
}
|
|
490
|
-
buffer->asLobLocator = tempLob->locator;
|
|
491
|
-
*ociValue = tempLob->locator;
|
|
492
|
-
tempLob->locator = NULL;
|
|
493
|
-
dpiLob__free(tempLob, error);
|
|
494
|
-
return DPI_SUCCESS;
|
|
495
|
-
}
|
|
496
|
-
break;
|
|
497
|
-
|
|
498
|
-
default:
|
|
499
|
-
break;
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
return dpiError__set(error, "to Oracle value",
|
|
503
|
-
DPI_ERR_UNHANDLED_CONVERSION, valueOracleTypeNum, nativeTypeNum);
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
//-----------------------------------------------------------------------------
|
|
508
|
-
// dpiObject_addRef() [PUBLIC]
|
|
509
|
-
// Add a reference to the object.
|
|
510
|
-
//-----------------------------------------------------------------------------
|
|
511
|
-
int dpiObject_addRef(dpiObject *obj)
|
|
512
|
-
{
|
|
513
|
-
return dpiGen__addRef(obj, DPI_HTYPE_OBJECT, __func__);
|
|
514
|
-
}
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
//-----------------------------------------------------------------------------
|
|
518
|
-
// dpiObject_appendElement() [PUBLIC]
|
|
519
|
-
// Append an element to the collection.
|
|
520
|
-
//-----------------------------------------------------------------------------
|
|
521
|
-
int dpiObject_appendElement(dpiObject *obj, dpiNativeTypeNum nativeTypeNum,
|
|
522
|
-
dpiData *data)
|
|
523
|
-
{
|
|
524
|
-
dpiOracleDataBuffer valueBuffer;
|
|
525
|
-
int16_t scalarValueIndicator;
|
|
526
|
-
void *indicator;
|
|
527
|
-
dpiError error;
|
|
528
|
-
void *ociValue;
|
|
529
|
-
int status;
|
|
530
|
-
|
|
531
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
532
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
533
|
-
DPI_CHECK_PTR_NOT_NULL(obj, data)
|
|
534
|
-
if (dpiObject__toOracleValue(obj, &error, &obj->type->elementTypeInfo,
|
|
535
|
-
&valueBuffer, &ociValue, &scalarValueIndicator,
|
|
536
|
-
(void**) &indicator, nativeTypeNum, data) < 0)
|
|
537
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
538
|
-
if (!indicator)
|
|
539
|
-
indicator = &scalarValueIndicator;
|
|
540
|
-
status = dpiOci__collAppend(obj->type->conn, ociValue, indicator,
|
|
541
|
-
obj->instance, &error);
|
|
542
|
-
dpiObject__clearOracleValue(obj, &error, &valueBuffer,
|
|
543
|
-
obj->type->elementTypeInfo.oracleTypeNum);
|
|
544
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
//-----------------------------------------------------------------------------
|
|
549
|
-
// dpiObject_copy() [PUBLIC]
|
|
550
|
-
// Create a copy of the object and return it. Return NULL upon error.
|
|
551
|
-
//-----------------------------------------------------------------------------
|
|
552
|
-
int dpiObject_copy(dpiObject *obj, dpiObject **copiedObj)
|
|
553
|
-
{
|
|
554
|
-
dpiObject *tempObj;
|
|
555
|
-
dpiError error;
|
|
556
|
-
|
|
557
|
-
if (dpiObject__check(obj, __func__, &error) < 0)
|
|
558
|
-
return DPI_FAILURE;
|
|
559
|
-
DPI_CHECK_PTR_NOT_NULL(obj, copiedObj)
|
|
560
|
-
if (dpiObject__allocate(obj->type, NULL, NULL, NULL, &tempObj, &error) < 0)
|
|
561
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
562
|
-
if (dpiOci__objectCopy(tempObj, obj->instance, obj->indicator,
|
|
563
|
-
&error) < 0) {
|
|
564
|
-
dpiObject__free(tempObj, &error);
|
|
565
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
566
|
-
}
|
|
567
|
-
*copiedObj = tempObj;
|
|
568
|
-
return dpiGen__endPublicFn(obj, DPI_SUCCESS, &error);
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
//-----------------------------------------------------------------------------
|
|
573
|
-
// dpiObject_deleteElementByIndex() [PUBLIC]
|
|
574
|
-
// Delete the element at the specified index in the collection.
|
|
575
|
-
//-----------------------------------------------------------------------------
|
|
576
|
-
int dpiObject_deleteElementByIndex(dpiObject *obj, int32_t index)
|
|
577
|
-
{
|
|
578
|
-
dpiError error;
|
|
579
|
-
int status;
|
|
580
|
-
|
|
581
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
582
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
583
|
-
status = dpiOci__tableDelete(obj, index, &error);
|
|
584
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
585
|
-
}
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
//-----------------------------------------------------------------------------
|
|
589
|
-
// dpiObject_getAttributeValue() [PUBLIC]
|
|
590
|
-
// Get the value of the given attribute from the object.
|
|
591
|
-
//-----------------------------------------------------------------------------
|
|
592
|
-
int dpiObject_getAttributeValue(dpiObject *obj, dpiObjectAttr *attr,
|
|
593
|
-
dpiNativeTypeNum nativeTypeNum, dpiData *data)
|
|
594
|
-
{
|
|
595
|
-
int16_t scalarValueIndicator;
|
|
596
|
-
void *valueIndicator, *tdo;
|
|
597
|
-
dpiOracleData value;
|
|
598
|
-
dpiError error;
|
|
599
|
-
int status;
|
|
600
|
-
|
|
601
|
-
// validate parameters
|
|
602
|
-
if (dpiObject__check(obj, __func__, &error) < 0)
|
|
603
|
-
return DPI_FAILURE;
|
|
604
|
-
DPI_CHECK_PTR_NOT_NULL(obj, data)
|
|
605
|
-
if (dpiGen__checkHandle(attr, DPI_HTYPE_OBJECT_ATTR, "get attribute value",
|
|
606
|
-
&error) < 0)
|
|
607
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
608
|
-
if (attr->belongsToType->tdo != obj->type->tdo) {
|
|
609
|
-
dpiError__set(&error, "get attribute value", DPI_ERR_WRONG_ATTR,
|
|
610
|
-
attr->nameLength, attr->name, obj->type->schemaLength,
|
|
611
|
-
obj->type->schema, obj->type->nameLength, obj->type->name);
|
|
612
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
// get attribute value
|
|
616
|
-
if (dpiOci__objectGetAttr(obj, attr, &scalarValueIndicator,
|
|
617
|
-
&valueIndicator, &value.asRaw, &tdo, &error) < 0)
|
|
618
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
619
|
-
|
|
620
|
-
// determine the proper null indicator
|
|
621
|
-
if (!valueIndicator)
|
|
622
|
-
valueIndicator = &scalarValueIndicator;
|
|
623
|
-
|
|
624
|
-
// check to see if type is supported
|
|
625
|
-
if (!attr->typeInfo.oracleTypeNum) {
|
|
626
|
-
dpiError__set(&error, "get attribute value",
|
|
627
|
-
DPI_ERR_UNHANDLED_DATA_TYPE, attr->typeInfo.ociTypeCode);
|
|
628
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
629
|
-
}
|
|
630
|
-
|
|
631
|
-
// convert to output data format
|
|
632
|
-
status = dpiObject__fromOracleValue(obj, &error, &attr->typeInfo, &value,
|
|
633
|
-
(int16_t*) valueIndicator, nativeTypeNum, data);
|
|
634
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
//-----------------------------------------------------------------------------
|
|
639
|
-
// dpiObject_getElementExistsByIndex() [PUBLIC]
|
|
640
|
-
// Return boolean indicating if an element exists in the collection at the
|
|
641
|
-
// specified index.
|
|
642
|
-
//-----------------------------------------------------------------------------
|
|
643
|
-
int dpiObject_getElementExistsByIndex(dpiObject *obj, int32_t index,
|
|
644
|
-
int *exists)
|
|
645
|
-
{
|
|
646
|
-
dpiError error;
|
|
647
|
-
int status;
|
|
648
|
-
|
|
649
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
650
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
651
|
-
DPI_CHECK_PTR_NOT_NULL(obj, exists)
|
|
652
|
-
status = dpiOci__tableExists(obj, index, exists, &error);
|
|
653
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
654
|
-
}
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
//-----------------------------------------------------------------------------
|
|
658
|
-
// dpiObject_getElementValueByIndex() [PUBLIC]
|
|
659
|
-
// Return the element at the given index in the collection.
|
|
660
|
-
//-----------------------------------------------------------------------------
|
|
661
|
-
int dpiObject_getElementValueByIndex(dpiObject *obj, int32_t index,
|
|
662
|
-
dpiNativeTypeNum nativeTypeNum, dpiData *data)
|
|
663
|
-
{
|
|
664
|
-
dpiOracleData value;
|
|
665
|
-
int exists, status;
|
|
666
|
-
void *indicator;
|
|
667
|
-
dpiError error;
|
|
668
|
-
|
|
669
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
670
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
671
|
-
DPI_CHECK_PTR_NOT_NULL(obj, data)
|
|
672
|
-
if (dpiOci__collGetElem(obj->type->conn, obj->instance, index, &exists,
|
|
673
|
-
&value.asRaw, &indicator, &error) < 0)
|
|
674
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
675
|
-
if (!exists) {
|
|
676
|
-
dpiError__set(&error, "get element value", DPI_ERR_INVALID_INDEX,
|
|
677
|
-
index);
|
|
678
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
679
|
-
}
|
|
680
|
-
status = dpiObject__fromOracleValue(obj, &error,
|
|
681
|
-
&obj->type->elementTypeInfo, &value, (int16_t*) indicator,
|
|
682
|
-
nativeTypeNum, data);
|
|
683
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
684
|
-
}
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
//-----------------------------------------------------------------------------
|
|
688
|
-
// dpiObject_getFirstIndex() [PUBLIC]
|
|
689
|
-
// Return the index of the first entry in the collection.
|
|
690
|
-
//-----------------------------------------------------------------------------
|
|
691
|
-
int dpiObject_getFirstIndex(dpiObject *obj, int32_t *index, int *exists)
|
|
692
|
-
{
|
|
693
|
-
dpiError error;
|
|
694
|
-
int32_t size;
|
|
695
|
-
int status;
|
|
696
|
-
|
|
697
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
698
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
699
|
-
DPI_CHECK_PTR_NOT_NULL(obj, index)
|
|
700
|
-
DPI_CHECK_PTR_NOT_NULL(obj, exists)
|
|
701
|
-
if (dpiOci__tableSize(obj, &size, &error) < 0)
|
|
702
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
703
|
-
*exists = (size != 0);
|
|
704
|
-
if (*exists)
|
|
705
|
-
status = dpiOci__tableFirst(obj, index, &error);
|
|
706
|
-
else status = DPI_SUCCESS;
|
|
707
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
//-----------------------------------------------------------------------------
|
|
712
|
-
// dpiObject_getLastIndex() [PUBLIC]
|
|
713
|
-
// Return the index of the last entry in the collection.
|
|
714
|
-
//-----------------------------------------------------------------------------
|
|
715
|
-
int dpiObject_getLastIndex(dpiObject *obj, int32_t *index, int *exists)
|
|
716
|
-
{
|
|
717
|
-
dpiError error;
|
|
718
|
-
int32_t size;
|
|
719
|
-
int status;
|
|
720
|
-
|
|
721
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
722
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
723
|
-
DPI_CHECK_PTR_NOT_NULL(obj, index)
|
|
724
|
-
DPI_CHECK_PTR_NOT_NULL(obj, exists)
|
|
725
|
-
if (dpiOci__tableSize(obj, &size, &error) < 0)
|
|
726
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
727
|
-
*exists = (size != 0);
|
|
728
|
-
if (*exists)
|
|
729
|
-
status = dpiOci__tableLast(obj, index, &error);
|
|
730
|
-
else status = DPI_SUCCESS;
|
|
731
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
//-----------------------------------------------------------------------------
|
|
736
|
-
// dpiObject_getNextIndex() [PUBLIC]
|
|
737
|
-
// Return the index of the next entry in the collection following the index
|
|
738
|
-
// specified. If there is no next entry, exists is set to 0.
|
|
739
|
-
//-----------------------------------------------------------------------------
|
|
740
|
-
int dpiObject_getNextIndex(dpiObject *obj, int32_t index, int32_t *nextIndex,
|
|
741
|
-
int *exists)
|
|
742
|
-
{
|
|
743
|
-
dpiError error;
|
|
744
|
-
int status;
|
|
745
|
-
|
|
746
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
747
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
748
|
-
DPI_CHECK_PTR_NOT_NULL(obj, nextIndex)
|
|
749
|
-
DPI_CHECK_PTR_NOT_NULL(obj, exists)
|
|
750
|
-
status = dpiOci__tableNext(obj, index, nextIndex, exists, &error);
|
|
751
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
//-----------------------------------------------------------------------------
|
|
756
|
-
// dpiObject_getPrevIndex() [PUBLIC]
|
|
757
|
-
// Return the index of the previous entry in the collection preceding the
|
|
758
|
-
// index specified. If there is no previous entry, exists is set to 0.
|
|
759
|
-
//-----------------------------------------------------------------------------
|
|
760
|
-
int dpiObject_getPrevIndex(dpiObject *obj, int32_t index, int32_t *prevIndex,
|
|
761
|
-
int *exists)
|
|
762
|
-
{
|
|
763
|
-
dpiError error;
|
|
764
|
-
int status;
|
|
765
|
-
|
|
766
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
767
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
768
|
-
DPI_CHECK_PTR_NOT_NULL(obj, prevIndex)
|
|
769
|
-
DPI_CHECK_PTR_NOT_NULL(obj, exists)
|
|
770
|
-
status = dpiOci__tablePrev(obj, index, prevIndex, exists, &error);
|
|
771
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
772
|
-
}
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
//-----------------------------------------------------------------------------
|
|
776
|
-
// dpiObject_getSize() [PUBLIC]
|
|
777
|
-
// Return the size of the collection.
|
|
778
|
-
//-----------------------------------------------------------------------------
|
|
779
|
-
int dpiObject_getSize(dpiObject *obj, int32_t *size)
|
|
780
|
-
{
|
|
781
|
-
dpiError error;
|
|
782
|
-
int status;
|
|
783
|
-
|
|
784
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
785
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
786
|
-
DPI_CHECK_PTR_NOT_NULL(obj, size)
|
|
787
|
-
status = dpiOci__collSize(obj->type->conn, obj->instance, size, &error);
|
|
788
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
789
|
-
}
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
//-----------------------------------------------------------------------------
|
|
793
|
-
// dpiObject_release() [PUBLIC]
|
|
794
|
-
// Release a reference to the object.
|
|
795
|
-
//-----------------------------------------------------------------------------
|
|
796
|
-
int dpiObject_release(dpiObject *obj)
|
|
797
|
-
{
|
|
798
|
-
return dpiGen__release(obj, DPI_HTYPE_OBJECT, __func__);
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
//-----------------------------------------------------------------------------
|
|
803
|
-
// dpiObject_setAttributeValue() [PUBLIC]
|
|
804
|
-
// Create a copy of the object and return it. Return NULL upon error.
|
|
805
|
-
//-----------------------------------------------------------------------------
|
|
806
|
-
int dpiObject_setAttributeValue(dpiObject *obj, dpiObjectAttr *attr,
|
|
807
|
-
dpiNativeTypeNum nativeTypeNum, dpiData *data)
|
|
808
|
-
{
|
|
809
|
-
void *valueIndicator, *ociValue;
|
|
810
|
-
dpiOracleDataBuffer valueBuffer;
|
|
811
|
-
int16_t scalarValueIndicator;
|
|
812
|
-
dpiError error;
|
|
813
|
-
int status;
|
|
814
|
-
|
|
815
|
-
// validate parameters
|
|
816
|
-
if (dpiObject__check(obj, __func__, &error) < 0)
|
|
817
|
-
return DPI_FAILURE;
|
|
818
|
-
DPI_CHECK_PTR_NOT_NULL(obj, data)
|
|
819
|
-
if (dpiGen__checkHandle(attr, DPI_HTYPE_OBJECT_ATTR, "set attribute value",
|
|
820
|
-
&error) < 0)
|
|
821
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
822
|
-
if (attr->belongsToType->tdo != obj->type->tdo) {
|
|
823
|
-
dpiError__set(&error, "set attribute value", DPI_ERR_WRONG_ATTR,
|
|
824
|
-
attr->nameLength, attr->name, obj->type->schemaLength,
|
|
825
|
-
obj->type->schema, obj->type->nameLength, obj->type->name);
|
|
826
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
827
|
-
}
|
|
828
|
-
|
|
829
|
-
// check to see if type is supported
|
|
830
|
-
if (!attr->typeInfo.oracleTypeNum) {
|
|
831
|
-
dpiError__set(&error, "get attribute value",
|
|
832
|
-
DPI_ERR_UNHANDLED_DATA_TYPE, attr->typeInfo.ociTypeCode);
|
|
833
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
834
|
-
}
|
|
835
|
-
|
|
836
|
-
// convert to input data format
|
|
837
|
-
if (dpiObject__toOracleValue(obj, &error, &attr->typeInfo, &valueBuffer,
|
|
838
|
-
&ociValue, &scalarValueIndicator, &valueIndicator, nativeTypeNum,
|
|
839
|
-
data) < 0)
|
|
840
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
841
|
-
|
|
842
|
-
// set attribute value
|
|
843
|
-
status = dpiOci__objectSetAttr(obj, attr, scalarValueIndicator,
|
|
844
|
-
valueIndicator, ociValue, &error);
|
|
845
|
-
dpiObject__clearOracleValue(obj, &error, &valueBuffer,
|
|
846
|
-
attr->typeInfo.oracleTypeNum);
|
|
847
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
848
|
-
}
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
//-----------------------------------------------------------------------------
|
|
852
|
-
// dpiObject_setElementValueByIndex() [PUBLIC]
|
|
853
|
-
// Set the element at the specified index to the given value.
|
|
854
|
-
//-----------------------------------------------------------------------------
|
|
855
|
-
int dpiObject_setElementValueByIndex(dpiObject *obj, int32_t index,
|
|
856
|
-
dpiNativeTypeNum nativeTypeNum, dpiData *data)
|
|
857
|
-
{
|
|
858
|
-
dpiOracleDataBuffer valueBuffer;
|
|
859
|
-
int16_t scalarValueIndicator;
|
|
860
|
-
void *indicator;
|
|
861
|
-
dpiError error;
|
|
862
|
-
void *ociValue;
|
|
863
|
-
int status;
|
|
864
|
-
|
|
865
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
866
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
867
|
-
DPI_CHECK_PTR_NOT_NULL(obj, data)
|
|
868
|
-
if (dpiObject__toOracleValue(obj, &error, &obj->type->elementTypeInfo,
|
|
869
|
-
&valueBuffer, &ociValue, &scalarValueIndicator,
|
|
870
|
-
(void**) &indicator, nativeTypeNum, data) < 0)
|
|
871
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
872
|
-
if (!indicator)
|
|
873
|
-
indicator = &scalarValueIndicator;
|
|
874
|
-
status = dpiOci__collAssignElem(obj->type->conn, index, ociValue,
|
|
875
|
-
indicator, obj->instance, &error);
|
|
876
|
-
dpiObject__clearOracleValue(obj, &error, &valueBuffer,
|
|
877
|
-
obj->type->elementTypeInfo.oracleTypeNum);
|
|
878
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
879
|
-
}
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
//-----------------------------------------------------------------------------
|
|
883
|
-
// dpiObject_trim() [PUBLIC]
|
|
884
|
-
// Trim a number of elements from the end of the collection.
|
|
885
|
-
//-----------------------------------------------------------------------------
|
|
886
|
-
int dpiObject_trim(dpiObject *obj, uint32_t numToTrim)
|
|
887
|
-
{
|
|
888
|
-
dpiError error;
|
|
889
|
-
int status;
|
|
890
|
-
|
|
891
|
-
if (dpiObject__checkIsCollection(obj, __func__, &error) < 0)
|
|
892
|
-
return dpiGen__endPublicFn(obj, DPI_FAILURE, &error);
|
|
893
|
-
status = dpiOci__collTrim(obj->type->conn, numToTrim, obj->instance,
|
|
894
|
-
&error);
|
|
895
|
-
return dpiGen__endPublicFn(obj, status, &error);
|
|
896
|
-
}
|
|
897
|
-
|