forked from synopse/mORMot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SynDBODBC.pas
2270 lines (2123 loc) · 88.6 KB
/
SynDBODBC.pas
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
/// ODBC 3.x library direct access classes to be used with our SynDB architecture
// - this unit is a part of the freeware Synopse mORMot framework,
// licensed under a MPL/GPL/LGPL tri-license; version 1.18
unit SynDBODBC;
{
This file is part of Synopse mORMot framework.
Synopse mORMot framework. Copyright (C) 2017 Arnaud Bouchez
Synopse Informatique - http://synopse.info
*** BEGIN LICENSE BLOCK *****
Version: MPL 1.1/GPL 2.0/LGPL 2.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the License.
The Original Code is Synopse mORMot framework.
The Initial Developer of the Original Code is Arnaud Bouchez.
Portions created by the Initial Developer are Copyright (C) 2017
the Initial Developer. All Rights Reserved.
Contributor(s):
- Esteban Martin (EMartin)
- squirrel
- zed
Alternatively, the contents of this file may be used under the terms of
either the GNU General Public License Version 2 or later (the "GPL"), or
the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
in which case the provisions of the GPL or the LGPL are applicable instead
of those above. If you wish to allow use of your version of this file only
under the terms of either the GPL or the LGPL, and not to allow others to
use your version of this file under the terms of the MPL, indicate your
decision by deleting the provisions above and replace them with the notice
and other provisions required by the GPL or the LGPL. If you do not delete
the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****
Version 1.16
- first public release, corresponding to mORMot Framework 1.16
Version 1.17
- initial working code, tested with ODBC Oracle provider
Version 1.18
- huge performance boost due to SQL statement cache implementation
- added FireBird ODBC driver detection
- circumvent restriction of some non-Unicode ODBC drivers to use SQL_C_CHAR
parameter binding instead of SQL_C_WCHAR (e.g. Microsoft Oracle ODBC)
- circumvent restring of some drivers which expect SQLExpect() columns to be
retrieved in left-to-right order
- fixed unexpected exception raised if SQL_NO_DATA is returned
- fixed issue when binding parameters: now specifies the correct SQL data type
- now trim any spaces when retrieving database schema text values
- fixed ticket [4c68975022] about broken SQL statement when logging active
- fixed ticket [d48283f5ec] about error at binding void string parameter
- exception during Commit should leave transaction state - see [ca035b8f0da]
- GetCol() will now retrieve all columns at once - mandatory for drivers not
supporting SQL_GD_ANY_ORDER feature (like SQL Server Native Client 10.0)
- TODBCConnectionProperties.Create will now handle full ODBC connection string
in aDatabaseName instead of ODBC Data Source name in aServerName
- now TODBCConnection.Connect() will recognize the DBMS from its driver name
- added NexusDB, Firebird, SQlite3 and DB2 support
- added Informix support - by EMartin
- added GetProcedureNames for listing stored procedure names from current connection
- addes GetViewNames and SQLGetViewNames for listing view names from current connection
- added ODBCInstalledDriversList for listing installed ODBC drivers (Windows only)
- overrided GetDatabaseNameSafe over ODBC connection string
TODO:
- implement array binding of parameters
http://msdn.microsoft.com/en-us/library/windows/desktop/ms709287
- implement row-wise binding when all columns are inlined
http://msdn.microsoft.com/en-us/library/windows/desktop/ms711730
}
{$I Synopse.inc} // define HASINLINE USETYPEINFO CPU32 CPU64 OWNNORMTOUPPER
interface
uses
{$ifdef MSWINDOWS}
Windows,
{$endif}
SysUtils,
{$ifndef DELPHI5OROLDER}
Variants,
{$endif}
{$ifdef FPC}
dynlibs,
{$endif}
Classes,
SynCommons,
SynLog,
SynDB;
{ -------------- TODBC* classes and types implementing an ODBC library connection }
type
/// generic Exception type, generated for ODBC connection
EODBCException = class(ESQLDBException);
/// will implement properties shared by the ODBC library
TODBCConnectionProperties = class(TSQLDBConnectionPropertiesThreadSafe)
protected
fDriverDoesNotHandleUnicode: Boolean;
fSQLDriverConnectPrompt: Boolean;
/// this overridden method will hide de DATABASE/PWD fields in ODBC connection string
function GetDatabaseNameSafe: RawUTF8; override;
/// this overridden method will retrieve the kind of DBMS from the main connection
function GetDBMS: TSQLDBDefinition; override;
public
/// initialize the connection properties
// - will raise an exception if the ODBC library is not available
// - SQLConnect() API will be used if aServerName is set: it should contain
// the ODBC Data source name as defined in "ODBC Data Source Administrator"
// tool (C:\Windows\SysWOW64\odbcad32.exe for 32bit app on Win64) - in this
// case, aDatabaseName will be ignored
// - SQLDriverConnect() API will be used if aServerName is '' and
// aDatabaseName is set - in this case, aDatabaseName should contain a
// full connection string like (e.g. for a local SQLEXPRESS instance):
// ! 'DRIVER=SQL Server Native Client 10.0;UID=.;server=.\SQLEXPRESS;'+
// ! 'Trusted_Connection=Yes;MARS_Connection=yes'
// see @http://msdn.microsoft.com/en-us/library/ms715433
// or when using Firebird ODBC:
// ! 'DRIVER=Firebird/InterBase(r) driver;CHARSET=UTF8;UID=SYSDBA;PWD=masterkey;'
// ! 'DBNAME=MyServer/3051:C:\database\myData.fdb'
// ! 'DRIVER=Firebird/InterBase(r) driver;CHARSET=UTF8;DBNAME=dbfile.fdb;'+
// ! 'CLIENT=fbembed.dll'
// for IBM DB2 and its official driver:
// ! 'Driver=IBM DB2 ODBC DRIVER;Database=SAMPLE;'+
// ! 'Hostname=localhost;Port=50000;UID=db2admin;Pwd=db2Password'
// for PostgreSQL - driver from http://ftp.postgresql.org/pub/odbc/versions/msi
// ! 'Driver=PostgreSQL Unicode;Database=postgres;'+
// ! 'Server=localhost;Port=5432;UID=postgres;Pwd=postgresPassword'
// for MySQL - driver from https://dev.mysql.com/downloads/connector/odbc
// (note: 5.2.6 and 5.3.1 driver seems to be slow in ODBC.FreeHandle)
// ! 'Driver=MySQL ODBC 5.2 UNICODE Driver;Database=test;'+
// ! 'Server=localhost;Port=3306;UID=root;Pwd='
// for IBM Informix and its official driver:
// ! 'Driver=IBM INFORMIX ODBC DRIVER;Database=SAMPLE;'+
// ! 'Host=localhost;Server=<instance name on host>;Service=<service name
// ! in ../drivers/etc/services>;Protocol=olsoctcp;UID=<Windows/Linux user account>;
// ! Pwd=<Windows/Linux user account password>'
constructor Create(const aServerName, aDatabaseName, aUserID, aPassWord: RawUTF8); override;
/// create a new connection
// - call this method if the shared MainConnection is not enough (e.g. for
// multi-thread access)
// - the caller is responsible of freeing this instance
// - this overridden method will create an TODBCConnection instance
function NewConnection: TSQLDBConnection; override;
/// get all table names
// - will retrieve the corresponding metadata from ODBC library if SQL
// direct access was not defined
procedure GetTableNames(out Tables: TRawUTF8DynArray); override;
/// get all view names
// - will retrieve the corresponding metadata from ODBC library if SQL
// direct access was not defined
procedure GetViewNames(out Views: TRawUTF8DynArray); override;
/// retrieve the column/field layout of a specified table
// - will also check if the columns are indexed
// - will retrieve the corresponding metadata from ODBC library if SQL
// direct access was not defined (e.g. for dDB2)
procedure GetFields(const aTableName: RawUTF8; out Fields: TSQLDBColumnDefineDynArray); override;
/// initialize fForeignKeys content with all foreign keys of this DB
// - used by GetForeignKey method
procedure GetForeignKeys; override;
/// retrieve a list of stored procedure names from current connection
procedure GetProcedureNames(out Procedures: TRawUTF8DynArray); override;
/// retrieve procedure input/output parameter information
// - aProcName: stored procedure name to retrieve parameter infomation.
// - Parameters: parameter list info (name, datatype, direction, default)
procedure GetProcedureParameters(const aProcName: RawUTF8; out Parameters: TSQLDBProcColumnDefineDynArray); override;
/// if full connection string may prompt the user for additional information
// - property used only with SQLDriverConnect() API (i.e. when aServerName
// is '' and aDatabaseName contains a full connection string)
// - set to TRUE to allow UI prompt if needed
property SQLDriverConnectPrompt: boolean read fSQLDriverConnectPrompt
write fSQLDriverConnectPrompt;
end;
/// implements a direct connection to the ODBC library
TODBCConnection = class(TSQLDBConnectionThreadSafe)
protected
fODBCProperties: TODBCConnectionProperties;
fEnv: pointer;
fDbc: pointer;
fDBMS: TSQLDBDefinition;
fDBMSName, fDriverName, fDBMSVersion, fSQLDriverFullString: RawUTF8;
public
/// connect to a specified ODBC database
constructor Create(aProperties: TSQLDBConnectionProperties); override;
/// release memory and connection
destructor Destroy; override;
/// connect to the ODBC library, i.e. create the DB instance
// - should raise an Exception on error
procedure Connect; override;
/// stop connection to the ODBC library, i.e. release the DB instance
// - should raise an Exception on error
procedure Disconnect; override;
/// return TRUE if Connect has been already successfully called
function IsConnected: boolean; override;
/// initialize a new SQL query statement for the given connection
// - the caller should free the instance after use
function NewStatement: TSQLDBStatement; override;
/// begin a Transaction for this connection
// - current implementation do not support nested transaction with those
// methods: exception will be raised in such case
procedure StartTransaction; override;
/// commit changes of a Transaction for this connection
// - StartTransaction method must have been called before
procedure Commit; override;
/// discard changes of a Transaction for this connection
// - StartTransaction method must have been called before
procedure Rollback; override;
/// the remote DBMS type, as retrieved at ODBC connection opening
property DBMS: TSQLDBDefinition read fDBMS;
/// the full connection string (expanded from ServerName)
property SQLDriverFullString: RawUTF8 read fSQLDriverFullString;
published
/// the remote DBMS name, as retrieved at ODBC connection opening
property DBMSName: RawUTF8 read fDBMSName;
/// the remote DBMS version, as retrieved at ODBC connection opening
property DBMSVersion: RawUTF8 read fDBMSVersion;
/// the local driver name, as retrieved at ODBC connection opening
property DriverName: RawUTF8 read fDriverName;
end;
/// implements a statement using a ODBC connection
TODBCStatement = class(TSQLDBStatementWithParamsAndColumns)
protected
fStatement: pointer;
fColData: TRawByteStringDynArray;
fSQLW: RawUnicode;
procedure AllocStatement;
procedure DeallocStatement;
procedure BindColumns;
procedure GetData(var Col: TSQLDBColumnProperty; ColIndex: integer);
function GetCol(Col: integer; ExpectedType: TSQLDBFieldType): TSQLDBStatementGetCol;
function MoreResults: boolean;
public
/// create a ODBC statement instance, from an existing ODBC connection
// - the Execute method can be called once per TODBCStatement instance,
// but you can use the Prepare once followed by several ExecutePrepared methods
// - if the supplied connection is not of TOleDBConnection type, will raise
// an exception
constructor Create(aConnection: TSQLDBConnection); override;
// release all associated memory and ODBC handles
destructor Destroy; override;
/// Prepare an UTF-8 encoded SQL statement
// - parameters marked as ? will be bound later, before ExecutePrepared call
// - if ExpectResults is TRUE, then Step() and Column*() methods are available
// to retrieve the data rows
// - raise an EODBCException or ESQLDBException on any error
procedure Prepare(const aSQL: RawUTF8; ExpectResults: Boolean=false); overload; override;
/// Execute a prepared SQL statement
// - parameters marked as ? should have been already bound with Bind*() functions
// - this overridden method will log the SQL statement if sllSQL has been
// enabled in SynDBLog.Family.Level
// - raise an EODBCException or ESQLDBException on any error
procedure ExecutePrepared; override;
/// Reset the previous prepared statement
// - this overridden implementation will reset all bindings and the cursor state
// - raise an EODBCException on any error
procedure Reset; override;
/// After a statement has been prepared via Prepare() + ExecutePrepared() or
// Execute(), this method must be called one or more times to evaluate it
// - you shall call this method before calling any Column*() methods
// - return TRUE on success, with data ready to be retrieved by Column*()
// - return FALSE if no more row is available (e.g. if the SQL statement
// is not a SELECT but an UPDATE or INSERT command)
// - access the first or next row of data from the SQL Statement result:
// if SeekFirst is TRUE, will put the cursor on the first row of results,
// otherwise, it will fetch one row of data, to be called within a loop
// - raise an EODBCException or ESQLDBException exception on any error
function Step(SeekFirst: boolean=false): boolean; override;
/// returns TRUE if the column contains NULL
function ColumnNull(Col: integer): boolean; override;
/// return a Column integer value of the current Row, first Col is 0
function ColumnInt(Col: integer): Int64; override;
/// return a Column floating point value of the current Row, first Col is 0
function ColumnDouble(Col: integer): double; override;
/// return a Column floating point value of the current Row, first Col is 0
function ColumnDateTime(Col: integer): TDateTime; override;
/// return a Column currency value of the current Row, first Col is 0
// - should retrieve directly the 64 bit Currency content, to avoid
// any rounding/conversion error from floating-point types
function ColumnCurrency(Col: integer): currency; override;
/// return a Column UTF-8 encoded text value of the current Row, first Col is 0
function ColumnUTF8(Col: integer): RawUTF8; override;
/// return a Column as a blob value of the current Row, first Col is 0
// - ColumnBlob() will return the binary content of the field is was not ftBlob,
// e.g. a 8 bytes RawByteString for a vtInt64/vtDouble/vtDate/vtCurrency,
// or a direct mapping of the RawUnicode
function ColumnBlob(Col: integer): RawByteString; override;
/// append all columns values of the current Row to a JSON stream
// - will use WR.Expand to guess the expected output format
// - fast overridden implementation with no temporary variable
// - BLOB field value is saved as Base64, in the '"\uFFF0base64encodedbinary"
// format and contains true BLOB data
procedure ColumnsToJSON(WR: TJSONWriter); override;
/// returns the number of rows updated by the execution of this statement
function UpdateCount: integer; override;
end;
{$ifdef MSWINDOWS}
/// List all ODBC drivers installed
// - aDrivers is the output driver list container, which should be either nil (to
// create a new TStringList), or any existing TStrings instance (may be from VCL
// - aIncludeVersion: include the DLL driver version as <driver name>=<dll version>
// in aDrivers (somewhat slower)
function ODBCInstalledDriversList(const aIncludeVersion: Boolean; out aDrivers: TStrings): boolean;
{$endif MSWINDOWS}
implementation
{$ifdef MSWINDOWS}
uses
Registry;
{$endif MSWINDOWS}
{ -------------- ODBC library interfaces, constants and types }
const
SQL_NULL_DATA = -1;
SQL_DATA_AT_EXEC = -2;
SQL_NO_TOTAL = -4;
// return values from functions
SQL_SUCCESS = 0;
SQL_SUCCESS_WITH_INFO = 1;
SQL_NO_DATA = 100;
SQL_PARAM_TYPE_UNKNOWN = 0;
SQL_PARAM_INPUT = 1;
SQL_PARAM_INPUT_OUTPUT = 2;
SQL_RESULT_COL = 3;
SQL_PARAM_OUTPUT = 4;
SQL_RETURN_VALUE = 5;
SQL_PARAM_DATA_AVAILABLE = 101;
SQL_ERROR = (-1);
SQL_INVALID_HANDLE = (-2);
SQL_STILL_EXECUTING = 2;
SQL_NEED_DATA = 99;
// flags for null-terminated string
SQL_NTS = (-3);
SQL_NTSL = (-3);
// maximum message length
SQL_MAX_MESSAGE_LENGTH = 512;
// date/time length constants
SQL_DATE_LEN = 10;
// add P+1 if precision is nonzero
SQL_TIME_LEN = 8;
// add P+1 if precision is nonzero
SQL_TIMESTAMP_LEN = 19;
// handle type identifiers
SQL_HANDLE_ENV = 1;
SQL_HANDLE_DBC = 2;
SQL_HANDLE_STMT = 3;
SQL_HANDLE_DESC = 4;
// env attribute
SQL_ATTR_ODBC_VERSION = 200;
SQL_ATTR_CONNECTION_POOLING = 201;
SQL_ATTR_CP_MATCH = 202;
SQL_ATTR_OUTPUT_NTS = 10001;
SQL_OV_ODBC3 = pointer(3);
// values for SQLStatistics()
SQL_INDEX_UNIQUE = 0;
SQL_INDEX_ALL = 1;
SQL_QUICK = 0;
SQL_ENSURE = 1;
// connection attributes
SQL_ACCESS_MODE = 101;
SQL_AUTOCOMMIT = 102;
SQL_LOGIN_TIMEOUT = 103;
SQL_OPT_TRACE = 104;
SQL_OPT_TRACEFILE = 105;
SQL_TRANSLATE_DLL = 106;
SQL_TRANSLATE_OPTION = 107;
SQL_TXN_ISOLATION = 108;
SQL_CURRENT_QUALIFIER = 109;
SQL_ODBC_CURSORS = 110;
SQL_QUIET_MODE = 111;
SQL_PACKET_SIZE = 112;
SQL_ATTR_AUTO_IPD = 10001;
SQL_ATTR_METADATA_ID = 10014;
// statement attributes
SQL_ATTR_APP_ROW_DESC = 10010;
SQL_ATTR_APP_PARAM_DESC = 10011;
SQL_ATTR_IMP_ROW_DESC = 10012;
SQL_ATTR_IMP_PARAM_DESC = 10013;
SQL_ATTR_CURSOR_SCROLLABLE = (-1);
SQL_ATTR_CURSOR_SENSITIVITY = (-2);
// SQL_ATTR_CURSOR_SCROLLABLE values
SQL_NONSCROLLABLE = 0;
SQL_SCROLLABLE = 1;
// SQL_AUTOCOMMIT options
SQL_AUTOCOMMIT_OFF = pointer(0);
SQL_AUTOCOMMIT_ON = pointer(1);
// identifiers of fields in the SQL descriptor
SQL_DESC_COUNT = 1001;
SQL_DESC_TYPE = 1002;
SQL_DESC_LENGTH = 1003;
SQL_DESC_OCTET_LENGTH_PTR = 1004;
SQL_DESC_PRECISION = 1005;
SQL_DESC_SCALE = 1006;
SQL_DESC_DATETIME_INTERVAL_CODE = 1007;
SQL_DESC_NULLABLE = 1008;
SQL_DESC_INDICATOR_PTR = 1009;
SQL_DESC_DATA_PTR = 1010;
SQL_DESC_NAME = 1011;
SQL_DESC_UNNAMED = 1012;
SQL_DESC_OCTET_LENGTH = 1013;
SQL_DESC_ALLOC_TYPE = 1099;
// identifiers of fields in the diagnostics area
SQL_DIAG_RETURNCODE = 1;
SQL_DIAG_NUMBER = 2;
SQL_DIAG_ROW_COUNT = 3;
SQL_DIAG_SQLSTATE = 4;
SQL_DIAG_NATIVE = 5;
SQL_DIAG_MESSAGE_TEXT = 6;
SQL_DIAG_DYNAMIC_FUNCTION = 7;
SQL_DIAG_CLASS_ORIGIN = 8;
SQL_DIAG_SUBCLASS_ORIGIN = 9;
SQL_DIAG_CONNECTION_NAME = 10;
SQL_DIAG_SERVER_NAME = 11;
SQL_DIAG_DYNAMIC_FUNCTION_CODE = 12;
// SQL data type codes
SQL_UNKNOWN_TYPE = 0;
SQL_CHAR = 1;
SQL_NUMERIC = 2;
SQL_DECIMAL = 3;
SQL_INTEGER = 4;
SQL_SMALLINT = 5;
SQL_FLOAT = 6;
SQL_REAL = 7;
SQL_DOUBLE = 8;
SQL_DATETIME = 9;
SQL_DATE = 9;
SQL_INTERVAL = 10;
SQL_TIME = 10;
SQL_TIMESTAMP = 11;
SQL_VARCHAR = 12;
SQL_LONGVARCHAR = -1;
SQL_BINARY = -2;
SQL_VARBINARY = -3;
SQL_LONGVARBINARY = -4;
SQL_BIGINT = -5;
SQL_TINYINT = -6;
SQL_BIT = -7;
SQL_WCHAR = -8;
SQL_WVARCHAR = -9;
SQL_WLONGVARCHAR = -10;
SQL_GUID = -11;
// One-parameter shortcuts for date/time data types
SQL_TYPE_DATE = 91;
SQL_TYPE_TIME = 92;
SQL_TYPE_TIMESTAMP = 93;
// C datatype to SQL datatype mapping
SQL_C_CHAR = SQL_CHAR;
SQL_C_WCHAR = SQL_WCHAR;
SQL_C_LONG = SQL_INTEGER;
SQL_C_SHORT = SQL_SMALLINT;
SQL_C_FLOAT = SQL_REAL;
SQL_C_DOUBLE = SQL_DOUBLE;
SQL_C_NUMERIC = SQL_NUMERIC;
SQL_C_DEFAULT = 99;
SQL_SIGNED_OFFSET = (-20);
SQL_UNSIGNED_OFFSET = (-22);
SQL_C_DATE = SQL_DATE;
SQL_C_TIME = SQL_TIME;
SQL_C_TIMESTAMP = SQL_TIMESTAMP;
SQL_C_TYPE_DATE = SQL_TYPE_DATE;
SQL_C_TYPE_TIME = SQL_TYPE_TIME;
SQL_C_TYPE_TIMESTAMP = SQL_TYPE_TIMESTAMP;
SQL_C_BINARY = SQL_BINARY;
SQL_C_BIT = SQL_BIT;
SQL_C_SBIGINT = (SQL_BIGINT+SQL_SIGNED_OFFSET);
SQL_C_UBIGINT = (SQL_BIGINT+SQL_UNSIGNED_OFFSET);
SQL_C_TINYINT = SQL_TINYINT;
SQL_C_SLONG = (SQL_C_LONG+SQL_SIGNED_OFFSET);
SQL_C_SSHORT = (SQL_C_SHORT+SQL_SIGNED_OFFSET);
SQL_C_STINYINT = (SQL_TINYINT+SQL_SIGNED_OFFSET);
SQL_C_ULONG = (SQL_C_LONG+SQL_UNSIGNED_OFFSET);
SQL_C_USHORT = (SQL_C_SHORT+SQL_UNSIGNED_OFFSET);
SQL_C_UTINYINT = (SQL_TINYINT+SQL_UNSIGNED_OFFSET);
// Statement attribute values for cursor sensitivity
SQL_UNSPECIFIED = 0;
SQL_INSENSITIVE = 1;
SQL_SENSITIVE = 2;
// GetTypeInfo() request for all data types
SQL_ALL_TYPES = 0;
// Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData()
SQL_DEFAULT = 99;
// SQLSQLLEN GetData() code indicating that the application row descriptor
// specifies the data type
SQL_ARD_TYPE = (-99);
SQL_APD_TYPE = (-100);
// SQL date/time type subcodes
SQL_CODE_DATE = 1;
SQL_CODE_TIME = 2;
SQL_CODE_TIMESTAMP = 3;
// CLI option values
SQL_FALSE = 0;
SQL_TRUE = 1;
// values of NULLABLE field in descriptor
SQL_NO_NULLS = 0;
SQL_NULLABLE = 1;
// Value returned by SQLGetTypeInfo() to denote that it is
// not known whether or not a data type supports null values.
SQL_NULLABLE_UNKNOWN = 2;
// Values returned by SQLGetTypeInfo() to show WHERE clause supported
SQL_PRED_NONE = 0;
SQL_PRED_CHAR = 1;
SQL_PRED_BASIC = 2;
// values of UNNAMED field in descriptor
SQL_NAMED = 0;
SQL_UNNAMED = 1;
// values of ALLOC_TYPE field in descriptor
SQL_DESC_ALLOC_AUTO = 1;
SQL_DESC_ALLOC_USER = 2;
// FreeStmt() options
SQL_CLOSE = 0;
SQL_DROP = 1;
SQL_UNBIND = 2;
SQL_RESET_PARAMS = 3;
// Codes used for FetchOrientation in SQLFetchScroll() and SQLDataSources()
SQL_FETCH_NEXT = 1;
SQL_FETCH_FIRST = 2;
// Other codes used for FetchOrientation in SQLFetchScroll()
SQL_FETCH_LAST = 3;
SQL_FETCH_PRIOR = 4;
SQL_FETCH_ABSOLUTE = 5;
SQL_FETCH_RELATIVE = 6;
// SQLEndTran() options
SQL_COMMIT = 0;
SQL_ROLLBACK = 1;
// null handles returned by SQLAllocHandle()
SQL_NULL_HENV = 0;
SQL_NULL_HDBC = 0;
SQL_NULL_HSTMT = 0;
SQL_NULL_HDESC = 0;
// null handle used in place of parent handle when allocating HENV
SQL_NULL_HANDLE = nil;
// Information requested by SQLGetInfo()
SQL_MAX_DRIVER_CONNECTIONS = 0;
SQL_MAXIMUM_DRIVER_CONNECTIONS = SQL_MAX_DRIVER_CONNECTIONS;
SQL_MAX_CONCURRENT_ACTIVITIES = 1;
SQL_MAXIMUM_CONCURRENT_ACTIVITIES = SQL_MAX_CONCURRENT_ACTIVITIES;
SQL_DATA_SOURCE_NAME = 2;
SQL_FETCH_DIRECTION = 8;
SQL_SERVER_NAME = 13;
SQL_SEARCH_PATTERN_ESCAPE = 14;
SQL_DRIVER_NAME = 6;
SQL_DBMS_NAME = 17;
SQL_DBMS_VER = 18;
SQL_ACCESSIBLE_TABLES = 19;
SQL_ACCESSIBLE_PROCEDURES = 20;
SQL_CURSOR_COMMIT_BEHAVIOR = 23;
SQL_DATA_SOURCE_READ_ONLY = 25;
SQL_DEFAULT_TXN_ISOLATION = 26;
SQL_IDENTIFIER_CASE = 28;
SQL_IDENTIFIER_QUOTE_CHAR = 29;
SQL_MAX_COLUMN_NAME_LEN = 30;
SQL_MAXIMUM_COLUMN_NAME_LENGTH = SQL_MAX_COLUMN_NAME_LEN;
SQL_MAX_CURSOR_NAME_LEN = 31;
SQL_MAXIMUM_CURSOR_NAME_LENGTH = SQL_MAX_CURSOR_NAME_LEN;
SQL_MAX_SCHEMA_NAME_LEN = 32;
SQL_MAXIMUM_SCHEMA_NAME_LENGTH = SQL_MAX_SCHEMA_NAME_LEN;
SQL_MAX_CATALOG_NAME_LEN = 34;
SQL_MAXIMUM_CATALOG_NAME_LENGTH = SQL_MAX_CATALOG_NAME_LEN;
SQL_MAX_TABLE_NAME_LEN = 35;
SQL_SCROLL_CONCURRENCY = 43;
SQL_TXN_CAPABLE = 46;
SQL_TRANSACTION_CAPABLE = SQL_TXN_CAPABLE;
SQL_USER_NAME = 47;
SQL_TXN_ISOLATION_OPTION = 72;
SQL_TRANSACTION_ISOLATION_OPTION = SQL_TXN_ISOLATION_OPTION;
SQL_INTEGRITY = 73;
SQL_GETDATA_EXTENSIONS = 81;
SQL_NULL_COLLATION = 85;
SQL_ALTER_TABLE = 86;
SQL_ORDER_BY_COLUMNS_IN_SELECT = 90;
SQL_SPECIAL_CHARACTERS = 94;
SQL_MAX_COLUMNS_IN_GROUP_BY = 97;
SQL_MAXIMUM_COLUMNS_IN_GROUP_BY = SQL_MAX_COLUMNS_IN_GROUP_BY;
SQL_MAX_COLUMNS_IN_INDEX = 98;
SQL_MAXIMUM_COLUMNS_IN_INDEX = SQL_MAX_COLUMNS_IN_INDEX;
SQL_MAX_COLUMNS_IN_ORDER_BY = 99;
SQL_MAXIMUM_COLUMNS_IN_ORDER_BY = SQL_MAX_COLUMNS_IN_ORDER_BY;
SQL_MAX_COLUMNS_IN_SELECT = 100;
SQL_MAXIMUM_COLUMNS_IN_SELECT = SQL_MAX_COLUMNS_IN_SELECT;
SQL_MAX_COLUMNS_IN_TABLE = 101;
SQL_MAX_INDEX_SIZE = 102;
SQL_MAXIMUM_INDEX_SIZE = SQL_MAX_INDEX_SIZE;
SQL_MAX_ROW_SIZE = 104;
SQL_MAXIMUM_ROW_SIZE = SQL_MAX_ROW_SIZE;
SQL_MAX_STATEMENT_LEN = 105;
SQL_MAXIMUM_STATEMENT_LENGTH = SQL_MAX_STATEMENT_LEN;
SQL_MAX_TABLES_IN_SELECT = 106;
SQL_MAXIMUM_TABLES_IN_SELECT = SQL_MAX_TABLES_IN_SELECT;
SQL_MAX_USER_NAME_LEN = 107;
SQL_MAXIMUM_USER_NAME_LENGTH = SQL_MAX_USER_NAME_LEN;
SQL_OJ_CAPABILITIES = 115;
SQL_OUTER_JOIN_CAPABILITIES = SQL_OJ_CAPABILITIES;
// Options for SQLDriverConnect
SQL_DRIVER_NOPROMPT = 0;
SQL_DRIVER_COMPLETE = 1;
SQL_DRIVER_PROMPT = 2;
SQL_DRIVER_COMPLETE_REQUIRED = 3;
type
SqlSmallint = Smallint;
SqlDate = Byte;
SqlTime = Byte;
SqlDecimal = Byte;
SqlDouble = Double;
SqlFloat = Double;
SqlInteger = integer;
SqlUInteger = cardinal;
SqlNumeric = Byte;
SqlPointer = Pointer;
SqlReal = Single;
SqlUSmallint = Word;
SqlTimestamp = Byte;
SqlVarchar = Byte;
PSqlSmallint = ^SqlSmallint;
PSqlInteger = ^SqlInteger;
SqlReturn = SqlSmallint;
SqlLen = PtrInt;
SqlULen = PtrUInt;
{$ifdef CPU64}
SqlSetPosIRow = PtrUInt;
{$else}
SqlSetPosIRow = Word;
{$endif}
PSqlLen = ^SqlLen;
SqlHandle = Pointer;
SqlHEnv = SqlHandle;
SqlHDbc = SqlHandle;
SqlHStmt = SqlHandle;
SqlHDesc = SqlHandle;
SqlHWnd = LongWord;
{$A-}
/// memory structure used to store SQL_C_TYPE_TIMESTAMP values
SQL_TIMESTAMP_STRUCT = {$ifndef UNICODE}object{$else}record{$endif}
Year: SqlSmallint;
Month: SqlUSmallint;
Day: SqlUSmallint;
Hour: SqlUSmallint;
Minute: SqlUSmallint;
Second: SqlUSmallint;
Fraction: SqlUInteger;
/// convert an ODBC date and time into Delphi TDateTime
// - depending on the original column data type specified, it will return
// either a TDate (for SQL_TYPE_DATE), either a TTime (for SQL_TYPE_TIME),
// either a TDateTime content (for SQL_TYPE_TIMESTAMP)
function ToDateTime(DataType: SqlSmallint=SQL_TYPE_TIMESTAMP): TDateTime;
/// convert an ODBC date and time into its textual expanded ISO-8601
// - will fill up to 21 characters, including double quotes
// - depending on the column data type specified, it will return either an
// ISO-8601 date (for SQL_TYPE_DATE), either a time (for SQL_TYPE_TIME),
// either a full date+time ISO-8601 content (for SQL_TYPE_TIMESTAMP)
function ToIso8601(Dest: PUTF8Char; DataType: SqlSmallint): integer;
/// convert a TDateTime into ODBC date or timestamp
// - returns the corresponding C type, i.e. either SQL_C_TYPE_DATE,
// either SQL_C_TYPE_TIMESTAMP and the corresponding size in bytes
function From(DateTime: TDateTime; var ColumnSize: SqlULen): SqlSmallint;
end;
SQL_TIME_STRUCT = record
Hour: SqlUSmallint;
Minute: SqlUSmallint;
Second: SqlUSmallint;
end;
SQL_DATE_STRUCT = record
year: SQLSMALLINT;
month: SQLUSMALLINT;
day: SQLUSMALLINT;
end;
{$A+}
PSQL_TIMESTAMP_STRUCT = ^SQL_TIMESTAMP_STRUCT;
/// direct access to the ODBC library
// - this wrapper will initialize both Ansi and Wide versions of the ODBC
// driver functions, and will work with 32 bit and 64 bit version of the
// interfaces, on Windows or POSIX platforms
// - within this unit, we will only use Wide version, and UTF-8 conversion
TODBCLib = class(TSQLDBLib)
public
AllocEnv: function (var EnvironmentHandle: SqlHEnv): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
AllocHandle: function(HandleType: SqlSmallint; InputHandle: SqlHandle;
var OutputHandle: SqlHandle): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
AllocStmt: function(ConnectionHandle: SqlHDbc; var StatementHandle: SqlHStmt): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
BindCol: function(StatementHandle: SqlHStmt; ColumnNumber: SqlUSmallint;
TargetType: SqlSmallint; TargetValue: SqlPointer;
BufferLength: SqlLen; StrLen_or_Ind: PSqlLen): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
BindParameter: function (StatementHandle: SqlHStmt; ParameterNumber: SqlUSmallint;
InputOutputType, ValueType, ParameterType: SqlSmallint; ColumnSize: SqlULen;
DecimalDigits: SqlSmallint; ParameterValue: SqlPointer; BufferLength: SqlLen;
var StrLen_or_Ind: SqlLen): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
Cancel: function(StatementHandle: SqlHStmt): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
CloseCursor: function(StatementHandle: SqlHStmt): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ColAttributeA: function(StatementHandle: SqlHStmt; ColumnNumber: SqlUSmallint;
FieldIdentifier: SqlUSmallint; CharacterAttribute: PAnsiChar;
BufferLength: SqlSmallint; StringLength: PSqlSmallint; NumericAttributePtr: PSqlLen): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ColAttributeW: function(StatementHandle: SqlHStmt; ColumnNumber: SqlUSmallint;
FieldIdentifier: SqlUSmallint; CharacterAttribute: PWideChar;
BufferLength: SqlSmallint; StringLength: PSqlSmallint; NumericAttributePtr: PSqlLen): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ColumnsA: function(StatementHandle: SqlHStmt;
CatalogName: PAnsiChar; NameLength1: SqlSmallint;
SchemaName: PAnsiChar; NameLength2: SqlSmallint;
TableName: PAnsiChar; NameLength3: SqlSmallint;
ColumnName: PAnsiChar; NameLength4: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ColumnsW: function(StatementHandle: SqlHStmt;
CatalogName: PWideChar; NameLength1: SqlSmallint;
SchemaName: PWideChar; NameLength2: SqlSmallint;
TableName: PWideChar; NameLength3: SqlSmallint;
ColumnName: PWideChar; NameLength4: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
StatisticsA: function(StatementHandle: SqlHStmt;
CatalogName: PAnsiChar; NameLength1: SqlSmallint;
SchemaName: PAnsiChar; NameLength2: SqlSmallint;
TableName: PAnsiChar; NameLength3: SqlSmallint;
Unique, Reserved: SqlUSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
StatisticsW: function(StatementHandle: SqlHStmt;
CatalogName: PWideChar; NameLength1: SqlSmallint;
SchemaName: PWideChar; NameLength2: SqlSmallint;
TableName: PWideChar; NameLength3: SqlSmallint;
Unique, Reserved: SqlUSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ConnectA: function(ConnectionHandle: SqlHDbc;
ServerName: PAnsiChar; NameLength1: SqlSmallint;
UserName: PAnsiChar; NameLength2: SqlSmallint;
Authentication: PAnsiChar; NameLength3: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ConnectW: function(ConnectionHandle: SqlHDbc;
ServerName: PWideChar; NameLength1: SqlSmallint;
UserName: PWideChar; NameLength2: SqlSmallint;
Authentication: PWideChar; NameLength3: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
CopyDesc: function(SourceDescHandle, TargetDescHandle: SqlHDesc): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
DataSourcesA: function(EnvironmentHandle: SqlHEnv; Direction: SqlUSmallint;
ServerName: PAnsiChar; BufferLength1: SqlSmallint; var NameLength1: SqlSmallint;
Description: PAnsiChar; BufferLength2: SqlSmallint; var NameLength2: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
DataSourcesW: function(EnvironmentHandle: SqlHEnv; Direction: SqlUSmallint;
ServerName: PWideChar; BufferLength1: SqlSmallint; var NameLength1: SqlSmallint;
Description: PWideChar; BufferLength2: SqlSmallint; var NameLength2: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
DescribeColA: function(StatementHandle: SqlHStmt; ColumnNumber: SqlUSmallint;
ColumnName: PAnsiChar; BufferLength: SqlSmallint; var NameLength: SqlSmallint;
var DataType: SqlSmallint; var ColumnSize: SqlULen; var DecimalDigits: SqlSmallint;
var Nullable: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
DescribeColW: function(StatementHandle: SqlHStmt; ColumnNumber: SqlUSmallint;
ColumnName: PWideChar; BufferLength: SqlSmallint; var NameLength: SqlSmallint;
var DataType: SqlSmallint; var ColumnSize: SqlULen; var DecimalDigits: SqlSmallint;
var Nullable: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
Disconnect: function(ConnectionHandle: SqlHDbc): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
EndTran: function(HandleType: SqlSmallint; Handle: SqlHandle;
CompletionType: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ErrorA: function(EnvironmentHandle: SqlHEnv; ConnectionHandle: SqlHDbc; StatementHandle: SqlHStmt;
Sqlstate: PAnsiChar; var NativeError: SqlInteger;
MessageText: PAnsiChar; BufferLength: SqlSmallint; var TextLength: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ErrorW: function(EnvironmentHandle: SqlHEnv; ConnectionHandle: SqlHDbc; StatementHandle: SqlHStmt;
Sqlstate: PWideChar; var NativeError: SqlInteger;
MessageText: PWideChar; BufferLength: SqlSmallint; var TextLength: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ExecDirectA: function(StatementHandle: SqlHStmt;
StatementText: PAnsiChar; TextLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ExecDirectW: function(StatementHandle: SqlHStmt;
StatementText: PWideChar; TextLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
Execute: function(StatementHandle: SqlHStmt): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
Fetch: function(StatementHandle: SqlHStmt): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
FetchScroll: function(StatementHandle: SqlHStmt;
FetchOrientation: SqlSmallint; FetchOffset: SqlLen): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
FreeConnect: function(ConnectionHandle: SqlHDbc): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
FreeEnv: function(EnvironmentHandle: SqlHEnv): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
FreeHandle: function(HandleType: SqlSmallint; Handle: SqlHandle): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
FreeStmt: function(StatementHandle: SqlHStmt; Option: SqlUSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetConnectAttrA: function(ConnectionHandle: SqlHDbc; Attribute: SqlInteger;
ValuePtr: SqlPointer; BufferLength: SqlInteger; pStringLength: pSqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetConnectAttrW: function(ConnectionHandle: SqlHDbc; Attribute: SqlInteger;
ValuePtr: SqlPointer; BufferLength: SqlInteger; pStringLength: pSqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetCursorNameA: function(StatementHandle: SqlHStmt;
CursorName: PAnsiChar; BufferLength: SqlSmallint; var NameLength: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetCursorNameW: function(StatementHandle: SqlHStmt;
CursorName: PWideChar; BufferLength: SqlSmallint; var NameLength: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetData: function(StatementHandle: SqlHStmt; ColumnNumber: SqlUSmallint;
TargetType: SqlSmallint; TargetValue: SqlPointer; BufferLength: SqlLen;
StrLen_or_Ind: PSqlLen): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetDescFieldA: function(DescriptorHandle: SqlHDesc; RecNumber: SqlSmallint;
FieldIdentifier: SqlSmallint; Value: SqlPointer; BufferLength: SqlInteger;
var StringLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetDescFieldW: function(DescriptorHandle: SqlHDesc; RecNumber: SqlSmallint;
FieldIdentifier: SqlSmallint; Value: SqlPointer; BufferLength: SqlInteger;
var StringLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetDescRecA: function(DescriptorHandle: SqlHDesc; RecNumber: SqlSmallint;
Name: PAnsiChar; BufferLength: SqlSmallint; var StringLength: SqlSmallint;
var _Type, SubType: SqlSmallint; var Length: SqlLen;
var Precision, Scale, Nullable: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetDescRecW: function(DescriptorHandle: SqlHDesc; RecNumber: SqlSmallint;
Name: PWideChar; BufferLength: SqlSmallint; var StringLength: SqlSmallint;
var _Type, SubType: SqlSmallint; var Length: SqlLen;
var Precision, Scale, Nullable: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetDiagFieldA: function(HandleType: SqlSmallint; Handle: SqlHandle;
RecNumber, DiagIdentifier: SqlSmallint;
DiagInfo: SqlPointer; BufferLength: SqlSmallint; var StringLength: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetDiagFieldW: function(HandleType: SqlSmallint; Handle: SqlHandle;
RecNumber, DiagIdentifier: SqlSmallint;
DiagInfo: SqlPointer; BufferLength: SqlSmallint; var StringLength: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetDiagRecA: function(HandleType: SqlSmallint; Handle: SqlHandle; RecNumber: SqlSmallint;
Sqlstate: PAnsiChar; var NativeError: SqlInteger;
MessageText: PAnsiChar; BufferLength: SqlSmallint; var TextLength: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetDiagRecW: function(HandleType: SqlSmallint; Handle: SqlHandle; RecNumber: SqlSmallint;
Sqlstate: PWideChar; var NativeError: SqlInteger;
MessageText: PWideChar; BufferLength: SqlSmallint; var TextLength: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
MoreResults: function(StatementHandle: SqlHStmt): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
PrepareA: function(StatementHandle: SqlHStmt;
StatementText: PAnsiChar; TextLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
PrepareW: function(StatementHandle: SqlHStmt;
StatementText: PWideChar; TextLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
RowCount: function(StatementHandle: SqlHStmt; var RowCount: SqlLen): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
NumResultCols: function(StatementHandle: SqlHStmt; var ColumnCount: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetInfoA: function(ConnectionHandle: SqlHDbc; InfoType: SqlUSmallint;
InfoValuePtr: SqlPointer; BufferLength: SqlSmallint; StringLengthPtr: PSqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
GetInfoW: function(ConnectionHandle: SqlHDbc; InfoType: SqlUSmallint;
InfoValuePtr: SqlPointer; BufferLength: SqlSmallint; StringLengthPtr: PSqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SetStmtAttrA: function(StatementHandle: SqlHStmt; Attribute: SqlInteger;
Value: SqlPointer; StringLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SetStmtAttrW: function(StatementHandle: SqlHStmt; Attribute: SqlInteger;
Value: SqlPointer; StringLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SetEnvAttr: function(EnvironmentHandle: SqlHEnv; Attribute: SqlInteger;
ValuePtr: SqlPointer; StringLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SetConnectAttrA: function(ConnectionHandle: SqlHDbc; Attribute: SqlInteger;
ValuePtr: SqlPointer; StringLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SetConnectAttrW: function(ConnectionHandle: SqlHDbc; Attribute: SqlInteger;
ValuePtr: SqlPointer; StringLength: SqlInteger): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
TablesA: function(StatementHandle: SqlHStmt;
CatalogName: PAnsiChar; NameLength1: SqlSmallint;
SchemaName: PAnsiChar; NameLength2: SqlSmallint;
TableName: PAnsiChar; NameLength3: SqlSmallint;
TableType: PAnsiChar; NameLength4: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
TablesW: function(StatementHandle: SqlHStmt;
CatalogName: PWideChar; NameLength1: SqlSmallint;
SchemaName: PWideChar; NameLength2: SqlSmallint;
TableName: PWideChar; NameLength3: SqlSmallint;
TableType: PWideChar; NameLength4: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ForeignKeysA: function(StatementHandle: SqlHStmt;
PKCatalogName: PAnsiChar; NameLength1: SqlSmallint;
PKSchemaName: PAnsiChar; NameLength2: SqlSmallint;
PKTableName: PAnsiChar; NameLength3: SqlSmallint;
FKCatalogName: PAnsiChar; NameLength4: SqlSmallint;
FKSchemaName: PAnsiChar; NameLength5: SqlSmallint;
FKTableName: PAnsiChar; NameLength6: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
ForeignKeysW: function(StatementHandle: SqlHStmt;
PKCatalogName: PWideChar; NameLength1: SqlSmallint;
PKSchemaName: PWideChar; NameLength2: SqlSmallint;
PKTableName: PWideChar; NameLength3: SqlSmallint;
FKCatalogName: PWideChar; NameLength4: SqlSmallint;
FKSchemaName: PWideChar; NameLength5: SqlSmallint;
FKTableName: PWideChar; NameLength6: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SQLDriverConnectA: function(ConnectionHandle: SqlHDbc; WindowHandle: SQLHWnd;
InConnectionString: PAnsiChar; StringLength1: SqlSmallint;
OutConnectionString: PAnsiChar; BufferLength: SqlSmallint;
var StringLength2Ptr: SqlSmallint; DriverCompletion: SqlUSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SQLDriverConnectW: function(ConnectionHandle: SqlHDbc; WindowHandle: SQLHWnd;
InConnectionString: PWideChar; StringLength1: SqlSmallint;
OutConnectionString: PWideChar; BufferLength: SqlSmallint;
var StringLength2Ptr: SqlSmallint; DriverCompletion: SqlUSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SQLProcedureColumnsA: function(StatementHandle: SqlHStmt;
CatalogName: PAnsiChar; NameLength1: SqlSmallint;
SchemaName: PAnsiChar; NameLength2: SqlSmallint;
ProcName: PAnsiChar; NameLength3: SqlSmallint;
ColumnName: PAnsiChar; NameLength4: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SQLProcedureColumnsW: function(StatementHandle: SqlHStmt;
CatalogName: PWideChar; NameLength1: SqlSmallint;
SchemaName: PWideChar; NameLength2: SqlSmallint;
ProcName: PWideChar; NameLength3: SqlSmallint;
ColumnName: PWideChar; NameLength4: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};
SQLProcedures: function(StatementHandle: SqlHStmt;
CatalogName: PWideChar; NameLength1: SqlSmallint;
SchemaName: PWideChar; NameLength2: SqlSmallint;
ProcName: PWideChar; NameLength3: SqlSmallint): SqlReturn;
{$ifdef MSWINDOWS} stdcall {$else} cdecl {$endif};