-
Notifications
You must be signed in to change notification settings - Fork 12
/
Main.cpp
1296 lines (1018 loc) · 33.9 KB
/
Main.cpp
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
/*
*
* The contents of this file are subject to the Initial
* Developer's Public License Version 1.0 (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.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl.
*
* 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 was created by James A. Starkey for IBPhoenix.
*
* Copyright (c) 1999, 2000, 2001 James A. Starkey
* All Rights Reserved.
*
*
*
* 2003-03-24 main.cpp
* Contributed by Roger Gammans
* Fix SQLError prototype to match the prototype
* in the sql.h header file. This stops g++
* generating SQLError as a C++ name-mangled
* entry point. A C function entry is used
* allowing correct binding to the driver manager.
*
* 2002-10-11 main.cpp
* Contributed by C G Alvarez
* Implement SQLNumParams()
*
* 2002-10-11 main.cpp
* Contributed by C G Alvarez
* Implement SQLTablePrivileges()
*
* 2002-10-11 main.cpp
* Contributed by C G Alvarez
* Implement SQLColumnPrivileges()
*
* 2002-10-11 main.cpp
* Contributed by C G Alvarez
* Implement SQLGetDescField()
*
* 2002-08-02 main.cpp
* Contributed by C G Alvarez
* Implement SQLGetEnvAttr()
*
*
* 2002-07-02 main.cpp
* Contributed by C G Alvarez
* Mapped calls to SQLGetConnectOption to SQLGetConnectAttr
* Mapped calls SQLGetStmtOption to SQLGetStmtAttr
* Mapped calls SQLSetStmtOption to SQLSetStmtAttr
*
* 2002-04-30 main.cpp
* Added suggestions by Carlos G Alvarez
* o Test for logfile before trying to close it.
* o Changed parameter types for SQLSetConnectOption
*
*/
#ifdef _WINDOWS
#include <windows.h>
#endif
#include <stdio.h>
#include <locale.h>
#include "OdbcJdbc.h"
#include "OdbcEnv.h"
#include "OdbcConnection.h"
#include "OdbcStatement.h"
#include "SafeEnvThread.h"
#include "Main.h"
#ifdef LOGGING
FILE *logFile = NULL;
void logMsg (const char *msg)
{
if (!logFile)
logFile = fopen( LOG_FILE, "a+" );
if (!logFile)
OutputDebugString ("log file create failed\n");
else
{
fputs (msg, logFile);
OutputDebugString (msg);
}
}
#endif
void notYetImplemented (const char *msg)
{
LOG_MSG (msg);
}
void trace (const char *msg)
{
LOG_MSG(msg);
}
using namespace OdbcJdbcLibrary;
#ifdef _WINDOWS
HINSTANCE m_hInstance = NULL;
UINT codePage = CP_ACP;
namespace OdbcJdbcLibrary {
#if _MSC_VER > 1000
void clearAtlResource();
#endif // _MSC_VER > 1000
void initCodePageTranslate( int userLCID );
};
BOOL APIENTRY DllMainSetup( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID );
BOOL APIENTRY DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
{
if ( fdwReason == DLL_PROCESS_ATTACH )
{
m_hInstance = hinstDLL;
codePage = GetACP();
initCodePageTranslate( GetUserDefaultLCID() );
setlocale( LC_ALL, ".ACP" );
}
else if ( fdwReason == DLL_PROCESS_DETACH )
{
#if _MSC_VER > 1000
clearAtlResource();
#endif // _MSC_VER > 1000
}
DllMainSetup( hinstDLL, fdwReason, lpvReserved );
return TRUE;
}
#endif
static SQLRETURN __SQLAllocHandle( SQLSMALLINT handleType, SQLHANDLE inputHandle,
SQLHANDLE *outputHandle )
{
TRACE ("__SQLAllocHandle");
if ( handleType == SQL_HANDLE_ENV )
{
if ( inputHandle != SQL_NULL_HANDLE || outputHandle == NULL)
return SQL_ERROR;
*outputHandle = (SQLHANDLE)new OdbcEnv;
return SQL_SUCCESS;
}
OdbcObject *object = (OdbcObject*)inputHandle;
if ( outputHandle == NULL )
return object->sqlReturn (SQL_ERROR, "HY009", "Invalid use of null pointer");
return object->allocHandle( handleType, outputHandle );
}
///// SQLAllocConnect ///// ODBC 1.0 ///// Deprecated
SQLRETURN SQL_API SQLAllocConnect( SQLHENV hEnv, SQLHDBC *hDbc )
{
TRACE ("SQLAllocConnect");
GUARD_ENV( hEnv );
return __SQLAllocHandle( SQL_HANDLE_DBC, hEnv, hDbc );
}
///// SQLAllocEnv ///// ODBC 1.0 ///// Deprecated
SQLRETURN SQL_API SQLAllocEnv( SQLHENV *hEnv )
{
TRACE ("SQLAllocEnv");
GUARD;
return __SQLAllocHandle( SQL_HANDLE_ENV, SQL_NULL_HANDLE, hEnv );
}
///// SQLAllocStmt ///// ODBC 1.0 ///// Deprecated
SQLRETURN SQL_API SQLAllocStmt( SQLHDBC hDbc, SQLHSTMT *hStmt )
{
TRACE ("SQLAllocStmt");
GUARD_HDBC( hDbc );
return __SQLAllocHandle( SQL_HANDLE_STMT, hDbc, hStmt );
}
///// SQLBindCol ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLBindCol( SQLHSTMT hStmt, SQLUSMALLINT columnNumber,
SQLSMALLINT targetType, SQLPOINTER targetValue,
SQLLEN bufferLength, SQLLEN *strLen_or_Ind )
{
TRACE ("SQLBindCol");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlBindCol( columnNumber, targetType, targetValue,
bufferLength, strLen_or_Ind );
}
///// SQLCancel ///// ODBC 1.0 ///// Deprecated
SQLRETURN SQL_API SQLCancel( SQLHSTMT hStmt )
{
TRACE ("SQLCancel");
return ((OdbcStatement*) hStmt)->sqlCancel();
}
///// SQLColAttributes ///// ODBC 1.0 ///// Deprecated
SQLRETURN SQL_API SQLColAttributes( SQLHSTMT hStmt, SQLUSMALLINT columnNumber,
SQLUSMALLINT fieldIdentifier, SQLPOINTER characterAttribute,
SQLSMALLINT bufferLength, SQLSMALLINT *stringLength,
SQLLEN *numericAttribute )
{
TRACE("SQLColAttributes");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlColAttribute( columnNumber, fieldIdentifier,
characterAttribute, bufferLength,
stringLength, numericAttribute );
}
///// SQLConnect ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLConnect( SQLHDBC hDbc,
SQLCHAR *serverName, SQLSMALLINT nameLength1,
SQLCHAR *userName, SQLSMALLINT nameLength2,
SQLCHAR *authentication, SQLSMALLINT nameLength3 )
{
TRACE ("SQLConnect");
GUARD_HDBC( hDbc );
SQLRETURN ret = ((OdbcConnection*) hDbc)->sqlConnect( serverName, nameLength1, userName,
nameLength2, authentication, nameLength3 );
LOG_PRINT(( logFile,
"SQLConnect : Line %d\n"
" +status : %d\n"
" +hDbc : %p\n"
" +serverName : %s\n"
" +userName : %s\n"
" +authentication : %s\n\n",
__LINE__,
ret,
hDbc,
serverName ? serverName : (SQLCHAR*)"",
userName ? userName : (SQLCHAR*)"",
authentication ? authentication : (SQLCHAR*)"" ));
return ret;
}
///// SQLDescribeCol ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLDescribeCol( SQLHSTMT hStmt, SQLUSMALLINT columnNumber,
SQLCHAR *columnName, SQLSMALLINT bufferLength,
SQLSMALLINT *nameLength, SQLSMALLINT *dataType,
SQLULEN *columnSize, SQLSMALLINT *decimalDigits,
SQLSMALLINT *nullable )
{
TRACE ("SQLDescribeCol");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlDescribeCol( columnNumber, columnName, bufferLength,
nameLength, dataType, columnSize, decimalDigits,
nullable );
}
///// SQLDisconnect ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLDisconnect( SQLHDBC hDbc )
{
TRACE ("SQLDisconnect");
GUARD_ENV( ((OdbcConnection*) hDbc)->env );
return ((OdbcConnection*) hDbc)->sqlDisconnect();
}
///// SQLError ///// ODBC 1.0 ///// Deprecated
SQLRETURN SQL_API SQLError( SQLHENV hEnv,
SQLHDBC hDbc, SQLHSTMT hStmt,
SQLCHAR *sqlState, SQLINTEGER *nativeErrorCode,
SQLCHAR *msgBuffer, SQLSMALLINT msgBufferLength,
SQLSMALLINT *msgLength )
{
TRACE("SQLError");
if ( hStmt )
{
GUARD_HSTMT( hStmt );
return ((OdbcStatement*)hStmt)->sqlError( sqlState, nativeErrorCode, msgBuffer,
msgBufferLength, msgLength );
}
if ( hDbc )
{
GUARD_HDBC( hDbc );
return ((OdbcConnection*)hDbc)->sqlError( sqlState, nativeErrorCode, msgBuffer,
msgBufferLength, msgLength );
}
if ( hEnv )
return ((OdbcEnv*)hEnv)->sqlError( sqlState, nativeErrorCode, msgBuffer,
msgBufferLength, msgLength );
return SQL_ERROR;
}
///// SQLExecDirect ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLExecDirect( SQLHSTMT hStmt, SQLCHAR *statementText, SQLINTEGER textLength )
{
TRACE ("SQLExecDirect");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlExecDirect( statementText, textLength );
}
///// SQLExecute ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLExecute( SQLHSTMT hStmt )
{
TRACE("SQLExecute");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlExecute();
}
///// SQLFetch ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLFetch( SQLHSTMT hStmt )
{
TRACE ("SQLFetch");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlFetch();
}
///// SQLFreeConnect ///// ODBC 1.0 ///// Deprecated
SQLRETURN SQL_API SQLFreeConnect( SQLHDBC hDbc )
{
TRACE ("SQLFreeconnect");
GUARD_HDBC( hDbc );
delete (OdbcConnection*) hDbc;
return SQL_SUCCESS;
}
///// SQLFreeEnv ///// ODBC 3.0 ///// ISO 92
SQLRETURN SQL_API SQLFreeEnv( SQLHENV hEnv )
{
TRACE ("SQLFreeEnv");
delete (OdbcEnv*) hEnv;
return SQL_SUCCESS;
}
///// SQLFreeStmt ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLFreeStmt( SQLHSTMT hStmt, SQLUSMALLINT option )
{
TRACE ("SQLFreeStmt");
GUARD_HSTMT( hStmt );
if ( option == SQL_DROP )
{
delete (OdbcStatement*) hStmt;
return SQL_SUCCESS;
}
return ((OdbcStatement*) hStmt)->sqlFreeStmt( option );
}
///// SQLGetCursorName ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLGetCursorName( SQLHSTMT hStmt, SQLCHAR *cursorName,
SQLSMALLINT bufferLength, SQLSMALLINT *nameLength )
{
TRACE ("SQLGetCursorName called\n");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlGetCursorName( cursorName, bufferLength, nameLength );
}
///// SQLNumResultCols ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLNumResultCols( SQLHSTMT hStmt, SQLSMALLINT *columnCount )
{
TRACE ("SQLNumResultCols");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlNumResultCols( columnCount );
}
///// SQLPrepare ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLPrepare( SQLHSTMT hStmt,
SQLCHAR *statementText, SQLINTEGER textLength )
{
TRACE ("SQLPrepare");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlPrepare( statementText, textLength );
}
///// SQLRowCount ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLRowCount( SQLHSTMT hStmt, SQLLEN* rowCount )
{
TRACE ("SQLRowCount");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlRowCount( rowCount );
}
///// SQLSetCursorName ///// ODBC 1.0 ///// ISO 92
SQLRETURN SQL_API SQLSetCursorName( SQLHSTMT hStmt, SQLCHAR *cursorName,
SQLSMALLINT nameLength )
{
TRACE ("SQLSetCursorName");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlSetCursorName( cursorName, nameLength );
}
///// SQLSetParam ///// Deprecated in 2.0
SQLRETURN SQL_API SQLSetParam( SQLHSTMT hStmt,
SQLUSMALLINT parameterNumber, SQLSMALLINT valueType,
SQLSMALLINT parameterType, SQLULEN lengthPrecision,
SQLSMALLINT parameterScale, SQLPOINTER parameterValue,
SQLLEN *strLen_or_Ind )
{
TRACE ("SQLSetParam");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlSetParam( parameterNumber, valueType,
parameterType, lengthPrecision,
parameterScale, parameterValue,
strLen_or_Ind );
}
///// SQLTransact /////
SQLRETURN SQL_API SQLTransact( SQLHENV hEnv, SQLHDBC hDbc,
SQLUSMALLINT completionType )
{
TRACE ("SQLTransact");
if ( hEnv == SQL_NULL_HENV )
{
GUARD_HDBC( hDbc );
return ((OdbcConnection*) hDbc)->sqlEndTran( completionType );
}
GUARD_ENV( hEnv );
return ((OdbcEnv*) hEnv)->sqlEndTran( completionType );
}
///// SQLColumns /////
SQLRETURN SQL_API SQLColumns( SQLHSTMT hStmt,
SQLCHAR *catalogName, SQLSMALLINT nameLength1,
SQLCHAR *schemaName, SQLSMALLINT nameLength2,
SQLCHAR *tableName, SQLSMALLINT nameLength3,
SQLCHAR *columnName, SQLSMALLINT nameLength4 )
{
TRACE ("SQLColumns");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlColumns( catalogName, nameLength1,
schemaName, nameLength2,
tableName, nameLength3,
columnName, nameLength4 );
}
///// SQLDriverConnect /////
SQLRETURN SQL_API SQLDriverConnect( SQLHDBC hDbc, SQLHWND hWnd, SQLCHAR *szConnStrIn,
SQLSMALLINT cbConnStrIn, SQLCHAR *szConnStrOut,
SQLSMALLINT cbConnStrOutMax, SQLSMALLINT *pcbConnStrOut,
SQLUSMALLINT fDriverCompletion )
{
TRACE ("SQLDriverConnect");
GUARD_HDBC( hDbc );
SQLRETURN ret = ((OdbcConnection*) hDbc)->sqlDriverConnect( hWnd, szConnStrIn, cbConnStrIn,
szConnStrOut, cbConnStrOutMax, pcbConnStrOut,
fDriverCompletion );
LOG_PRINT(( logFile,
"SQLDriverConnect : Line %d\n"
" +status : %d\n"
" +hDbc : %p\n"
" +szConnStrIn : %s\n"
" +szConnStrOut : %s\n\n",
__LINE__,
ret,
hDbc,
szConnStrIn ? szConnStrIn : (SQLCHAR*)"",
szConnStrOut ? szConnStrOut : (SQLCHAR*)"" ));
return ret;
}
///// SQLGetConnectOption ///// Level 1 ///// Deprecated
SQLRETURN SQL_API SQLGetConnectOption( SQLHDBC hDbc, SQLUSMALLINT option, SQLPOINTER value )
{
TRACE ("SQLGetConnectOption");
GUARD_HDBC( hDbc );
int bufferLength;
switch ( option )
{
case SQL_ATTR_CURRENT_CATALOG:
case SQL_ATTR_TRACEFILE:
case SQL_ATTR_TRANSLATE_LIB:
bufferLength = SQL_MAX_OPTION_STRING_LENGTH;
break;
default:
bufferLength = 0;
}
return ((OdbcConnection*) hDbc)->sqlGetConnectAttr( option, value, bufferLength, NULL);
}
///// SQLGetData /////
SQLRETURN SQL_API SQLGetData( SQLHSTMT hStmt, SQLUSMALLINT columnNumber,
SQLSMALLINT targetType, SQLPOINTER targetValue,
SQLLEN bufferLength, SQLLEN *strLen_or_Ind )
{
TRACE ("SQLGetData");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlGetData( columnNumber, targetType, targetValue,
bufferLength, strLen_or_Ind );
}
///// SQLGetFunctions /////
SQLRETURN SQL_API SQLGetFunctions( SQLHDBC hDbc, SQLUSMALLINT functionId,
SQLUSMALLINT *supported )
{
TRACE ("SQLGetFunctions");
GUARD_HDBC( hDbc );
return ((OdbcConnection*) hDbc)->sqlGetFunctions( functionId, supported );
}
///// SQLGetInfo /////
SQLRETURN SQL_API SQLGetInfo( SQLHDBC hDbc, SQLUSMALLINT infoType, SQLPOINTER infoValue,
SQLSMALLINT bufferLength, SQLSMALLINT *stringLength )
{
TRACE ("SQLGetInfo");
GUARD_HDBC( hDbc );
return ((OdbcConnection*) hDbc)->sqlGetInfo( infoType, infoValue,
bufferLength, stringLength );
}
///// SQLGetStmtOption ///// Level 1
SQLRETURN SQL_API SQLGetStmtOption( SQLHSTMT hStmt, SQLUSMALLINT option, SQLPOINTER value )
{
TRACE ("SQLGetStmtOption");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlGetStmtAttr( option, value, 0, NULL );
}
///// SQLGetTypeInfo /////
SQLRETURN SQL_API SQLGetTypeInfo( SQLHSTMT hStmt, SQLSMALLINT dataType )
{
TRACE ("SQLGetTypeInfo");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlGetTypeInfo( dataType );
}
///// SQLParamData /////
SQLRETURN SQL_API SQLParamData( SQLHSTMT hStmt, SQLPOINTER *value )
{
TRACE("SQLParamData");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlParamData( value );
}
///// SQLPutData /////
SQLRETURN SQL_API SQLPutData( SQLHSTMT hStmt, SQLPOINTER data, SQLLEN strLen_or_Ind )
{
TRACE ("SQLPutData");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlPutData( data, strLen_or_Ind );
}
///// SQLSetConnectOption ///// Level 1 ///// Deprecated
SQLRETURN SQL_API SQLSetConnectOption( SQLHDBC hDbc, SQLUSMALLINT option, SQLULEN value )
{
TRACE ("SQLSetConnectOption");
GUARD_HDBC( hDbc );
return ((OdbcConnection*) hDbc)->sqlSetConnectAttr( option, (SQLPOINTER)value, 0 );
}
///// SQLSetStmtOption ///// Deprecated
SQLRETURN SQL_API SQLSetStmtOption( SQLHSTMT hStmt, SQLUSMALLINT option, SQLULEN value )
{
TRACE ("SQLSetStmtOption");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlSetStmtAttr( option, (SQLPOINTER)value, 0);
}
///// SQLSpecialColumns /////
SQLRETURN SQL_API SQLSpecialColumns( SQLHSTMT hStmt, SQLUSMALLINT identifierType,
SQLCHAR *catalogName, SQLSMALLINT nameLength1,
SQLCHAR *schemaName, SQLSMALLINT nameLength2,
SQLCHAR *tableName, SQLSMALLINT nameLength3,
SQLUSMALLINT scope, SQLUSMALLINT nullable )
{
TRACE ("SQLSpecialColumns");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlSpecialColumns( identifierType,
catalogName, nameLength1,
schemaName, nameLength2,
tableName, nameLength3,
scope, nullable);
}
///// SQLStatistics /////
SQLRETURN SQL_API SQLStatistics( SQLHSTMT hStmt,
SQLCHAR *catalogName, SQLSMALLINT nameLength1,
SQLCHAR *schemaName, SQLSMALLINT nameLength2,
SQLCHAR *tableName, SQLSMALLINT nameLength3,
SQLUSMALLINT unique, SQLUSMALLINT reserved )
{
TRACE ("SQLStatistics");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlStatistics( catalogName, nameLength1,
schemaName, nameLength2,
tableName, nameLength3,
unique, reserved );
}
///// SQLTables /////
SQLRETURN SQL_API SQLTables( SQLHSTMT hStmt,
SQLCHAR *catalogName, SQLSMALLINT nameLength1,
SQLCHAR *schemaName, SQLSMALLINT nameLength2,
SQLCHAR *tableName, SQLSMALLINT nameLength3,
SQLCHAR *tableType, SQLSMALLINT nameLength4 )
{
TRACE ("SQLTables");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlTables( catalogName, nameLength1,
schemaName, nameLength2,
tableName, nameLength3,
tableType, nameLength4 );
}
///// SQLBrowseConnect /////
SQLRETURN SQL_API SQLBrowseConnect( SQLHDBC hDbc,
SQLCHAR *szConnStrIn, SQLSMALLINT cbConnStrIn,
SQLCHAR *szConnStrOut, SQLSMALLINT cbConnStrOutMax,
SQLSMALLINT *pcbConnStrOut )
{
TRACE ("SQLBrowseConnect");
GUARD_HDBC( hDbc );
return ((OdbcConnection*) hDbc)->sqlBrowseConnect( szConnStrIn, cbConnStrIn,
szConnStrOut, cbConnStrOutMax,
pcbConnStrOut );
}
///// SQLDataSources /////
SQLRETURN SQL_API SQLDataSources( SQLHENV hEnv,
SQLUSMALLINT direction, SQLCHAR *serverName,
SQLSMALLINT bufferLength1, SQLSMALLINT *nameLength1,
SQLCHAR *description, SQLSMALLINT bufferLength2,
SQLSMALLINT *nameLength2 )
{
TRACE ("SQLDataSources");
GUARD_ENV( hEnv );
return ((OdbcEnv*)hEnv)->sqlDataSources( direction, serverName,
bufferLength1, nameLength1, description,
bufferLength2, nameLength2 );
}
///// SQLDescribeParam /////
SQLRETURN SQL_API SQLDescribeParam( SQLHSTMT hStmt, SQLUSMALLINT iPar,
SQLSMALLINT *pfSqlType, SQLULEN *pcbParamDef,
SQLSMALLINT *pibScale, SQLSMALLINT *pfNullable )
{
TRACE("SQLDescribeParam");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlDescribeParam( iPar, pfSqlType, pcbParamDef,
pibScale, pfNullable );
}
///// SQLExtendedFetch /////
SQLRETURN SQL_API SQLExtendedFetch( SQLHSTMT hStmt, SQLUSMALLINT fFetchType,
SQLLEN iRow, SQLULEN *pcRow, SQLUSMALLINT *rgfRowStatus )
{
TRACE ("SQLExtendedFetch");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlExtendedFetch( fFetchType, iRow, pcRow, rgfRowStatus );
}
///// SQLForeignKeys /////
SQLRETURN SQL_API SQLForeignKeys( SQLHSTMT hStmt,
SQLCHAR *szPkCatalogName, SQLSMALLINT cbPkCatalogName,
SQLCHAR *szPkSchemaName, SQLSMALLINT cbPkSchemaName,
SQLCHAR *szPkTableName, SQLSMALLINT cbPkTableName,
SQLCHAR *szFkCatalogName, SQLSMALLINT cbFkCatalogName,
SQLCHAR *szFkSchemaName, SQLSMALLINT cbFkSchemaName,
SQLCHAR *szFkTableName, SQLSMALLINT cbFkTableName )
{
TRACE ("SQLForeignKeys");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlForeignKeys( szPkCatalogName, cbPkCatalogName,
szPkSchemaName, cbPkSchemaName,
szPkTableName, cbPkTableName,
szFkCatalogName, cbFkCatalogName,
szFkSchemaName, cbFkSchemaName,
szFkTableName, cbFkTableName );
}
///// SQLMoreResults /////
SQLRETURN SQL_API SQLMoreResults( SQLHSTMT hStmt )
{
TRACE("SQLMoreResults");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlMoreResults();
}
///// SQLNativeSql /////
SQLRETURN SQL_API SQLNativeSql( SQLHDBC hDbc,
SQLCHAR *szSqlStrIn, SQLINTEGER cbSqlStrIn,
SQLCHAR *szSqlStr, SQLINTEGER cbSqlStrMax,
SQLINTEGER *pcbSqlStr )
{
TRACE ("SQLNativeSql");
GUARD_HDBC( hDbc );
return ((OdbcConnection*) hDbc)->sqlNativeSql( szSqlStrIn, cbSqlStrIn,
szSqlStr, cbSqlStrMax, pcbSqlStr );
}
///// SQLNumParams /////
SQLRETURN SQL_API SQLNumParams( SQLHSTMT hStmt, SQLSMALLINT *pcPar )
{
TRACE("SQLMoreResults");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlNumParams( pcPar );
}
///// SQLParamOptions /////
SQLRETURN SQL_API SQLParamOptions( SQLHSTMT hStmt, SQLULEN cRow, SQLULEN *piRow )
{
TRACE("SQLParamOptions");
GUARD_HSTMT( hStmt );
((OdbcStatement*) hStmt)->sqlSetStmtAttr( SQL_ATTR_PARAMSET_SIZE, (SQLPOINTER)cRow, 0 );
((OdbcStatement*) hStmt)->sqlSetStmtAttr( SQL_ATTR_PARAMS_PROCESSED_PTR, (SQLPOINTER)piRow, 0 );
return SQL_SUCCESS;
}
///// SQLPrimaryKeys /////
SQLRETURN SQL_API SQLPrimaryKeys( SQLHSTMT hStmt,
SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName, SQLSMALLINT cbTableName )
{
TRACE ("SQLPrimaryKeys");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlPrimaryKeys( szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName,
szTableName, cbTableName );
}
///// SQLProcedureColumns /////
SQLRETURN SQL_API SQLProcedureColumns( SQLHSTMT hStmt,
SQLCHAR *szCatalogName,
SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName,
SQLSMALLINT cbSchemaName,
SQLCHAR *szProcName,
SQLSMALLINT cbProcName,
SQLCHAR *szColumnName,
SQLSMALLINT cbColumnName )
{
TRACE ("SQLProcedureColumns");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlProcedureColumns( szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName,
szProcName, cbProcName,
szColumnName, cbColumnName );
}
///// SQLProcedures /////
SQLRETURN SQL_API SQLProcedures( SQLHSTMT hStmt,
SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName,
SQLCHAR *szProcName, SQLSMALLINT cbProcName )
{
TRACE ("SQLProcedures");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlProcedures( szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName,
szProcName, cbProcName );
}
///// SQLSetPos /////
SQLRETURN SQL_API SQLSetPos( SQLHSTMT hStmt, SQLSETPOSIROW iRow,
SQLUSMALLINT fOption, SQLUSMALLINT fLock )
{
TRACE ("SQLSetPos");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlSetPos( iRow, fOption, fLock );
}
///// SQLSetScrollOptions /////
SQLRETURN SQL_API SQLSetScrollOptions( SQLHSTMT hStmt, SQLUSMALLINT fConcurrency,
SQLLEN crowKeyset, SQLUSMALLINT crowRowset)
{
TRACE ("SQLSetScrollOptions");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlSetScrollOptions( fConcurrency, crowKeyset, crowRowset );
}
///// SQLTablePrivileges /////
SQLRETURN SQL_API SQLTablePrivileges( SQLHSTMT hStmt,
SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName, SQLSMALLINT cbTableName )
{
TRACE ("SQLTablePrivileges");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlTablePrivileges( szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName,
szTableName, cbTableName );
}
///// SQLColumnPrivileges /////
SQLRETURN SQL_API SQLColumnPrivileges( SQLHSTMT hStmt,
SQLCHAR *szCatalogName, SQLSMALLINT cbCatalogName,
SQLCHAR *szSchemaName, SQLSMALLINT cbSchemaName,
SQLCHAR *szTableName, SQLSMALLINT cbTableName,
SQLCHAR *szColumnName, SQLSMALLINT cbColumnName )
{
TRACE ("SQLColumnPrivileges");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlColumnPrivileges( szCatalogName, cbCatalogName,
szSchemaName, cbSchemaName,
szTableName, cbTableName,
szColumnName, cbColumnName );
}
///// SQLDrivers /////
SQLRETURN SQL_API SQLDrivers( SQLHENV hEnv, SQLUSMALLINT fDirection,
SQLCHAR *szDriverDesc, SQLSMALLINT cbDriverDescMax,
SQLSMALLINT *pcbDriverDesc,
SQLCHAR *szDriverAttributes, SQLSMALLINT cbDrvrAttrMax,
SQLSMALLINT *pcbDrvrAttr )
{
TRACE ("SQLDrivers");
GUARD_ENV( hEnv );
return ((OdbcEnv*) hEnv)->sqlDrivers( fDirection, szDriverDesc, cbDriverDescMax,
pcbDriverDesc, szDriverAttributes, cbDrvrAttrMax,
pcbDrvrAttr );
}
///// SQLBindParameter /////
SQLRETURN SQL_API SQLBindParameter( SQLHSTMT hStmt, SQLUSMALLINT iPar, SQLSMALLINT fParamType,
SQLSMALLINT fCType, SQLSMALLINT fSqlType, SQLULEN cbColDef,
SQLSMALLINT ibScale, SQLPOINTER rgbValue, SQLLEN cbValueMax,
SQLLEN *pcbValue )
{
TRACE ("SQLBindParameter");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*) hStmt)->sqlBindParameter( iPar, fParamType, fCType, fSqlType,
cbColDef, ibScale, rgbValue, cbValueMax,
pcbValue );
}
///// SQLAllocHandle - global /////
SQLRETURN SQL_API SQLAllocHandle( SQLSMALLINT fHandleType, SQLHANDLE hInput, SQLHANDLE *phOutput )
{
TRACE ("SQLAllocHandle");
switch( fHandleType )
{
case SQL_HANDLE_ENV:
{
GUARD;
return __SQLAllocHandle( fHandleType, hInput, phOutput );
}
case SQL_HANDLE_DBC:
{
GUARD_ENV( hInput );
return __SQLAllocHandle( fHandleType, hInput, phOutput );
}
case SQL_HANDLE_STMT:
{
GUARD_HDBC( hInput );
return __SQLAllocHandle( fHandleType, hInput, phOutput );
}
case SQL_HANDLE_DESC:
{
GUARD_HDBC( hInput );
return __SQLAllocHandle( fHandleType, hInput, phOutput );
}
}
return SQL_INVALID_HANDLE;
}
///// SQLBindParam /////
SQLRETURN SQL_API SQLBindParam( SQLHSTMT hStmt, SQLUSMALLINT parameterNumber,
SQLSMALLINT valueType, SQLSMALLINT parameterType,
SQLULEN lengthPrecision, SQLSMALLINT parameterScale,
SQLPOINTER parameterValue, SQLLEN *strLen_or_Ind )
{
TRACE ("SQLBindParam");
GUARD_HSTMT( hStmt );
return ((OdbcStatement*)hStmt)->sqlBindParameter( parameterNumber, SQL_PARAM_INPUT,
valueType, parameterType, lengthPrecision, parameterScale,
parameterValue, SQL_SETPARAM_VALUE_MAX, strLen_or_Ind );
}
///// SQLCloseCursor /////