oci_rs 0.8.0

This crate provides a Rust wrapper to the Oracle Call Interface (OCI) library.
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
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
use libc::{c_int, c_uchar, c_uint, c_ushort, c_void, size_t};

#[derive(Debug)]
pub enum OCIEnv {}
#[derive(Debug)]
pub enum OCIServer {}
#[derive(Debug)]
pub enum OCIError {}
#[derive(Debug)]
pub enum OCISvcCtx {}
#[derive(Debug)]
pub enum OCISession {}
#[derive(Debug)]
pub enum OCIStmt {}
#[derive(Debug)]
pub enum OCISnapshot {}
#[derive(Debug)]
pub enum OCIBind {}
#[derive(Debug)]
pub enum OCIParam {}
#[derive(Debug)]
pub enum OCIDefine {}

const OCI_DEFAULT: c_uint = 0;
const OCI_THREADED: c_uint = 1;

#[derive(Debug)]
pub enum EnvironmentMode {
    Default,
    Threaded,
}

impl From<EnvironmentMode> for c_uint {
    fn from(mode: EnvironmentMode) -> Self {
        match mode {
            EnvironmentMode::Default => OCI_DEFAULT,
            EnvironmentMode::Threaded => OCI_THREADED,
        }
    }
}

const OCI_SUCCESS: c_int = 0;
const OCI_ERROR: c_int = -1;
const OCI_NO_DATA: c_int = 100;
const OCI_INVALID_HANDLE: c_int = -2;

#[derive(Debug)]
pub enum ReturnCode {
    Success,
    Error,
    NoData,
    InvalidHandle,
}

impl From<c_int> for ReturnCode {
    fn from(number: c_int) -> Self {
        match number {
            OCI_SUCCESS => ReturnCode::Success,
            OCI_NO_DATA => ReturnCode::NoData,
            OCI_INVALID_HANDLE => ReturnCode::InvalidHandle,
            OCI_ERROR => ReturnCode::Error,
            _ => panic!(format!(
                "Found an unknown return code: {}, this should not happen.",
                number
            )),
        }
    }
}

const OCI_HTYPE_ENV: c_uint = 1;
const OCI_HTYPE_ERROR: c_uint = 2;
const OCI_HTYPE_SVCCTX: c_uint = 3;
const OCI_HTYPE_STMT: c_uint = 4;
const OCI_HTYPE_DEFINE: c_uint = 6;
const OCI_HTYPE_SERVER: c_uint = 8;
const OCI_HTYPE_SESSION: c_uint = 9;

#[derive(Debug, Copy, Clone)]
pub enum HandleType {
    Environment,
    Error,
    Service,
    Statement,
    Define,
    Server,
    Session,
}

impl From<HandleType> for c_uint {
    fn from(handle_type: HandleType) -> Self {
        match handle_type {
            HandleType::Environment => OCI_HTYPE_ENV,
            HandleType::Error => OCI_HTYPE_ERROR,
            HandleType::Service => OCI_HTYPE_SVCCTX,
            HandleType::Statement => OCI_HTYPE_STMT,
            HandleType::Define => OCI_HTYPE_DEFINE,
            HandleType::Server => OCI_HTYPE_SERVER,
            HandleType::Session => OCI_HTYPE_SESSION,
        }
    }
}

impl From<c_uint> for HandleType {
    fn from(number: c_uint) -> Self {
        match number {
            OCI_HTYPE_ENV => HandleType::Environment,
            OCI_HTYPE_ERROR => HandleType::Error,
            OCI_HTYPE_SVCCTX => HandleType::Service,
            OCI_HTYPE_STMT => HandleType::Statement,
            OCI_HTYPE_DEFINE => HandleType::Define,
            OCI_HTYPE_SERVER => HandleType::Server,
            OCI_HTYPE_SESSION => HandleType::Session,
            _ => panic!(format!(
                "Found an unknown handle type: {}, this should not happen.",
                number
            )),
        }
    }
}

impl<'hnd> From<HandleType> for &'hnd str {
    fn from(handle_type: HandleType) -> Self {
        match handle_type {
            HandleType::Environment => "Environment handle",
            HandleType::Error => "Error handle",
            HandleType::Service => "Service handle",
            HandleType::Statement => "Statement handle",
            HandleType::Define => "Define handle",
            HandleType::Server => "Server handle",
            HandleType::Session => "Session handle",
        }
    }
}

const OCI_ATTR_DATA_SIZE: c_uint = 1;
const OCI_ATTR_DATA_TYPE: c_uint = 2;
const OCI_ATTR_PRECISION: c_uint = 5;
const OCI_ATTR_SCALE: c_uint = 6;
const OCI_ATTR_SERVER: c_uint = 6;
const OCI_ATTR_SESSION: c_uint = 7;
const OCI_ATTR_PREFETCH_ROWS: c_uint = 11;
const OCI_ATTR_PARAM_COUNT: c_uint = 18;
const OCI_ATTR_USERNAME: c_uint = 22;
const OCI_ATTR_PASSWORD: c_uint = 23;
const OCI_ATTR_STMT: c_uint = 24;
const OCI_ATTR_PARAM: c_uint = 124;

#[derive(Debug)]
pub enum AttributeType {
    DataSize,
    DataType,
    Precision,
    Scale,
    Server,
    Session,
    PrefetchRows,
    ParameterCount,
    UserName,
    Password,
    Statement,
    Parameter,
}

impl From<AttributeType> for c_uint {
    fn from(attribute_type: AttributeType) -> Self {
        match attribute_type {
            AttributeType::DataSize => OCI_ATTR_DATA_SIZE,
            AttributeType::DataType => OCI_ATTR_DATA_TYPE,
            AttributeType::Precision => OCI_ATTR_PRECISION,
            AttributeType::Scale => OCI_ATTR_SCALE,
            AttributeType::Server => OCI_ATTR_SERVER,
            AttributeType::Session => OCI_ATTR_SESSION,
            AttributeType::PrefetchRows => OCI_ATTR_PREFETCH_ROWS,
            AttributeType::ParameterCount => OCI_ATTR_PARAM_COUNT,
            AttributeType::UserName => OCI_ATTR_USERNAME,
            AttributeType::Password => OCI_ATTR_PASSWORD,
            AttributeType::Statement => OCI_ATTR_STMT,
            AttributeType::Parameter => OCI_ATTR_PARAM,
        }
    }
}

const OCI_CRED_RDBMS: c_uint = 1;

#[derive(Debug)]
pub enum CredentialsType {
    Rdbms,
}

impl From<CredentialsType> for c_uint {
    fn from(credentials_type: CredentialsType) -> Self {
        match credentials_type {
            CredentialsType::Rdbms => OCI_CRED_RDBMS,
        }
    }
}

const OCI_NTV_SYNTAX: c_uint = 1;

#[derive(Debug)]
pub enum SyntaxType {
    Ntv,
}

impl From<SyntaxType> for c_uint {
    fn from(syntax_type: SyntaxType) -> Self {
        match syntax_type {
            SyntaxType::Ntv => OCI_NTV_SYNTAX,
        }
    }
}

const SQLT_CHR: c_ushort = 1;
const SQLT_NUM: c_ushort = 2;
const SQLT_INT: c_ushort = 3;
const SQLT_FLT: c_ushort = 4;
const SQLT_DAT: c_ushort = 12;
const SQLT_AFC: c_ushort = 96;
const SQLT_TIMESTAMP: c_ushort = 187;
const SQLT_TIMESTAMP_INTERNAL: c_ushort = 180;
const SQLT_TIMESTAMP_TZ: c_ushort = 188;
const SQLT_TIMESTAMP_TZ_INTERNAL: c_ushort = 181;

#[derive(Debug)]
pub enum OciDataType {
    SqlVarChar,
    SqlInt,
    SqlNum,
    SqlFloat,
    SqlDate,
    SqlChar,
    SqlTimestamp,
    SqlTimestampTz,
}
impl OciDataType {
    /// The number of bytes needed to respresent the data type.
    ///
    pub fn size(&self) -> c_ushort {
        match *self {
            OciDataType::SqlVarChar => 4000,
            OciDataType::SqlInt | OciDataType::SqlNum | OciDataType::SqlFloat => 8,
            OciDataType::SqlDate => 7,
            OciDataType::SqlChar => 2000,
            OciDataType::SqlTimestamp => 11,
            OciDataType::SqlTimestampTz => 13,
        }
    }
}

impl From<OciDataType> for c_ushort {
    fn from(sql_type: OciDataType) -> Self {
        match sql_type {
            OciDataType::SqlVarChar => SQLT_CHR,
            OciDataType::SqlInt => SQLT_INT,
            OciDataType::SqlNum => SQLT_NUM,
            OciDataType::SqlFloat => SQLT_FLT,
            OciDataType::SqlDate => SQLT_DAT,
            OciDataType::SqlChar => SQLT_AFC,
            OciDataType::SqlTimestamp => SQLT_TIMESTAMP_INTERNAL,
            OciDataType::SqlTimestampTz => SQLT_TIMESTAMP_TZ_INTERNAL,
        }
    }
}

impl<'a> From<&'a OciDataType> for c_ushort {
    fn from(sql_type: &OciDataType) -> Self {
        match *sql_type {
            OciDataType::SqlVarChar => SQLT_CHR,
            OciDataType::SqlInt => SQLT_INT,
            OciDataType::SqlNum => SQLT_NUM,
            OciDataType::SqlFloat => SQLT_FLT,
            OciDataType::SqlDate => SQLT_DAT,
            OciDataType::SqlChar => SQLT_AFC,
            OciDataType::SqlTimestamp => SQLT_TIMESTAMP_INTERNAL,
            OciDataType::SqlTimestampTz => SQLT_TIMESTAMP_TZ_INTERNAL,
        }
    }
}

impl From<c_ushort> for OciDataType {
    fn from(number: c_ushort) -> Self {
        match number {
            SQLT_CHR => OciDataType::SqlVarChar,
            SQLT_INT => OciDataType::SqlInt,
            SQLT_NUM => OciDataType::SqlNum,
            SQLT_FLT => OciDataType::SqlFloat,
            SQLT_DAT => OciDataType::SqlDate,
            SQLT_AFC => OciDataType::SqlChar,
            SQLT_TIMESTAMP => OciDataType::SqlTimestamp,
            SQLT_TIMESTAMP_TZ => OciDataType::SqlTimestampTz,
            _ => panic!(format!(
                "Found an unknown OciDataType code, {}, this should not happen.",
                number
            )),
        }
    }
}

const OCI_STMT_UNKNOWN: c_uint = 0;
const OCI_STMT_SELECT: c_uint = 1;
const OCI_STMT_UPDATE: c_uint = 2;
const OCI_STMT_DELETE: c_uint = 3;
const OCI_STMT_INSERT: c_uint = 4;
const OCI_STMT_CREATE: c_uint = 5;
const OCI_STMT_DROP: c_uint = 6;
const OCI_STMT_ALTER: c_uint = 7;
const OCI_STMT_BEGIN: c_uint = 8;
const OCI_STMT_DECLARE: c_uint = 9;

#[derive(Debug)]
pub enum StatementType {
    Unknown,
    Select,
    Update,
    Delete,
    Insert,
    Create,
    Drop,
    Alter,
    Begin,
    Declare,
}

impl From<StatementType> for c_uint {
    fn from(statement_type: StatementType) -> Self {
        match statement_type {
            StatementType::Unknown => OCI_STMT_UNKNOWN,
            StatementType::Select => OCI_STMT_SELECT,
            StatementType::Update => OCI_STMT_UPDATE,
            StatementType::Delete => OCI_STMT_DELETE,
            StatementType::Insert => OCI_STMT_INSERT,
            StatementType::Create => OCI_STMT_CREATE,
            StatementType::Drop => OCI_STMT_DROP,
            StatementType::Alter => OCI_STMT_ALTER,
            StatementType::Begin => OCI_STMT_BEGIN,
            StatementType::Declare => OCI_STMT_DECLARE,
        }
    }
}

impl From<c_uint> for StatementType {
    fn from(number: c_uint) -> Self {
        match number {
            OCI_STMT_UNKNOWN => StatementType::Unknown,
            OCI_STMT_SELECT => StatementType::Select,
            OCI_STMT_UPDATE => StatementType::Update,
            OCI_STMT_DELETE => StatementType::Delete,
            OCI_STMT_INSERT => StatementType::Insert,
            OCI_STMT_CREATE => StatementType::Create,
            OCI_STMT_DROP => StatementType::Drop,
            OCI_STMT_ALTER => StatementType::Alter,
            OCI_STMT_BEGIN => StatementType::Begin,
            OCI_STMT_DECLARE => StatementType::Declare,
            _ => panic!(format!(
                "Found an unknown statement type: {}, this should not happen.",
                number
            )),
        }
    }
}

const OCI_DTYPE_PARAM: c_uint = 53;

#[derive(Debug)]
pub enum DescriptorType {
    Parameter,
}

impl From<DescriptorType> for c_uint {
    fn from(descriptor_type: DescriptorType) -> Self {
        match descriptor_type {
            DescriptorType::Parameter => OCI_DTYPE_PARAM,
        }
    }
}

const OCI_FETCH_NEXT: c_ushort = 2;
const OCI_FETCH_FIRST: c_ushort = 4;

#[derive(Debug)]
pub enum FetchType {
    Next,
    First,
}

impl From<FetchType> for c_ushort {
    fn from(fetch_type: FetchType) -> Self {
        match fetch_type {
            FetchType::Next => OCI_FETCH_NEXT,
            FetchType::First => OCI_FETCH_FIRST,
        }
    }
}

const OCI_NUMBER_UNSIGNED: c_uint = 0;
const OCI_NUMBER_SIGNED: c_uint = 2;

#[derive(Debug)]
pub enum OciNumberType {
    Unsigned,
    Signed,
}

impl From<OciNumberType> for c_uint {
    fn from(oci_number_type: OciNumberType) -> Self {
        match oci_number_type {
            OciNumberType::Unsigned => OCI_NUMBER_UNSIGNED,
            OciNumberType::Signed => OCI_NUMBER_SIGNED,
        }
    }
}

// Note: The library name is selected in the build script because it is different
// for each platform.
extern "C" {
    /// Creates the environment handle. The signature has been changed to only
    /// allow null pointers for the user defined memory parameters. This means
    /// that user defined memory functions are not supported. I don't know how
    /// to specify function pointers in the signature but then send in null pointers
    /// when calling. Any attempt so far has been thwarted by the type system.
    ///
    /// # Safety
    ///
    /// C function so is unsafe.
    ///
    pub fn OCIEnvCreate(
        envhpp: &*mut OCIEnv,
        mode: c_uint,
        ctxp: *const c_void,
        // maloc_cb: extern "C" fn(*const c_void, size_t) -> *const c_void,
        maloc_cb: *const c_void,
        // raloc_cb: extern "C" fn(*const c_void, *const c_void, size_t)
        //                        -> *const c_void,
        raloc_cb: *const c_void,
        // mfree_cb: extern "C" fn(*const c_void, *const c_void) -> *const c_void,
        mfree_cb: *const c_void,
        xtramemsz: size_t,
        // usrmempp: &*mut c_void)
        usrmempp: *const c_void,
    ) -> c_int;

    /// Frees a handle and deallocates the memory. Any child handles are automatically
    /// freed as well.
    /// See [Oracle docs](https://docs.oracle.com/database/122/
    /// LNOCI/handle-and-descriptor-functions.htm#LNOCI17135) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIHandleFree(hndlp: *mut c_void, hnd_type: c_uint) -> c_int;

    /// Allocates handles. As in OCIEnvCreate it allows user defined memory
    /// but I have effectively disabled that by setting the usrmempp parameter
    /// as a null pointer. Same problem, I don't know how to specifiy a function
    /// pointer by send in a null pointer when calling.
    /// See [Oracle docs](https://docs.oracle.com/database/122/
    /// LNOCI/handle-and-descriptor-functions.htm#LNOCI17134) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIHandleAlloc(
        parenth: *const c_void,
        hndlpp: &*mut c_void,
        hnd_type: c_uint,
        xtramem_sz: size_t,
        // usrmempp: &*mut c_void
        usrmempp: *const c_void,
    ) -> c_int;

    /// Gets an error record. The sqlstate parameter is unused.
    /// See [Oracle docs](https://docs.oracle.com/database/122/
    /// LNOCI/miscellaneous-functions.htm#GUID-4B99087C-74F6-498A-8310-D6645172390A) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIErrorGet(
        hndlp: *mut c_void,
        recordno: c_uint,
        sqlstate: *mut c_uchar,
        errcodep: *mut c_int,
        bufp: *mut c_uchar,
        bufsiz: c_uint,
        hnd_type: c_uint,
    ) -> c_int;

    /// Connects to the database.
    /// See [Oracle docs](https://docs.oracle.com/database/122/
    /// LNOCI/connect-authorize-and-initialize-functions.htm#LNOCI17119) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIServerAttach(
        srvhp: *mut OCIServer,
        errhp: *mut OCIError,
        dblink: *const c_uchar,
        dblink_len: c_int,
        mode: c_uint,
    ) -> c_int;

    /// Disconnects the database. Must be called during disconnection or else
    /// will leave zombie processes running in the OS.
    /// See [Oracle docs](https://docs.oracle.com/database/122/
    /// LNOCI/connect-authorize-and-initialize-functions.htm#LNOCI17121) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIServerDetach(srvhp: *mut OCIServer, errhp: *mut OCIError, mode: c_uint) -> c_int;

    /// Sets the value of an attribute of a handle, e.g. username in session
    /// handle.
    /// See [Oracle docs](https://docs.oracle.com/database/122/LNOCI/
    /// handle-and-descriptor-functions.htm#GUID-3741D7BD-7652-4D7A-8813-AC2AEA8D3B03)
    /// for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIAttrSet(
        trgthndlp: *const c_void,
        trghndltyp: c_uint,
        attributep: *mut c_void,
        size: c_uint,
        attrtype: c_uint,
        errhp: *mut OCIError,
    ) -> c_int;

    /// Gets the value of an attribute of a handle.
    /// See [Oracle docs](https://docs.oracle.com/database/122/LNOCI/
    /// handle-and-descriptor-functions.htm#LNOCI17130) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIAttrGet(
        trgthndlp: *const c_void,
        trghndltyp: c_uint,
        attributep: *mut c_void,
        sizep: *mut c_uint,
        attrtype: c_uint,
        errhp: *mut OCIError,
    ) -> c_int;

    /// Creates and starts a user session.
    /// See [Oracle docs](https://docs.oracle.com/database/122/LNOCI/
    /// connect-authorize-and-initialize-functions.htm#GUID-31B1FDB3-056E-4AF9-9B89-8DA6AA156947)
    /// for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCISessionBegin(
        svchp: *mut OCISvcCtx,
        errhp: *mut OCIError,
        userhp: *mut OCISession,
        credt: c_uint,
        mode: c_uint,
    ) -> c_int;

    /// Stops a user session.
    /// See [Oracle docs](https://docs.oracle.com/database/122/LNOCI/
    /// connect-authorize-and-initialize-functions.htm#LNOCI17123) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCISessionEnd(
        svchp: *mut OCISvcCtx,
        errhp: *mut OCIError,
        userhp: *mut OCISession,
        mode: c_uint,
    ) -> c_int;

    /// Prepares a SQL or PL/SQL statement for execution. The user has the option of using
    /// the statement cache, if it has been enabled.
    /// See [Oracle docs](https://docs.oracle.com/database/122/LNOCI/
    /// statement-functions.htm#LNOCI17168) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIStmtPrepare2(
        svchp: *mut OCISvcCtx,
        stmthp: &*mut OCIStmt,
        errhp: *mut OCIError,
        stmttext: *const c_uchar,
        stmt_len: c_uint,
        key: *const c_uchar,
        keylen: c_uint,
        language: c_uint,
        mode: c_uint,
    ) -> c_int;

    /// Releases the statement handle obtained by a call to OCIStmtPrepare2().
    /// See [Oracle docs](https://docs.oracle.com/database/122/LNOCI/
    /// statement-functions.htm#LNOCI17169) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIStmtRelease(
        stmthp: *mut OCIStmt,
        errhp: *mut OCIError,
        key: *const c_uchar,
        keylen: c_uint,
        mode: c_uint,
    ) -> c_int;

    /// Executes a statement.
    /// See [Oracle docs](https://docs.oracle.com/database/122/LNOCI/
    /// statement-functions.htm#LNOCI17163) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    pub fn OCIStmtExecute(
        svchp: *mut OCISvcCtx,
        stmtp: *mut OCIStmt,
        errhp: *mut OCIError,
        iters: c_uint,
        rowoff: c_uint,
        snap_in: *const OCISnapshot,
        snap_out: *mut OCISnapshot,
        mode: c_uint,
    ) -> c_int;

    /// Commits the transaction associated with a specified service context.
    /// See [Oracle docs](https://docs.oracle.com/cd/E11882_01/appdev.112/e10646/
    /// oci17msc006.htm#LNOCI13112) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCITransCommit(svchp: *mut OCISvcCtx, errhp: *mut OCIError, flags: c_uint) -> c_int;

    /// Creates an association between a program variable and a placeholder in a SQL statement
    /// or PL/SQL block.
    /// See [Oracle docs](http://docs.oracle.com/database/122/LNOCI/
    /// bind-define-describe-functions.htm#LNOCI17141) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIBindByPos(
        stmtp: *mut OCIStmt,
        bindpp: &*mut OCIBind,
        errhp: *mut OCIError,
        position: c_uint,
        valuep: *mut c_void,
        value_sz: c_int,
        dty: c_ushort,
        indp: *mut c_void,
        alenp: *mut c_ushort,
        rcodep: *mut c_ushort,
        maxarr_len: c_uint,
        curelep: *mut c_uint,
        mode: c_uint,
    ) -> c_int;

    /// Returns a descriptor of a parameter specified by position in the describe handle or
    /// statement handle.
    /// See [Oracle docs](http://docs.oracle.com/database/122/LNOCI/
    /// handle-and-descriptor-functions.htm#GUID-35D2FF91-139B-4A5C-97C8-8BC29866CCA4) for more
    /// info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIParamGet(
        hndlp: *const c_void,
        htype: c_uint,
        errhp: *mut OCIError,
        parmdpp: &*mut OCIParam,
        pos: c_uint,
    ) -> c_int;

    /// Associates an item in a select list with the type and output data buffer.
    /// See [Oracle docs](http://docs.oracle.com/database/122/LNOCI/
    /// bind-define-describe-functions.htm#GUID-CFE5AA54-DEBC-42D3-8A27-AFF1E7815691) for more
    /// info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIDefineByPos(
        stmtp: *mut OCIStmt,
        defnpp: &*mut OCIDefine,
        errhp: *mut OCIError,
        position: c_uint,
        valuep: *mut c_void,
        value_sz: c_int,
        dty: c_ushort,
        indp: *mut c_void,
        rlenp: *mut c_ushort,
        rcodep: *mut c_ushort,
        mode: c_uint,
    ) -> c_int;

    /// Fetches a row from the (scrollable) result set.
    /// See [Oracle docs](http://docs.oracle.com/database/122/LNOCI/
    /// statement-functions.htm#GUID-DF585B90-58BA-45FC-B7CE-6F7F987C03B9) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIStmtFetch2(
        stmthp: *mut OCIStmt,
        errhp: *mut OCIError,
        nrows: c_uint,
        orientation: c_ushort,
        fetchOffset: c_int,
        mode: c_uint,
    ) -> c_int;

    /// Deallocates a previously allocated descriptor.
    /// See [Oracle docs](http://docs.oracle.com/database/122/LNOCI/
    /// handle-and-descriptor-functions.htm#LNOCI17134) for more info.
    ///
    /// # Safety
    ///
    /// Unsafe C
    ///
    pub fn OCIDescriptorFree(descp: *mut c_void, desc_type: c_uint) -> c_int;

}