/
ocilib.h
18218 lines (16467 loc) · 396 KB
/
ocilib.h
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
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
+-----------------------------------------------------------------------------------------+
| |
| OCILIB - C Driver for Oracle |
| |
| (C Wrapper for Oracle OCI) |
| |
| Website : http://www.ocilib.net |
| |
| Copyright (c) 2007-2012 Vincent ROGIER <vince.rogier@ocilib.net> |
| |
+-----------------------------------------------------------------------------------------+
| |
| This library is free software; you can redistribute it and/or |
| modify it under the terms of the GNU Lesser General Public |
| License as published by the Free Software Foundation; either |
| version 2 of the License, or (at your option) any later version. |
| |
| This library is distributed in the hope that it will be useful, |
| but WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| Lesser General Public License for more details. |
| |
| You should have received a copy of the GNU Lesser General Public |
| License along with this library; if not, write to the Free |
| Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
| |
+-----------------------------------------------------------------------------------------+
+-----------------------------------------------------------------------------------------+
| IMPORTANT NOTICE |
+-----------------------------------------------------------------------------------------+
| |
| This file contains explanations about Oracle and OCI technologies. |
| OCILIB is a wrapper around OCI and thus exposes OCI features. |
| The OCILIB documentation intends to explain Oracle / OCI concepts |
| and is naturally based on the official Oracle OCI documentation. |
| |
| Some parts of OCILIB documentation may include some informations |
| taken and adapted from the following Oracle documentations : |
| - Oracle Call Interface Programmer's Guide |
| - Oracle Streams - Advanced Queuing User's Guide |
| |
+-----------------------------------------------------------------------------------------+
*/
/* --------------------------------------------------------------------------------------------- *
* $Id: ocilib.h, Vincent Rogier $
* --------------------------------------------------------------------------------------------- */
#ifndef OCILIB_H_INCLUDED
#define OCILIB_H_INCLUDED
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/**
* @mainpage
*
* @image html logo-160x120.png
*
* @section s_intro Introduction
*
* OCILIB is an open source and portable Oracle Driver that delivers really fast
* and reliable access to Oracle databases.
*
* The OCILIB library :
*
* - offers a rich, full featured and easy to use API
* - runs on all Oracle platforms
* - is written in pure ISO C code with native ISO C Unicode support
* - encapsulates OCI (Oracle Call Interface)
* - is the most complete available OCI wrapper
*
* @section s_version Version information
*
* <b>Current version : 3.12.0 (2013-02-07)</b>
*
* @section s_feats Main features
*
* - Full Ansi and Unicode support on all platforms (ISO C wide strings or UTF8 strings)
* - Full 32/64 bits compatibility
* - Comptabile with all Oracle version >= 8i
* - Automatic adaptation to the runtime Oracle client version
* - Runtime loading of Oracle libraries
* - Builtin error handling (global and thread context)
* - Full support for SQL API and Object API
* - Full support for ALL Oracle SQL and PL/SQL datatypes (scalars, objects, refs, collections, ..)
* - Full support for PL/SQL (blocks, cursors, Index by Tables and Nested tables)
* - Support for non scalar datatype with trough library objects
* - Oracle Pooling (connections and sessions pools)
* - Oracle XA connectivity (X/Open Distributed Transaction Processing XA interface)
* - Oracle AQ (Advanded Queues)
* - Oracle TAF (Transparent Application Failover) and HA (High availabality) support
* - Binding array Interface
* - Returning DML feature
* - Scrollable statements
* - Statement cache
* - Direct Path loading
* - Remote Instances Startup/Shutdown
* - Oracle Database Change notification / Continuous Query Notification
* - Oracle warnings support
* - Global and local transactions
* - Describe database schema objects
* - Hash tables API
* - Portable Threads and mutexes API
*
* @section s_down Download
*
* Get OCILIB from <a href="http://orclib.sourceforge.net">OCILIB Project page</a>
* at Sourceforge Website
*
* @section s_author Author
*
* OCILIB is developed by <a href="mailto:vince.rogier@ocilib.net">Vincent Rogier</a>
*
* @section s_changelog ChangeLog
*
* @include ChangeLog.txt
*
*/
/* --------------------------------------------------------------------------------------------- *
* Platform config
* --------------------------------------------------------------------------------------------- */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
/* --------------------------------------------------------------------------------------------- *
* C headers
* --------------------------------------------------------------------------------------------- */
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <errno.h>
#include <limits.h>
/* --------------------------------------------------------------------------------------------- *
* MS Windows platform detection
* --------------------------------------------------------------------------------------------- */
#ifndef _WINDOWS
#if defined(_WIN32) || defined(_WIN64) ||defined(_WIN32_WINNT)
#define _WINDOWS
#endif
#endif
#ifdef _WINDOWS
#ifdef boolean
#undef boolean
#endif
#include <windows.h>
#ifdef boolean
#undef boolean
#endif
#endif
/* --------------------------------------------------------------------------------------------- *
* OCILIB version information
* --------------------------------------------------------------------------------------------- */
#define OCILIB_MAJOR_VERSION 3
#define OCILIB_MINOR_VERSION 12
#define OCILIB_REVISION_VERSION 0
/* --------------------------------------------------------------------------------------------- *
* Installing OCILIB
* --------------------------------------------------------------------------------------------- */
/**
* @defgroup g_install Installing OCILIB
* @{
*
* @par Compatibilities
*
* Actual version of OCILIB has been validated on :
* - Platforms: Windows, HP/UX, Linux, Mac OS, Solaris, AIX
* - Architectures: 32/64bits
* - Compilers: GCC / MinGW, MS Compilers, IBM XLC, CCs, LabView
* - Oracle versions: 8i, 9i, 10g, 11g
*
* @note
*
* The validation of OCILIB on OpenVMS is still pending.
*
* Please, contact the author if you have validated OCILIB on platforms or compilers not listed here.
*
* @par Global build options
*
* OCILIB supports the following global build options:
*
* => Oracle import modes
*
* - OCI_IMPORT_LINKAGE for linkage at compile time (default on Unix systems)
* - OCI_IMPORT_RUNTIME for runtime loading (default with prebuilt OCILIB libraries on MS Windows)
*
* => Oracle charset modes
*
* - OCI_CHARSET_ANSI : ANSI strings (default)
* - OCI_CHARSET_WIDE : wide strings using ISO C wide character
* - OCI_CHARSET_MIXED : ANSI for meta data and wide characters for user data
* - OCI_CHARSET_UFT8 : UFT8 strings
*
* From v3.6.0, OCI_CHARSET_WIDE replaces OCI_CHARSET_UNICODE OCI_CHARSET_UNICODE remains a
* valid identifier for backward compatibility
*
* => Calling convention (WINDOWS ONLY)
*
* - OCI_API = __cdecl or blank for C/C++ only ! (default on Unix systems and non MSVC projects)
* - OCI_API = __stdcall to link OCILIB shared library on Ms Windows (default for MSVC projects)
*
* @note
*
* On Windows, OCI_API MUST be set to __stdcall in order to use prebuilt libraries
* From v3.5.0, ocilib.h automatically sets OCI_API to __stdcall with MS compilers
*
* @par Installing OCILIB on UNIX like systems
*
* OCILIB uses GNU tools for deployment and installation on UNIX like platforms
*
* Uncompress the archive (ocilib-x.y.z-gnu.tar.gz)
* - $ cd ocilib-x.y.z
* - $ ./configure
* - $ ./make
* - $ ./make install (this step might require admin rights)
*
* Check the shared library path environment variable (LD_LIBRARY_PATH, LD_PATH, ...):
* - it must include $ORACLE_HOME\[lib|lib32|lib64]
* - it must include the path where OCILIB has been installed
* (by example, typically /usr/local/lib under Linux)
*
* In order to get these values loaded at logon time, export these values in
* your .profile configuration file :
* - > export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib:/usr/local/lib
*
* <b>GNU Installation options </b>:
*
* OCILIB supports some options that are not needed for most common configurations.
*
* List of available options:
*
* - --with-oracle-import=(linkage|runtime)
* - --with-oracle-charset=(ansi|wide|mixed) (old mode 'unicode' mapped to 'wide')
* - --with-oracle-home=(custom oracle regular client directory)
* - --with-oracle-headers-path=(oracle header files directory)
* - --with-oracle-lib-path=(oracle shared lib directory)
* - --with-oracle-lib-name=(oracle shared lib name)
* - --with-custom-loader=(linker flag telling the linker which loader to use
* when loading dynamically at runtime Oracle shared libs.
* This option must be provide if the platform does not use the default
* loader flag '-ldl') and the --with-oracle-import is set to 'runtime'
*
* @note
*
* --with-oracle-headers-path and --with-oracle-lib-path are meant to be used with
* Instant client only but can used for regular client of libs and headers are
* not located in usual folders
*
* @note
*
* If the Oracle OCI linkage mode is set to 'linkage' (default) and no Oracle lib
* path is provided, OCILIB configure script tries to located the Oracle library
* folder following this sequence :
* - $ORACLE_HOME/lib32 (32 bits libs)
* - $ORACLE_HOME/lib (32 or 64 bits libs)
* - $ORACLE_HOME/lib64 (64 bits libs)
*
* @note
*
* To compile native 64 bits versions of OCILIB, you need pass your compiler
* specifics flags to the configure script.
*
* To use OCILIB in a project:
*
* - include "ocilib.h" in your application
* - Add the flag -I$USER_LIBS/include to your compiler
* - Defines OCILIB modes:
* - OCI import mode (-DOCI_IMPORT_LINKAGE | -DOCI_IMPORT_RUNTIME)
* - OCI charset mode (-DOCI_CHARSET_ANSI | -DOCI_CHARSET_WIDE | -DOCI_CHARSET_MIXED)
* - Add the flag -L/$ORACLE_HOME/[lib|lib32|lib64] -lclntsh to the linker
* - Add the flag -L$USER_LIBS/lib -locilib to the linker
*
* where :
* - $USER_LIBS is the folder where OCILIB was installed
* - $ORACLE_LIB_PATH is Oracle client shared library path
*
* Some older version of Oracle 8 have direct path API symbols located in the library libclient8.
* With these versions, you must include as well the linker flag -lclient8 to use Direct Path API.
*
* @par Installing and using OCILIB on Microsoft Windows
*
* 32bits and 64bits DLLs are provided for x86 architectures.
* Visual .NET (2005/2008) solutions are also provided to recompile the Dlls and the demo.
*
* - Uncompress the archive (ocilib-x.y.z-windows.zip)
* - Copy ocilib\include\ocilib.h to a folder listed in the compiler headers folders
* - Copy ocilib\lib[32|64]\ocilib[x].lib to a folder listed in the linker libraries folders
* - Copy ocilib\lib[32|64]\ocilib[x].dll to a folder included in the PATH
* environment variable
*
* [x] is the compiled version of OCILIB ('a' -> ANSI, 'w' -> Unicode, 'm' -> Mixed)
*
* To use OCILIB in a project :
*
* - include "ocilib.h" in your application
* - define call convention (OCI_API) to __stdcall
* - define charset mode (OCI_CHARSET_ANSI | OCI_CHARSET_MIXED| OCI_CHARSET_WIDE | OCI_CHARSET_UFT8)
*
* Note for MinGW users:
* - Precompiled 32bits static libraries libocilib[x].a are provided
* - To use OCILIB dll's, copy/rename import libraries ocilib[x].lib to libocilib[x].lib
* - Add the desired version (static/shared + charset) of the library to the linker options
*
* @note
*
* The OCI import mode (OCI_IMPORT_LINKAGE or OCI_IMPORT_RUNTIME is only used when
* compiling OCILIB source code
* @par Oracle Instant Client Support
*
* OCILIB supports Oracle Instant Client.
*
* On Microsoft Windows, there is no difference between using a regular Oracle
* client and an Instant Client with OCILIB
*
* On Unix-like systems, the Instant Client is divided in different packages.
*
* Public headers and shared libs are not part of the same package.
*
* So, you must provide the following options to the configure command:
*
* - with-oracle-headers-path: location the public header files
* - with-oracle-lib-path: location the oracle shared lib
*
* If your instant client package containing the shared libs does not have a symbolic link
* 'libclntsh.[shared lib extension]' to the fully qualified shared lib real name,
* you must create it:
*
* Example on Linux:
*
* - $ ln -s $ORALIBPATH/libclntsh.so.10.1 $ORALIBPATH/libclntsh.so
*
* @}
*
*/
/* Import mode */
#define OCI_IMPORT_MODE_LINKAGE 1
#define OCI_IMPORT_MODE_RUNTIME 2
#ifdef OCI_IMPORT_RUNTIME
#undef OCI_IMPORT_LINKAGE
#endif
#ifdef OCI_IMPORT_LINKAGE
#undef OCI_IMPORT_RUNTIME
#endif
#if !defined(OCI_IMPORT_RUNTIME) && !defined(OCI_IMPORT_LINKAGE)
#define OCI_IMPORT_LINKAGE
#endif
#ifdef OCI_IMPORT_RUNTIME
#define OCI_IMPORT_MODE OCI_IMPORT_MODE_RUNTIME
#else
#define OCI_IMPORT_MODE OCI_IMPORT_MODE_LINKAGE
#endif
/* Charset modes */
#ifdef OCI_CHARSET_UNICODE
#define OCI_CHARSET_WIDE
#endif
#ifdef OCI_CHARSET_WIDE
#undef OCI_CHARSET_ANSI
#undef OCI_CHARSET_MIXED
#endif
#ifdef OCI_CHARSET_MIXED
#undef OCI_CHARSET_ANSI
#undef OCI_CHARSET_WIDE
#endif
#ifdef OCI_CHARSET_ANSI
#undef OCI_CHARSET_MIXED
#undef OCI_CHARSET_WIDE
#endif
#if !defined(OCI_CHARSET_ANSI) && !defined(OCI_CHARSET_MIXED) && \
!defined(OCI_CHARSET_WIDE)
#define OCI_CHARSET_ANSI
#endif
/* Calling convention */
#ifndef OCI_API
#ifdef _MSC_VER
#define OCI_API __stdcall
#else
#define OCI_API
#endif
#endif
/* Build mode */
#ifndef OCI_EXPORT
#define OCI_EXPORT
#endif
/**
* @defgroup g_charset Charset support
* @{
*
* OCILIB supports ANSI and Unicode charsets
*
* Oracle started a real Unicode support with Oracle8i but only for user data.
* All SQL and PL/SQ/ statements, metadata string, database objects names, etc,
* ... were still only supported in ANSI.
*
* With Oracle 9i, Oracle provides a full Unicode support.
*
* So depending on the compile time Oracle library or the runtime loaded
* library, the Unicode support differs.
*
* OCILIB supports:
*
* - ANSI (char)
* - Unicode (wchar_t)
* - Mixed charset: ANSI for metadata, Unicode for user data
* - UTF8 strings
*
* OCILIB uses two types of strings:
*
* - mtext: for metadata, SQL strings, object attributes.
* - dtext: for input binds and output data
*
* mtext and dtext are declared as defines around char and wchar_t depending on the charset option
*
* @par Text macro
*
* - MT() macro : 'meta text' -> meta data and strings passed to OCI calls
* - DT() macro : 'data text' -> user input/output data
*
* @par Option OCI_CHARSET_ANSI
*
* - dtext --> char
* - DT(x) --> x
*
* - mtext --> char
* - MT(x) --> x
*
* @par Option OCI_CHARSET_WIDE
*
* - dtext --> wchar_t
* - DT(x) --> L ## x
*
* - mtext --> wchar_t
* - MT(x) --> L ## x
*
* @par Option OCI_CHARSET_MIXED
*
* - dtext --> wchar_t
* - DT(x) --> L ## x
*
* - mtext --> char
* - MT(x) --> x
*
* @par Unicode and ISO C
*
* Well, ISO C:
* - doesn't know anything about Unicode.
* - makes wide characters support tricky because the size of a wide character
* is not defined and is freely adaptable by implementations.
*
* OCILIB uses char/wchar_t strings for public interface and internal storage.
*
* OCILIB, for Unicode builds, initialize OCI in UTF16 Unicode mode. Oracle
* implements this mode with a 2 bytes (fixed length) UTF16 encoding.
*
* So, on systems implementing wchar_t as 2 bytes based UTF16 (e.g. Ms Windows),
* input strings are directly passed to Oracle and taken back from it.
*
* On other systems (most of the Unix systems) that use UTF32 as encoding
* (4 bytes based wchar_t), OCILIB uses:
* - temporary buffers to pass string to OCI for metadata strings
* - buffer expansion from UTF16 to UTF32 for user data string:
* - allocation based on sizeof(wchar_t)
* - data filling based on sizeof(short) -> (UTF16 2 bytes)
* - data expansion to sizeof(wchar_t).
*
* The buffer expansion is done in place and has the advantage of not requiring extra buffer.
* That reduces the cost of the Unicode/ISO C handling overhead on Unix systems.
*
* @par UTF8 strings
*
* From version 3.6.0, OCILIB fully supports UTF8 strings for all data in OCI_CHARSET_ANSI mode
* if NLS_LANG environment variable is set to an valid UTF8 Oracle charset string
*
* @par Charset mapping macros
*
* OCILIB main header file provides macro around most common string functions of
* the C standard library.
*
* these macros are based on the model:
*
* - mtsxxx() for mtext * typed strings
* - dtsxxx() for dtext * typed strings
*
* xxx is the standard C library string function name without the character type prefix (str/wcs).
*
* List of available macros:
* - mtsdup, dtsdup
* - mtscpy, dtscpy
* - mtsncpy, dtsncpy
* - mtscat, dtscat
* - mtsncat, dtsncat
* - mtslen, dtslen
* - mtscmp, dtscmp
* - mtscasecmp, dtscasecmp
* - mtsprintf, dtsprintf
* - mtstol, dtstol
*
**/
/* Unicode mode */
#ifdef OCI_CHARSET_WIDE
#define OCI_METADATA_WIDE
#define OCI_USERDATA_WIDE
#define OCI_INCLUDE_WCHAR
#endif
#ifdef OCI_CHARSET_MIXED
#define OCI_USERDATA_WIDE
#define OCI_INCLUDE_WCHAR
#endif
/* include wchar header if needed */
#ifdef OCI_INCLUDE_WCHAR
#include <wctype.h>
#ifdef _MSC_VER
#if (_MSC_VER < 1300) && defined(__cplusplus)
extern "C++" {
#endif
#include <wchar.h>
#if (_MSC_VER < 1300) && defined(__cplusplus)
}
#endif
#else
#include <wchar.h>
#endif
#endif
/* Charset macros */
#define OCI_CHAR_ANSI 1
#define OCI_CHAR_WIDE 2
#ifdef OCI_METADATA_WIDE
#define MT(x) L ## x
#define mtext wchar_t
#define OCI_CHAR_MTEXT OCI_CHAR_WIDE
#else
#define MT(x) x
#define mtext char
#define OCI_CHAR_MTEXT OCI_CHAR_ANSI
#endif
#ifdef OCI_USERDATA_WIDE
#define DT(x) L ## x
#define dtext wchar_t
#define OCI_CHAR_DTEXT OCI_CHAR_WIDE
#else
#define DT(x) x
#define dtext char
#define OCI_CHAR_DTEXT OCI_CHAR_ANSI
#endif
/*
For ISO conformance, strdup/wcsdup/stricmp/strncasecmp are not used.
All wide char routines are part of the 1995 Normative Addendum 1 to the ISO C90 standard.
OCILIB also needs an ANSI equivalent to swprintf => ocisprintf
Thus OCILIB exports the following helper functions
*/
OCI_EXPORT int ocisprintf
(
char *str,
int size,
const char *format,
...
);
OCI_EXPORT char * ocistrdup
(
const char * src
);
OCI_EXPORT int ocistrcasecmp
(
const char *str1,
const char *str2
);
#ifdef OCI_INCLUDE_WCHAR
OCI_EXPORT wchar_t * ociwcsdup
(
const wchar_t * src
);
OCI_EXPORT int ociwcscasecmp
(
const wchar_t *str1,
const wchar_t *str2
);
#endif
/* special defines for Microsoft C runtime that is not C ISO compliant */
#ifdef _WINDOWS
#define vsnprintf _vsnprintf
#ifdef OCI_INCLUDE_WCHAR
#define swprintf _snwprintf
#endif
#endif
/* helpers mapping macros */
#ifdef OCI_METADATA_WIDE
#define mtsdup ociwcsdup
#define mtscpy wcscpy
#define mtsncpy wcsncpy
#define mtscat wcscat
#define mtsncat wcsncat
#define mtslen wcslen
#define mtscmp wcscmp
#define mtscasecmp ociwcscasecmp
#define mtsprintf swprintf
#define mtstol wcstol
#else
#define mtsdup ocistrdup
#define mtscpy strcpy
#define mtsncpy strncpy
#define mtscat strcat
#define mtsncat strncat
#define mtslen strlen
#define mtscmp strcmp
#define mtscasecmp ocistrcasecmp
#define mtsprintf ocisprintf
#define mtstol strtol
#endif
#ifdef OCI_USERDATA_WIDE
#define dtsdup ociwcsdup
#define dtscpy wcscpy
#define dtsncpy wcsncpy
#define dtscat wcscat
#define dtsncat wcsncat
#define dtslen wcslen
#define dtscmp wcscmp
#define dtscasecmp ociwcscasecmp
#define dtsprintf swprintf
#define dtscanf swscanf
#define dtstol wcstol
#else
#define dtsdup ocistrdup
#define dtscpy strcpy
#define dtsncpy strncpy
#define dtscat strcat
#define dtsncat strncat
#define dtslen strlen
#define dtscmp strcmp
#define dtscasecmp ocistrcasecmp
#define dtsprintf ocisprintf
#define dtscanf sscanf
#define dtstol strtol
#endif
/* string size macros */
#define mtextsize(s) (mtslen(s) * sizeof(mtext))
#define dtextsize(s) (dtslen(s) * sizeof(dtext))
/**
* @}
*/
/**
* @defgroup g_objects Library objects and datatypes
* @{
*
* OCILIB implements:
*
* - Oracle Scalar datatypes through scalar C datatypes
* - Oracle opaque/complex objects though opaque library handles
* - Library objects for manipulating the database: connections, transactions, statements...
*
* @par Supported Oracle datatypes
*
* - All Database types are supported excluding REFs.
*
* Here is a summary of the supported datatypes:
*
* - Scalar types CHAR/NCHAR, VARCHAR2/NVARCHAR2, NUMBER, FLOAT, REAL, RAW, ...
* - Binary types: RAW, LONG RAW, VARRAW, ..
* - Larges Objects (Lobs and Files) : BLOB, CLOB, NCLOB, BFILE
* - LONG types: LONG, VAR LONG
* - Date, Timestamps et Intervals: DATE, TIMESTAMP, INTERVAL
* - PL/SQL types: Ref cursors, PL/SQL Tables
* - Named Types (by value): Built-in system objects and User defined objects
* - VARRAYs and Nested Tables
* - ROWIDs
*
* @par OCILIB library objects
*
* The public OCILIB library interface implements encapsulation for
* representing database objects (such as connections, statements ...) through
* opaque structures (pointers to structures whose definition is kept private)
*
* Instead of directly manipulating the structures and their members, the library
* has functions to access the underlying members.
*
* It's designed to make the user code as more independent as possible of
* the library details.
*
**/
/**
* @struct OCI_Pool
*
* @brief
* Pool object (session or connection)
*
* A pool is a set of pooled objects
*
*/
typedef struct OCI_Pool OCI_Pool;
/**
* @struct OCI_Connection
*
* @brief
* Oracle physical connection.
*
* It holds all information about a connection such as error handling, associated statements, ...
* Error handling and transactions are embedded within a connection object.
*
* @warning
* Multithreaded applications that use multiple connections should use one connection per thread
* as all statements associated with a connection share the same context.
*
*/
typedef struct OCI_Connection OCI_Connection;
/**
* @struct OCI_Statement
*
* @brief
* Oracle SQL or PL/SQL statement.
*
* A Statement object allows users to prepare, execute SQL orders or PL/SQL blocks
*
*/
typedef struct OCI_Statement OCI_Statement;
/**
* @struct OCI_Bind
*
* @brief
* Internal bind representation.
*
* A bind object is an object that holds all information about an Oracle statement binding operation
*
*/
typedef struct OCI_Bind OCI_Bind;
/**
* @struct OCI_Resultset
*
* @brief
* Collection of output columns from a select statement.
*
* A resultset object is the result of 'select' SQL Statement.
*
* It's a set of data (ordered in columns) that can be fetched row by row
* to get data returned by the SQL statement
*
*/
typedef struct OCI_Resultset OCI_Resultset;
/**
* @struct OCI_Column
*
* @brief
* Oracle SQL Column and Type member representation.
*
* A column object represents an output column from a select statement
*
*/
typedef struct OCI_Column OCI_Column;
/**
* @struct OCI_Lob
*
* @brief
* Oracle Internal Large objects:
*
* The following internal Larges Objects are supported:
*
* - BLOBs : Binary large objects
* - CLOBs / NCLOBs : Character large objects
*
* LOBs were introduced by OCI8 to replace Long datatypes.
*
* It's designed to store really larges objects (buffer, files) inside the database
*
* Oracle encourages programmers to use those objects instead of LONG, LONG RAW, ...
*
* OCILIB supports both LOBs and LONGs
*
*/
typedef struct OCI_Lob OCI_Lob;
/**
* @struct OCI_File
*
* @brief
* Oracle External Large objects:
*
* The following external Larges Objects are supported:
*
* - BFILEs : Binary files
* - CFILEs : Character files
*
* FILEs were introduced by OCI8 in order to store references to files located outside the database.
*
* @warning
* Only Read-only access is allowed on BFILEs
*
* Two way to use FILEs :
*
* - within statement context (query, binding)
* - without statement context (server files reading) through OCI_File properties functions
*
*/
typedef struct OCI_File OCI_File;
/**
* @struct OCI_Transaction
*
* @brief
* Oracle Transaction.
*
* A transaction can be:
*
* - Local: it's implicitly created by OCILIB
* - Global: it's explicitly created by the program
*
*/
typedef struct OCI_Transaction OCI_Transaction;
/**
* @struct OCI_Long
*
* @brief Oracle Long datatype.
*
* The following long Objects are supported:
*
* - LONG RAW : Binary long objects
* - LONG : Character long objects
*
* Those types were used in older versions of Oracle (before Oracle8i) to store
* large chunks of data in the database.
*
* It's now depreciated by Oracle that recommends using LOBs
*
* Many databases and applications are still designed to use LONGs that's why
* OCILIB supports Long Objects and piecewise operations
*
*/
typedef struct OCI_Long OCI_Long;
/**
* @struct OCI_Date
*
* @brief
* Oracle internal date representation.
*
*/
typedef struct OCI_Date OCI_Date;
/**
* @struct OCI_Timestamp
*
* @brief
* Oracle internal timestamp representation.
*
*/
typedef struct OCI_Timestamp OCI_Timestamp;
/**
* @struct OCI_Interval
*
* @brief
* Oracle internal interval representation.
*
*/
typedef struct OCI_Interval OCI_Interval;
/**
* @struct OCI_Object
*
* @brief
* Oracle Named types representation.
*
*/
typedef struct OCI_Object OCI_Object;
/**
* @struct OCI_Coll
*
* @brief
* Oracle Collections (VARRAYs and Nested Tables) representation.
*
*/
typedef struct OCI_Coll OCI_Coll;
/**
* @struct OCI_Elem
*
* @brief
* Oracle Collection item representation.
*
*/
typedef struct OCI_Elem OCI_Elem;
/**
* @struct OCI_Iter
*
* @brief
* Oracle Collection iterator representation.
*
*/
typedef struct OCI_Iter OCI_Iter;
/**
* @struct OCI_TypeInfo
*
* @brief
* Type info metadata handle.
*
*/
/**
* @struct OCI_Ref
*
* @brief
* Oracle REF type representation.
*
*/
typedef struct OCI_Ref OCI_Ref;
/**