odpic-sys 0.2.0

Bindings to Oracle Database Programming Interface for C (ODPI-C).
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
//-----------------------------------------------------------------------------
// Copyright (c) 2016, 2024, Oracle and/or its affiliates.
//
// This software is dual-licensed to you under the Universal Permissive License
// (UPL) 1.0 as shown at https://oss.oracle.com/licenses/upl and Apache License
// 2.0 as shown at http://www.apache.org/licenses/LICENSE-2.0. You may choose
// either license.
//
// If you elect to accept the software under the Apache License, Version 2.0,
// the following applies:
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//    https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//-----------------------------------------------------------------------------

//-----------------------------------------------------------------------------
// dpiOracleType.c
//   Implementation of variable types.
//-----------------------------------------------------------------------------

#include "dpiImpl.h"

//-----------------------------------------------------------------------------
// definition of Oracle types (MUST be in same order as enumeration)
//-----------------------------------------------------------------------------
static const dpiOracleType
        dpiAllOracleTypes[DPI_ORACLE_TYPE_MAX - DPI_ORACLE_TYPE_NONE - 1] = {
    {
        DPI_ORACLE_TYPE_VARCHAR,            // public Oracle type
        DPI_NATIVE_TYPE_BYTES,              // default native type
        DPI_SQLT_CHR,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        0,                                  // buffer size
        1,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_NVARCHAR,           // public Oracle type
        DPI_NATIVE_TYPE_BYTES,              // default native type
        DPI_SQLT_CHR,                       // internal Oracle type
        DPI_SQLCS_NCHAR,                    // charset form
        0,                                  // buffer size
        1,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_CHAR,               // public Oracle type
        DPI_NATIVE_TYPE_BYTES,              // default native type
        DPI_SQLT_AFC,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        0,                                  // buffer size
        1,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_NCHAR,              // public Oracle type
        DPI_NATIVE_TYPE_BYTES,              // default native type
        DPI_SQLT_AFC,                       // internal Oracle type
        DPI_SQLCS_NCHAR,                    // charset form
        0,                                  // buffer size
        1,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_ROWID,              // public Oracle type
        DPI_NATIVE_TYPE_ROWID,              // default native type
        DPI_SQLT_RDD,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        1,                                  // is character data
        1,                                  // can be in array
        1                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_RAW,                // public Oracle type
        DPI_NATIVE_TYPE_BYTES,              // default native type
        DPI_SQLT_BIN,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        0,                                  // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_NATIVE_FLOAT,       // public Oracle type
        DPI_NATIVE_TYPE_FLOAT,              // default native type
        DPI_SQLT_BFLOAT,                    // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(float),                      // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_NATIVE_DOUBLE,      // public Oracle type
        DPI_NATIVE_TYPE_DOUBLE,             // default native type
        DPI_SQLT_BDOUBLE,                   // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(double),                     // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_NATIVE_INT,         // public Oracle type
        DPI_NATIVE_TYPE_INT64,              // default native type
        DPI_SQLT_INT,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(int64_t),                    // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_NUMBER,             // public Oracle type
        DPI_NATIVE_TYPE_DOUBLE,             // default native type
        DPI_SQLT_VNU,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        DPI_OCI_NUMBER_SIZE,                // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_DATE,               // public Oracle type
        DPI_NATIVE_TYPE_TIMESTAMP,          // default native type
        DPI_SQLT_ODT,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(dpiOciDate),                 // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_TIMESTAMP,          // public Oracle type
        DPI_NATIVE_TYPE_TIMESTAMP,          // default native type
        DPI_SQLT_TIMESTAMP,                 // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_TIMESTAMP_TZ,       // public Oracle type
        DPI_NATIVE_TYPE_TIMESTAMP,          // default native type
        DPI_SQLT_TIMESTAMP_TZ,              // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_TIMESTAMP_LTZ,      // public Oracle type
        DPI_NATIVE_TYPE_TIMESTAMP,          // default native type
        DPI_SQLT_TIMESTAMP_LTZ,             // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_INTERVAL_DS,        // public Oracle type
        DPI_NATIVE_TYPE_INTERVAL_DS,        // default native type
        DPI_SQLT_INTERVAL_DS,               // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_INTERVAL_YM,        // public Oracle type
        DPI_NATIVE_TYPE_INTERVAL_YM,        // default native type
        DPI_SQLT_INTERVAL_YM,               // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_CLOB,               // public Oracle type
        DPI_NATIVE_TYPE_LOB,                // default native type
        DPI_SQLT_CLOB,                      // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        1,                                  // is character data
        0,                                  // can be in array
        1                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_NCLOB,              // public Oracle type
        DPI_NATIVE_TYPE_LOB,                // default native type
        DPI_SQLT_CLOB,                      // internal Oracle type
        DPI_SQLCS_NCHAR,                    // charset form
        sizeof(void*),                      // buffer size
        1,                                  // is character data
        0,                                  // can be in array
        1                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_BLOB,               // public Oracle type
        DPI_NATIVE_TYPE_LOB,                // default native type
        DPI_SQLT_BLOB,                      // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        1                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_BFILE,              // public Oracle type
        DPI_NATIVE_TYPE_LOB,                // default native type
        DPI_SQLT_BFILE,                     // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        1                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_STMT,               // public Oracle type
        DPI_NATIVE_TYPE_STMT,               // default native type
        DPI_SQLT_RSET,                      // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        1                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_BOOLEAN,            // public Oracle type
        DPI_NATIVE_TYPE_BOOLEAN,            // default native type
        DPI_SQLT_BOL,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(int),                        // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_OBJECT,             // public Oracle type
        DPI_NATIVE_TYPE_OBJECT,             // default native type
        DPI_SQLT_NTY,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        1                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_LONG_VARCHAR,       // public Oracle type
        DPI_NATIVE_TYPE_BYTES,              // default native type
        DPI_SQLT_CHR,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        DPI_MAX_BASIC_BUFFER_SIZE + 1,      // buffer size
        1,                                  // is character data
        0,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_LONG_RAW,           // public Oracle type
        DPI_NATIVE_TYPE_BYTES,              // default native type
        DPI_SQLT_BIN,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        DPI_MAX_BASIC_BUFFER_SIZE + 1,      // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_NATIVE_UINT,        // public Oracle type
        DPI_NATIVE_TYPE_UINT64,             // default native type
        DPI_SQLT_UIN,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(uint64_t),                   // buffer size
        0,                                  // is character data
        1,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_JSON,               // public Oracle type
        DPI_NATIVE_TYPE_JSON,               // default native type
        DPI_SQLT_JSON,                      // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        1                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_JSON_OBJECT,        // public Oracle type
        DPI_NATIVE_TYPE_JSON_OBJECT,        // default native type
        0,                                  // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(dpiJsonObject),              // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_JSON_ARRAY,         // public Oracle type
        DPI_NATIVE_TYPE_JSON_ARRAY,         // default native type
        0,                                  // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(dpiJsonArray),               // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_UROWID,             // public Oracle type
        DPI_NATIVE_TYPE_ROWID,              // default native type
        DPI_SQLT_RDD,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        1,                                  // is character data
        1,                                  // can be in array
        1                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_LONG_NVARCHAR,      // public Oracle type
        DPI_NATIVE_TYPE_BYTES,              // default native type
        DPI_SQLT_CHR,                       // internal Oracle type
        DPI_SQLCS_NCHAR,                    // charset form
        DPI_MAX_BASIC_BUFFER_SIZE + 1,      // buffer size
        1,                                  // is character data
        0,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_XMLTYPE,            // public Oracle type
        DPI_NATIVE_TYPE_BYTES,              // default native type
        DPI_SQLT_CHR,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        DPI_MAX_BASIC_BUFFER_SIZE + 1,      // buffer size
        1,                                  // is character data
        0,                                  // can be in array
        0                                   // requires pre-fetch
    },
    {
        DPI_ORACLE_TYPE_VECTOR,             // public Oracle type
        DPI_NATIVE_TYPE_VECTOR,             // default native type
        DPI_SQLT_VEC,                       // internal Oracle type
        DPI_SQLCS_IMPLICIT,                 // charset form
        sizeof(void*),                      // buffer size
        0,                                  // is character data
        0,                                  // can be in array
        1                                   // requires pre-fetch
    },
};


//-----------------------------------------------------------------------------
// dpiOracleType__convertFromOracle() [INTERNAL]
//   Return a value from the dpiOracleTypeNum enumeration for the OCI data type
// and charset form. If the OCI data type is not supported, 0 is returned.
//-----------------------------------------------------------------------------
static dpiOracleTypeNum dpiOracleType__convertFromOracle(uint16_t typeCode,
        uint8_t charsetForm)
{
    switch(typeCode) {
        case DPI_SQLT_CHR:
        case DPI_SQLT_VCS:
            if (charsetForm == DPI_SQLCS_NCHAR)
                return DPI_ORACLE_TYPE_NVARCHAR;
            return DPI_ORACLE_TYPE_VARCHAR;
        case DPI_SQLT_INT:
        case DPI_SQLT_FLT:
        case DPI_SQLT_NUM:
        case DPI_SQLT_PDN:
        case DPI_SQLT_VNU:
        case DPI_SQLT_BFLOAT:
        case DPI_SQLT_BDOUBLE:
        case DPI_OCI_TYPECODE_SMALLINT:
            return DPI_ORACLE_TYPE_NUMBER;
        case DPI_SQLT_DAT:
        case DPI_SQLT_ODT:
            return DPI_ORACLE_TYPE_DATE;
        case DPI_SQLT_BIN:
        case DPI_SQLT_LVB:
            return DPI_ORACLE_TYPE_RAW;
        case DPI_SQLT_AFC:
            if (charsetForm == DPI_SQLCS_NCHAR)
                return DPI_ORACLE_TYPE_NCHAR;
            return DPI_ORACLE_TYPE_CHAR;
        case DPI_OCI_TYPECODE_BINARY_INTEGER:
        case DPI_OCI_TYPECODE_PLS_INTEGER:
            return DPI_ORACLE_TYPE_NATIVE_INT;
        case DPI_SQLT_IBFLOAT:
            return DPI_ORACLE_TYPE_NATIVE_FLOAT;
        case DPI_SQLT_IBDOUBLE:
            return DPI_ORACLE_TYPE_NATIVE_DOUBLE;
        case DPI_SQLT_DATE:
        case DPI_SQLT_TIMESTAMP:
            return DPI_ORACLE_TYPE_TIMESTAMP;
        case DPI_SQLT_TIMESTAMP_TZ:
            return DPI_ORACLE_TYPE_TIMESTAMP_TZ;
        case DPI_SQLT_TIMESTAMP_LTZ:
            return DPI_ORACLE_TYPE_TIMESTAMP_LTZ;
        case DPI_SQLT_NTY:
        case DPI_SQLT_REC:
        case DPI_SQLT_NCO:
            return DPI_ORACLE_TYPE_OBJECT;
        case DPI_SQLT_BOL:
            return DPI_ORACLE_TYPE_BOOLEAN;
        case DPI_SQLT_CLOB:
            if (charsetForm == DPI_SQLCS_NCHAR)
                return DPI_ORACLE_TYPE_NCLOB;
            return DPI_ORACLE_TYPE_CLOB;
        case DPI_SQLT_BLOB:
            return DPI_ORACLE_TYPE_BLOB;
        case DPI_SQLT_BFILE:
            return DPI_ORACLE_TYPE_BFILE;
        case DPI_SQLT_RDD:
        case DPI_OCI_TYPECODE_ROWID:
            return DPI_ORACLE_TYPE_ROWID;
        case DPI_SQLT_RSET:
            return DPI_ORACLE_TYPE_STMT;
        case DPI_SQLT_INTERVAL_DS:
            return DPI_ORACLE_TYPE_INTERVAL_DS;
        case DPI_SQLT_INTERVAL_YM:
            return DPI_ORACLE_TYPE_INTERVAL_YM;
        case DPI_SQLT_LNG:
        case DPI_OCI_TYPECODE_LONG:
            return DPI_ORACLE_TYPE_LONG_VARCHAR;
        case DPI_SQLT_LBI:
        case DPI_OCI_TYPECODE_LONG_RAW:
            return DPI_ORACLE_TYPE_LONG_RAW;
        case DPI_SQLT_JSON:
            return DPI_ORACLE_TYPE_JSON;
        case DPI_SQLT_VEC:
            return DPI_ORACLE_TYPE_VECTOR;
    }
    return (dpiOracleTypeNum) 0;
}


//-----------------------------------------------------------------------------
// dpiOracleType__getFromNum() [INTERNAL]
//   Return the type associated with the type number.
//-----------------------------------------------------------------------------
const dpiOracleType *dpiOracleType__getFromNum(dpiOracleTypeNum typeNum,
        dpiError *error)
{
    if (typeNum > DPI_ORACLE_TYPE_NONE && typeNum < DPI_ORACLE_TYPE_MAX)
        return &dpiAllOracleTypes[typeNum - DPI_ORACLE_TYPE_NONE - 1];
    dpiError__set(error, "check type", DPI_ERR_INVALID_ORACLE_TYPE, typeNum);
    return NULL;
}


//-----------------------------------------------------------------------------
// dpiOracleType__populateTypeInfo() [INTERNAL]
//   Populate dpiDataTypeInfo structure given an Oracle descriptor. Note that
// no error is raised by this function if the data type is not supported. This
// method is called for both implicit and explicit describes (which behave
// slightly differently).
//-----------------------------------------------------------------------------
int dpiOracleType__populateTypeInfo(dpiConn *conn, void *handle,
        uint32_t handleType, dpiDataTypeInfo *info, dpiError *error)
{
    const dpiOracleType *oracleType = NULL;
    uint8_t charsetForm, isJson, isOson;
    dpiNativeTypeNum nativeTypeNum;
    uint32_t dataTypeAttribute, i;
    void *listParam, *itemParam;
    dpiAnnotation *annotation;
    uint16_t ociSize;

    // acquire data type
    if (handleType == DPI_OCI_DTYPE_PARAM)
        dataTypeAttribute = DPI_OCI_ATTR_TYPECODE;
    else dataTypeAttribute = DPI_OCI_ATTR_DATA_TYPE;
    if (dpiOci__attrGet(handle, handleType, (void*) &info->ociTypeCode, 0,
            dataTypeAttribute, "get data type", error) < 0)
        return DPI_FAILURE;

    // acquire character set form
    if (info->ociTypeCode != DPI_SQLT_CHR &&
            info->ociTypeCode != DPI_SQLT_AFC &&
            info->ociTypeCode != DPI_SQLT_VCS &&
            info->ociTypeCode != DPI_SQLT_CLOB)
        charsetForm = DPI_SQLCS_IMPLICIT;
    else if (dpiOci__attrGet(handle, handleType, (void*) &charsetForm, 0,
            DPI_OCI_ATTR_CHARSET_FORM, "get charset form", error) < 0)
        return DPI_FAILURE;

    // convert Oracle type to ODPI-C enumerations, if possible
    info->oracleTypeNum = dpiOracleType__convertFromOracle(info->ociTypeCode,
            charsetForm);
    if (!info->oracleTypeNum)
        info->defaultNativeTypeNum = (dpiNativeTypeNum) 0;
    else {
        oracleType = dpiOracleType__getFromNum(info->oracleTypeNum, error);
        if (!oracleType)
            return DPI_FAILURE;
        info->defaultNativeTypeNum = oracleType->defaultNativeTypeNum;
    }

    // determine precision/scale
    nativeTypeNum = info->defaultNativeTypeNum;
    switch (nativeTypeNum) {
        case DPI_NATIVE_TYPE_DOUBLE:
        case DPI_NATIVE_TYPE_FLOAT:
        case DPI_NATIVE_TYPE_INT64:
        case DPI_NATIVE_TYPE_TIMESTAMP:
        case DPI_NATIVE_TYPE_INTERVAL_YM:
        case DPI_NATIVE_TYPE_INTERVAL_DS:
            if (dpiOci__attrGet(handle, handleType, (void*) &info->scale, 0,
                    DPI_OCI_ATTR_SCALE, "get scale", error) < 0)
                return DPI_FAILURE;
            if (dpiOci__attrGet(handle, handleType, (void*) &info->precision,
                    0, DPI_OCI_ATTR_PRECISION, "get precision", error) < 0)
                return DPI_FAILURE;
            if (nativeTypeNum == DPI_NATIVE_TYPE_TIMESTAMP ||
                    nativeTypeNum == DPI_NATIVE_TYPE_INTERVAL_DS) {
                info->fsPrecision = (uint8_t) info->scale;
                info->scale = 0;
            }
            break;
        default:
            info->precision = 0;
            info->fsPrecision = 0;
            info->scale = 0;
            break;
    }

    // change default type to integer if precision/scale supports it
    if (info->oracleTypeNum == DPI_ORACLE_TYPE_NUMBER && info->scale == 0 &&
            info->precision > 0 && info->precision <= DPI_MAX_INT64_PRECISION)
        info->defaultNativeTypeNum = DPI_NATIVE_TYPE_INT64;

    // acquire size (in bytes) of item
    info->sizeInChars = 0;
    if (oracleType && oracleType->sizeInBytes == 0) {
        if (dpiOci__attrGet(handle, handleType, (void*) &ociSize, 0,
                DPI_OCI_ATTR_DATA_SIZE, "get size (bytes)", error) < 0)
            return DPI_FAILURE;
        info->dbSizeInBytes = ociSize;
        info->clientSizeInBytes = ociSize;
    } else {
        info->dbSizeInBytes = 0;
        info->clientSizeInBytes = 0;
    }

    // acquire size (in characters) of item, if applicable
    if (oracleType && oracleType->isCharacterData &&
            oracleType->sizeInBytes == 0) {
        if (dpiOci__attrGet(handle, handleType, (void*) &ociSize, 0,
                DPI_OCI_ATTR_CHAR_SIZE, "get size (chars)", error) < 0)
            return DPI_FAILURE;
        info->sizeInChars = ociSize;
        if (charsetForm == DPI_SQLCS_NCHAR)
            info->clientSizeInBytes = info->sizeInChars *
                    conn->env->nmaxBytesPerCharacter;
        else if (conn->charsetId != conn->env->charsetId)
            info->clientSizeInBytes = info->sizeInChars *
                    conn->env->maxBytesPerCharacter;
    }

    // acquire object type, if applicable
    if (info->oracleTypeNum == DPI_ORACLE_TYPE_OBJECT) {
        if (dpiObjectType__allocate(conn, handle, handleType,
                &info->objectType, error) < 0)
            return DPI_FAILURE;
        if (dpiObjectType__isXmlType(info->objectType)) {
            dpiObjectType__free(info->objectType, error);
            info->objectType = NULL;
            info->ociTypeCode = DPI_SQLT_CHR;
            info->oracleTypeNum = DPI_ORACLE_TYPE_XMLTYPE;
            info->defaultNativeTypeNum = DPI_NATIVE_TYPE_BYTES;
        }
    }

    // determine if the data refers to a JSON column
    if (handleType == DPI_OCI_HTYPE_DESCRIBE &&
            conn->env->versionInfo->versionNum >= 19) {
        if (dpiOci__attrGet(handle, handleType, (void*) &isJson, 0,
                DPI_OCI_ATTR_JSON_COL, "get is JSON column", error) < 0)
            return DPI_FAILURE;
        info->isJson = isJson;
    }

    // determine if the data refers to an OSON column
    if (handleType == DPI_OCI_HTYPE_DESCRIBE &&
            conn->env->versionInfo->versionNum >= 21) {
        if (dpiOci__attrGet(handle, handleType, (void*) &isOson, 0,
                DPI_OCI_ATTR_OSON_COL, "get is OSON column", error) < 0)
            return DPI_FAILURE;
        info->isOson = isOson;
    }

    // get domain and annotations, if applicable
    if (handleType == DPI_OCI_HTYPE_DESCRIBE &&
            conn->env->versionInfo->versionNum >= 23) {

        // check for domain
        if (dpiOci__attrGet(handle, handleType, (void*) &info->domainSchema,
                &info->domainSchemaLength, DPI_OCI_ATTR_DOMAIN_SCHEMA,
                "get domain schema", error) < 0)
            return DPI_FAILURE;
        if (dpiOci__attrGet(handle, handleType, (void*) &info->domainName,
                &info->domainNameLength, DPI_OCI_ATTR_DOMAIN_NAME,
                "get domain name", error) < 0)
            return DPI_FAILURE;

        // check for annotations
        if (dpiOci__attrGet(handle, handleType, (void*) &info->numAnnotations,
                0, DPI_OCI_ATTR_NUM_ANNOTATIONS, "get number of annotations",
                error) < 0)
            return DPI_FAILURE;
        if (info->numAnnotations > 0) {

            // allocate memory for the array
            if (dpiUtils__allocateMemory(info->numAnnotations,
                    sizeof(dpiAnnotation), 1, "allocate annotation array",
                    (void**) &info->annotations, error) < 0)
                return DPI_FAILURE;

            // get the list parameter
            if (dpiOci__attrGet(handle, handleType,
                    (void*) &listParam, 0, DPI_OCI_ATTR_LIST_ANNOTATIONS,
                    "get annotation list param", error) < 0)
                return DPI_FAILURE;

            // populate the arrays
            for (i = 0 ; i < info->numAnnotations; i++) {
                annotation = &info->annotations[i];
                if (dpiOci__paramGet(listParam, DPI_OCI_DTYPE_PARAM,
                        &itemParam, (uint32_t) i + 1, "get annotation",
                        error) < 0)
                    return DPI_FAILURE;
                if (dpiOci__attrGet(itemParam, DPI_OCI_DTYPE_PARAM,
                        (void*) &annotation->key, &annotation->keyLength,
                        DPI_OCI_ATTR_ANNOTATION_KEY,
                        "get annotation key", error) < 0)
                    return DPI_FAILURE;
                if (dpiOci__attrGet(itemParam, DPI_OCI_DTYPE_PARAM,
                        (void*) &annotation->value, &annotation->valueLength,
                        DPI_OCI_ATTR_ANNOTATION_VALUE,
                        "get annotation value", error) < 0)
                    return DPI_FAILURE;
            }

        }

    }

    // get vector metadata, if applicable
    if (info->oracleTypeNum == DPI_ORACLE_TYPE_VECTOR) {

        // get vector format
        if (dpiOci__attrGet(handle, handleType, &info->vectorFormat, 0,
                DPI_OCI_ATTR_VECTOR_DATA_FORMAT, "get vector column format",
                error) < 0)
            return DPI_FAILURE;

        // get number of dimensions
        if (dpiOci__attrGet(handle, handleType, &info->vectorDimensions, 0,
                DPI_OCI_ATTR_VECTOR_DIMENSION,
                "get number of vector dimensions in column", error) < 0)
            return DPI_FAILURE;

        // get vector column flags
        if (dpiOci__attrGet(handle, handleType, &info->vectorFlags, 0,
                DPI_OCI_ATTR_VECTOR_PROPERTY, "get vector column flags",
                error) < 0)
            return DPI_FAILURE;

    }

    return DPI_SUCCESS;
}