Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
.. _dpiObjectFunctions:

ODPI-C Object Functions
-----------------------

Object handles are used to represent instances of the types created by the SQL
command CREATE OR REPLACE TYPE. They are created by calling the function
:func:`dpiObjectType_createObject()` or calling the function
:func:`dpiObject_copy()` or implicitly by creating a variable of the type
DPI_ORACLE_TYPE_OBJECT. The are destroyed when the last reference is released
by calling the function :func:`dpiObject_release()`.

.. function:: int dpiObject_addRef(dpiObject* obj)

    Adds a reference to the object. This is intended for situations where a
    reference to the object needs to be maintained independently of the
    reference returned when the object was created.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object to which a reference is to be added. If the reference
            is NULL or invalid, an error is returned.

.. function:: int dpiObject_appendElement(dpiObject* obj, \
        dpiNativeTypeNum nativeTypeNum, dpiData* value)

    Appends an element with the specified value to the collection.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object to which the value is to be appended. If the reference
            is NULL or invalid, an error is returned. Likewise, if the object
            does not refer to a collection an error is returned.
        * - ``nativeTypeNum``
          - IN
          - The native type of the data that is to be appended. It should be
            one of the values from the enumeration
            :ref:`dpiNativeTypeNum<dpiNativeTypeNum>`.
        * - ``value``
          - IN
          - A pointer to a :ref:`dpiData<dpiData>` structure which contains
            the value of the element to append to the collection.

.. function:: int dpiObject_copy(dpiObject* obj, dpiObject** copiedObj)

    Creates an independent copy of an object and returns a reference to the
    newly created object. This reference should be released as soon as it is
    no longer needed.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object which is to be copied. If the reference is NULL or
            invalid an error is returned.
        * - ``copiedObj``
          - OUT
          - A pointer to a reference to the object which is created as a copy
            of the first object, which is populated upon successful completion
            of this function.

.. function:: int dpiObject_deleteElementByIndex(dpiObject* obj, \
        int32_t index)

    Deletes an element from the collection. Note that the position ordinals of
    the remaining elements are not changed. The delete operation creates
    *holes* in the collection.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which the element is to be deleted. If the
            reference is NULL or invalid, an error is returned. Likewise,
            if the object does not refer to a collection, an error is
            returned.
        * - ``index``
          - IN
          - The index of the element that is to be deleted. If no element
            exists at that index an error is returned.

.. function:: int dpiObject_getAttributeValue(dpiObject* obj, \
        dpiObjectAttr* attr, dpiNativeTypeNum nativeTypeNum, dpiData* value)

    Returns the value of one of the object's attributes.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which the the attribute is to be retrieved. If the
            reference is NULL or invalid, an error is returned.
        * - ``attr``
          - IN
          - The attribute which is to be retrieved. The attribute must belong
            to the same type as the object; otherwise, an error is returned.
        * - ``nativeTypeNum``
          - IN
          - The native type of the data that is to be retrieved. It should be
            one of the values from the enumeration
            :ref:`dpiNativeTypeNum<dpiNativeTypeNum>`.
        * - ``nativeTypeNum``
          - IN
          - The native type of the data that is to be retrieved. It should be
            one of the values from the enumeration
            :ref:`dpiNativeTypeNum<dpiNativeTypeNum>`.
        * - ``value``
          - IN/OUT
          - A pointer to a :ref:`dpiData<dpiData>` structure which will
            be populated with the value of the element when this function
            completes successfully. If the native type is
            ``DPI_NATIVE_TYPE_BYTES`` and the Oracle type of the attribute is
            ``DPI_ORACLE_TYPE_NUMBER``, a buffer must be supplied in the
            value.asBytes.ptr attribute and the maximum length of that buffer
            must be supplied in the value.asBytes.length attribute before
            calling this function. For all other conversions, the buffer is
            supplied by the library and remains valid as long as a reference
            to the object is held. Note that if the native type is
            ``DPI_NATIVE_TYPE_OBJECT`` the reference that is returned must be
            released by a call to :func:`dpiObject_release()`.

.. function:: int dpiObject_getElementExistsByIndex(dpiObject* obj, \
        int32_t index, int* exists)

    Returns whether an element exists at the specified index.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object for which an element's existence is to be tested. If
            the reference is NULL or invalid, an error is returned. Likewise,
            if the object does not refer to a collection, an error is
            returned.
        * - ``index``
          - IN
          - The index into the collection that is to be checked.
        * - ``exists``
          - OUT
          - A pointer to a boolean value indicating if an element exists at
            the specified index (1) or not (0), which will be populated when
            this function completes successfully.

.. function:: int dpiObject_getElementValueByIndex(dpiObject* obj, \
        int32_t index, dpiNativeTypeNum nativeTypeNum, dpiData* value)

    Returns the value of the element found at the specified index.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which the element is to be retrieved. If the
            reference is NULL or invalid, an error is returned. Likewise, if
            the object does not refer to a collection, an error is returned.
        * - ``index``
          - IN
          - The index into the collection from which the element is to be
            retrieved. If no element exists at that index, an error is
            returned.
        * - ``nativeTypeNum``
          - IN
          - The native type of the data that is to be retrieved. It should be
            one of the values from the enumeration
            :ref:`dpiNativeTypeNum<dpiNativeTypeNum>`.
        * - ``value``
          - IN/OUT
          - A pointer to a :ref:`dpiData<dpiData>` structure which will be
            populated with the value of the element when this function
            completes successfully. If the native type is
            ``DPI_NATIVE_TYPE_BYTES`` and the Oracle type of the attribute is
            ``DPI_ORACLE_TYPE_NUMBER``, a buffer must be supplied in the
            value.asBytes.ptr attribute and the maximum length of that buffer
            must be supplied in the value.asBytes.length attribute before
            calling this function. For all other conversions, the buffer is
            supplied by the library and remains valid as long as a reference
            to the object is held. Note that if the native type is
            ``DPI_NATIVE_TYPE_OBJECT`` the reference that is returned must be
            released by a call to :func:`dpiObject_release()`.

.. function:: int dpiObject_getFirstIndex(dpiObject* obj, int32_t* index, \
        int* exists)

    Returns the first index used in a collection.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which the first index is to be retrieved. If the
            reference is NULL or invalid, an error is returned. Likewise, if
            the object does not refer to a collection, an error is returned.
        * - ``index``
          - OUT
          - A pointer to the first index used in the collection, which will be
            populated when the function completes successfully.
        * - ``exists``
          - OUT
          - A pointer to a boolean value specifying whether a first index
            exists (1) or not (0), which will be populated when the function
            completes successfully.

.. function:: int dpiObject_getLastIndex(dpiObject* obj, int32_t* index, \
        int* exists)

    Returns the last index used in a collection.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which the last index is to be retrieved. If the
            reference is NULL or invalid, an error is returned. Likewise, if
            the object does not refer to a collection, an error is returned.
        * - ``index``
          - OUT
          - A pointer to the last index used in the collection, which will be
            populated when the function completes successfully.
        * - ``exists``
          - OUT
          - A pointer to a boolean value specifying whether a last index
            exists (1) or not (0), which will be populated when the function
            completes successfully.

.. function:: int dpiObject_getNextIndex(dpiObject* obj, int32_t index, \
        int32_t* nextIndex, int* exists)

    Returns the next index used in a collection following the specified index.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which the next index is to be retrieved. If the
            reference is NULL or invalid, an error is returned. Likewise, if
            the object does not refer to a collection, an error is returned.
        * - ``index``
          - IN
          - The index after which the next index is to be determined. This
            does not have to be an actual index in the collection.
        * - ``nextIndex``
          - OUT
          - A pointer to the next index used in the collection, which will be
            populated when the function completes successfully and the value
            of the exists parameter is 1.
        * - ``exists``
          - OUT
          - A pointer to a boolean value specifying whether a next index
            exists following the specified index (1) or not (0), which will be
            populated when the function completes successfully.

.. function:: int dpiObject_getPrevIndex(dpiObject* obj, int32_t index, \
        int32_t* prevIndex, int* exists)

    Returns the previous index used in a collection preceding the specified
    index.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which the previous index is to be retrieved. If the
            reference is NULL or invalid, an error is returned. Likewise, if
            the object does not refer to a collection, an error is returned.
        * - ``index``
          - IN
          - The index before which the previous index is to be determined.
            This does not have to be an actual index in the collection.
        * - ``prevIndex``
          - OUT
          - A pointer to the previous index used in the collection, which will
            be populated when the function completes successfully and the value
            of the exists parameter is 1.
        * - ``exists``
          - OUT
          - A pointer to a boolean value specifying whether a previous index
            exists preceding the specified index (1) or not (0), which will be
            populated when the function completes successfully.

.. function:: int dpiObject_getSize(dpiObject* obj, int32_t* size)

    Returns the number of elements in a collection.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which the number of elements is to be retrieved.
            If the reference is NULL or invalid, an error is returned.
            Likewise, if the object does not refer to a collection, an error
            is returned.
        * - ``size``
          - OUT
          - A pointer to the number of elements in the collection, which will
            be populated when the function completes successfully.

.. function:: int dpiObject_release(dpiObject* obj)

    Releases a reference to the object. A count of the references to the object
    is maintained and when this count reaches zero, the memory associated with
    the object is freed.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which a reference is to be released. If the
            reference is NULL or invalid, an error is returned.

.. function:: int dpiObject_setAttributeValue(dpiObject* obj, \
        dpiObjectAttr* attr, dpiNativeTypeNum nativeTypeNum, dpiData* value)

    Sets the value of one of the object's attributes.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object on which the attribute is to be set. If the reference
            is NULL or invalid, an error is returned.
        * - ``attr``
          - IN
          - The attribute which is to be set. The attribute must belong to the
            same type as the object; otherwise, an error is returned.
        * - ``nativeTypeNum``
          - IN
          - The native type of the data that is to be set. It should be one of
            the values from the enumeration
            :ref:`dpiNativeTypeNum<dpiNativeTypeNum>`.
        * - ``value``
          - IN
          - A pointer to a :ref:`dpiData<dpiData>` structure which contains
            the value to which the attribute is to be set.

.. function:: int dpiObject_setElementValueByIndex(dpiObject* obj, \
        int32_t index, dpiNativeTypeNum nativeTypeNum, dpiData* value)

    Sets the value of the element found at the specified index.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object in which the element is to be set. If the reference is
            NULL or invalid, an error is returned. Likewise, if the object
            does not refer to a collection, an error is returned.
        * - ``index``
          - IN
          - The index into the collection at which the element is to be set.
        * - ``nativeTypeNum``
          - IN
          - The native type of the data that is to be set. It should be one of
            the values from the enumeration
            :ref:`dpiNativeTypeNum<dpiNativeTypeNum>`.
        * - ``value``
          - IN
          - A pointer to a :ref:`dpiData<dpiData>` structure which contains the
            value of the element to place at the specified index.

.. function:: int dpiObject_trim(dpiObject* obj, uint32_t numToTrim)

    Trims a number of elements from the end of a collection.

    The function returns DPI_SUCCESS for success and DPI_FAILURE for failure.

    .. parameters-table::

        * - ``obj``
          - IN
          - The object from which a number of elements are to be trimmed. If
            the reference is NULL or invalid, an error is returned. Likewise,
            if the object does not refer to a collection, an error is
            returned.
        * - ``numToTrim``
          - IN
          - The number of elements to trim from the end of the collection. If
            the number of of elements to trim exceeds the current size of the
            collection an error is returned.