-
Notifications
You must be signed in to change notification settings - Fork 166
/
Copy pathsybdb.h
1337 lines (1210 loc) · 63.9 KB
/
sybdb.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
/* FreeTDS - Library of routines accessing Sybase and Microsoft databases
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Brian Bruns
* Copyright (C) 2010, 2011 Frediano Ziglio
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/** \file ../include/sybdb.h
* \brief Primary include file for db-lib applications.
*
* Declares macros, functions, enumerated types, and defined tokens
* used by the db-lib API.
*/
#ifndef _sybdb_h_
#define _sybdb_h_
#include "tds_sysdep_public.h"
#undef TDS_STATIC_CAST
#ifdef __cplusplus
#define TDS_STATIC_CAST(type, a) static_cast<type>(a)
extern "C"
{
#if 0
}
#endif
#else
#define TDS_STATIC_CAST(type, a) ((type)(a))
#endif
#ifdef FALSE
#undef FALSE
#endif
#ifdef TRUE
#undef TRUE
#endif
#define FALSE 0
#define TRUE 1
#define DBSAVE 1
#define DBNOSAVE 0
#define DBNOERR -1
#define INT_EXIT 0
#define INT_CONTINUE 1
#define INT_CANCEL 2
#define INT_TIMEOUT 3
#define DBMAXNUMLEN 33
/* https://msdn.microsoft.com/en-us/library/ms176061.aspx */
#define DBMAXNAME 128
/**
* DBVERSION_xxx are used with dbsetversion()
*/
#define DBVERSION_UNKNOWN 0
#define DBVERSION_46 1
#define DBVERSION_100 2
#define DBVERSION_42 3
#define DBVERSION_70 4
#define DBVERSION_71 5
#define DBVERSION_72 6
#define DBVERSION_73 7
#define DBVERSION_74 8
/* these two are defined by Microsoft for dbsetlversion() */
#define DBVER42 DBVERSION_42
#define DBVER60 DBVERSION_70 /* our best approximation */
/**
* DBTDS_xxx are returned by DBTDS()
* The integer values of the constants are poorly chosen.
*/
#define DBTDS_UNKNOWN 0
#define DBTDS_2_0 1 /* pre 4.0 SQL Server */
#define DBTDS_3_4 2 /* Microsoft SQL Server (3.0) */
#define DBTDS_4_0 3 /* 4.0 SQL Server */
#define DBTDS_4_2 4 /* 4.2 SQL Server */
#define DBTDS_4_6 5 /* 2.0 OpenServer and 4.6 SQL Server. */
#define DBTDS_4_9_5 6 /* 4.9.5 (NCR) SQL Server */
#define DBTDS_5_0 7 /* 5.0 SQL Server */
#define DBTDS_7_0 8 /* Microsoft SQL Server 7.0 */
#define DBTDS_8_0 ("Use DBTDS_7_1 instead"*x) /* Microsoft SQL Server 2000 */
#define DBTDS_9_0 ("Use DBTDS_7_2 instead"*x) /* Microsoft SQL Server 2005 */
#define DBTDS_7_1 9 /* Microsoft SQL Server 2000 */
#define DBTDS_7_2 10 /* Microsoft SQL Server 2005 */
#define DBTDS_7_3 11 /* Microsoft SQL Server 2008 */
#define DBTDS_7_4 12 /* Microsoft SQL Server 2012/2014 */
#define DBTDS_8_0_ 13 /* Microsoft SQL Server 2022 */
#define DBTXPLEN 16
#define BCPMAXERRS 1
#define BCPFIRST 2
#define BCPLAST 3
#define BCPBATCH 4
#define BCPKEEPIDENTITY 8
#define BCPLABELED 5
#define BCPHINTS 6
#define DBCMDNONE 0
#define DBCMDPEND 1
#define DBCMDSENT 2
typedef int RETCODE;
typedef void DBCURSOR;
typedef void DBXLATE;
typedef void DBSORTORDER;
typedef void DBLOGINFO;
typedef void *DBVOIDPTR;
typedef short SHORT;
typedef unsigned short USHORT;
typedef int (*INTFUNCPTR) (void *, ...);
typedef int (*DBWAITFUNC) (void);
typedef DBWAITFUNC(*DB_DBBUSY_FUNC) (void *dbproc);
typedef void (*DB_DBIDLE_FUNC) (DBWAITFUNC dfunc, void *dbproc);
typedef int (*DB_DBCHKINTR_FUNC) (void *dbproc);
typedef int (*DB_DBHNDLINTR_FUNC) (void *dbproc);
#ifndef __INCvxWorksh
/* VxWorks already defines STATUS and BOOL. Compiler gets mad if you
** redefine them. */
/* __INCvxWorksh will get #defined by std. include files included from tds.h
*/
#ifdef STATUS
/* On DU4.0d we get a conflicting STATUS definition from arpa/nameser.h
when _REENTRANT is defined.
*/
#undef STATUS
#endif
typedef int STATUS;
#if !defined(_WINDEF_) && !defined(_WINDEF_H) && !defined(DOS32X)
typedef int BOOL;
#endif
#endif
#ifndef _tdsguard_hfOrWb5znoUCWdBPoNQvqN_
/* copied from tds.h */
/* TODO find a best way... */
enum
{
SYBCHAR = 47, /* 0x2F */
#define SYBCHAR SYBCHAR
SYBVARCHAR = 39, /* 0x27 */
#define SYBVARCHAR SYBVARCHAR
SYBINTN = 38, /* 0x26 */
#define SYBINTN SYBINTN
SYBINT1 = 48, /* 0x30 */
#define SYBINT1 SYBINT1
SYBINT2 = 52, /* 0x34 */
#define SYBINT2 SYBINT2
SYBINT4 = 56, /* 0x38 */
#define SYBINT4 SYBINT4
SYBINT8 = 127, /* 0x7F */
#define SYBINT8 SYBINT8
SYBFLT8 = 62, /* 0x3E */
#define SYBFLT8 SYBFLT8
SYBDATETIME = 61, /* 0x3D */
#define SYBDATETIME SYBDATETIME
SYBBIT = 50, /* 0x32 */
#define SYBBIT SYBBIT
SYBBITN = 104, /* 0x68 */
#define SYBBITN SYBBITN
SYBTEXT = 35, /* 0x23 */
#define SYBTEXT SYBTEXT
SYBNTEXT = 99, /* 0x63 */
#define SYBNTEXT SYBNTEXT
SYBIMAGE = 34, /* 0x22 */
#define SYBIMAGE SYBIMAGE
SYBMONEY4 = 122, /* 0x7A */
#define SYBMONEY4 SYBMONEY4
SYBMONEY = 60, /* 0x3C */
#define SYBMONEY SYBMONEY
SYBDATETIME4 = 58, /* 0x3A */
#define SYBDATETIME4 SYBDATETIME4
SYBREAL = 59, /* 0x3B */
#define SYBREAL SYBREAL
SYBBINARY = 45, /* 0x2D */
#define SYBBINARY SYBBINARY
SYBVOID = 31, /* 0x1F */
#define SYBVOID SYBVOID
SYBVARBINARY = 37, /* 0x25 */
#define SYBVARBINARY SYBVARBINARY
SYBNUMERIC = 108, /* 0x6C */
#define SYBNUMERIC SYBNUMERIC
SYBDECIMAL = 106, /* 0x6A */
#define SYBDECIMAL SYBDECIMAL
SYBFLTN = 109, /* 0x6D */
#define SYBFLTN SYBFLTN
SYBMONEYN = 110, /* 0x6E */
#define SYBMONEYN SYBMONEYN
SYBDATETIMN = 111, /* 0x6F */
#define SYBDATETIMN SYBDATETIMN
SYBNVARCHAR = 103, /* 0x67 */
#define SYBNVARCHAR SYBNVARCHAR
SYBDATE = 49, /* 0x31 */
#define SYBDATE SYBDATE
SYBTIME = 51, /* 0x33 */
#define SYBTIME SYBTIME
SYBBIGDATETIME = 187, /* 0xBB */
#define SYBBIGDATETIME SYBBIGDATETIME
SYBBIGTIME = 188, /* 0xBC */
#define SYBBIGTIME SYBBIGTIME
SYBMSDATE = 40, /* 0x28 */
#define SYBMSDATE SYBMSDATE
SYBMSTIME = 41, /* 0x29 */
#define SYBMSTIME SYBMSTIME
SYBMSDATETIME2 = 42, /* 0x2A */
#define SYBMSDATETIME2 SYBMSDATETIME2
SYBMSDATETIMEOFFSET = 43, /* 0x2B */
#define SYBMSDATETIMEOFFSET SYBMSDATETIMEOFFSET
};
#define SYBAOPCNT 0x4b
#define SYBAOPCNTU 0x4c
#define SYBAOPSUM 0x4d
#define SYBAOPSUMU 0x4e
#define SYBAOPAVG 0x4f
#define SYBAOPAVGU 0x50
#define SYBAOPMIN 0x51
#define SYBAOPMAX 0x52
/* mssql2k compute operator */
#define SYBAOPCNT_BIG 0x09
#define SYBAOPSTDEV 0x30
#define SYBAOPSTDEVP 0x31
#define SYBAOPVAR 0x32
#define SYBAOPVARP 0x33
#define SYBAOPCHECKSUM_AGG 0x72
#endif
typedef unsigned char DBBOOL;
typedef char DBCHAR;
typedef unsigned char DBBIT;
typedef unsigned char DBTINYINT;
typedef int16_t DBSMALLINT;
typedef int32_t DBINT;
typedef int64_t DBBIGINT;
typedef unsigned char DBBINARY;
typedef tds_sysdep_real32_type DBREAL;
typedef tds_sysdep_real64_type DBFLT8;
typedef uint16_t DBUSMALLINT;
typedef uint32_t DBUINT;
typedef uint64_t DBUBIGINT;
typedef struct
{
DBSMALLINT len;
char str[256];
} DBVARYCHAR;
typedef struct
{
DBSMALLINT len;
unsigned char array[256];
} DBVARYBIN;
typedef struct
{
unsigned char precision;
unsigned char scale;
unsigned char array[33];
} DBNUMERIC;
typedef DBNUMERIC DBDECIMAL;
typedef struct
{
DBINT mnyhigh;
DBUINT mnylow;
} DBMONEY;
typedef struct
{
DBINT mny4;
} DBMONEY4;
typedef struct
{
DBINT dtdays;
DBINT dttime;
} DBDATETIME;
typedef struct
{
DBUSMALLINT days; /* days since Jan-1-1900 */
DBUSMALLINT minutes; /* minutes since midnight */
} DBDATETIME4;
typedef struct
{
DBUBIGINT time; /**< time, 7 digit precision */
DBINT date; /**< date, 0 = 1900-01-01 */
DBSMALLINT offset; /**< time offset */
DBUSMALLINT time_prec:3;
/* fix a problem with some public headers defining _res */
#undef _res
DBUSMALLINT _res:10;
DBUSMALLINT has_time:1;
DBUSMALLINT has_date:1;
DBUSMALLINT has_offset:1;
} DBDATETIMEALL;
#ifdef MSDBLIB
# define SQLCHAR SYBCHAR
typedef struct
{
DBUSMALLINT numdays;
DBUSMALLINT nummins;
} DBDATETIM4;
#endif
typedef struct tds_dblib_loginrec LOGINREC;
#ifndef DOS32X
typedef unsigned char BYTE;
#endif
typedef struct dbtypeinfo
{
DBINT precision;
DBINT scale;
} DBTYPEINFO;
struct dbstring
{
BYTE *strtext;
DBINT strtotlen;
struct dbstring *strnext;
};
typedef struct dbstring DBSTRING;
/* Used by dbcolinfo */
enum
{ MAXCOLNAMELEN = 512 }; /* duplicates TDS_SYSNAME_SIZE */
typedef enum { CI_REGULAR=1, CI_ALTERNATE=2, CI_CURSOR=3 } CI_TYPE;
typedef struct
{
DBINT SizeOfStruct;
DBCHAR Name[MAXCOLNAMELEN+2];
DBCHAR ActualName[MAXCOLNAMELEN+2];
DBCHAR TableName[MAXCOLNAMELEN+2];
SHORT Type;
DBINT UserType;
DBINT MaxLength;
BYTE Precision;
BYTE Scale;
BOOL VarLength;
BYTE Null;
BYTE CaseSensitive;
BYTE Updatable;
BOOL Identity;
} DBCOL;
typedef struct
{
DBINT SizeOfStruct;
DBCHAR Name[MAXCOLNAMELEN+2];
DBCHAR ActualName[MAXCOLNAMELEN+2];
DBCHAR TableName[MAXCOLNAMELEN+2];
SHORT Type;
DBINT UserType;
DBINT MaxLength;
BYTE Precision;
BYTE Scale;
BOOL VarLength;
BYTE Null;
BYTE CaseSensitive;
BYTE Updatable;
BOOL Identity;
SHORT ServerType;
DBINT ServerMaxLength;
DBCHAR ServerTypeDeclaration[256];
} DBCOL2;
/* end dbcolinfo stuff */
/* a large list of options, DBTEXTSIZE is needed by sybtcl */
#define DBPARSEONLY 0
#define DBESTIMATE 1
#define DBSHOWPLAN 2
#define DBNOEXEC 3
#define DBARITHIGNORE 4
#define DBNOCOUNT 5
#define DBARITHABORT 6
#define DBTEXTLIMIT 7
#define DBBROWSE 8
#define DBOFFSET 9
#define DBSTAT 10
#define DBERRLVL 11
#define DBCONFIRM 12
#define DBSTORPROCID 13
#define DBBUFFER 14
#define DBNOAUTOFREE 15
#define DBROWCOUNT 16
#define DBTEXTSIZE 17
#define DBNATLANG 18
#define DBDATEFORMAT 19
#define DBPRPAD 20
#define DBPRCOLSEP 21
#define DBPRLINELEN 22
#define DBPRLINESEP 23
#define DBLFCONVERT 24
#define DBDATEFIRST 25
#define DBCHAINXACTS 26
#define DBFIPSFLAG 27
#define DBISOLATION 28
#define DBAUTH 29
#define DBIDENTITY 30
#define DBNOIDCOL 31
#define DBDATESHORT 32
#define DBCLIENTCURSORS 33
#define DBSETTIME 34
#define DBQUOTEDIDENT 35
#define DBNUMOPTIONS 36
#define DBPADOFF 0
#define DBPADON 1
#define OFF 0
#define ON 1
#define NOSUCHOPTION 2
#define MAXOPTTEXT 32
typedef struct tds_dblib_dbprocess DBPROCESS;
/*
* Sybase & Microsoft use different names for the dbdaterec members.
* Keep these two structures physically identical in memory.
* dbdatecrack() casts one to the other for ease of implementation.
*
* Giving credit where credit is due, we can acknowledge that
* Microsoft chose the better names here, hands down. ("datedmonth"?!)
*/
struct tds_microsoft_dbdaterec
{
DBINT year; /* 1753 - 9999 */
DBINT quarter; /* 1 - 4 */
DBINT month; /* 1 - 12 */
DBINT day; /* 1 - 31 */
DBINT dayofyear; /* 1 - 366 */
DBINT week; /* 1 - 54 (for leap years) */
DBINT weekday; /* 1 - 7 (Mon. - Sun.) */
DBINT hour; /* 0 - 23 */
DBINT minute; /* 0 - 59 */
DBINT second; /* 0 - 59 */
DBINT millisecond; /* 0 - 999 */
DBINT tzone; /* -840 - 840 */
};
struct tds_sybase_dbdaterec
{
DBINT dateyear; /* 1900 and counting */
DBINT quarter; /* 0 - 3 (Microsoft only) */
DBINT datemonth; /* 0 - 11 */
DBINT datedmonth; /* 1 - 31 */
DBINT datedyear; /* 1 - 366 */
DBINT week; /* 1 - 54 (Microsoft only) */
DBINT datedweek; /* 0 - 6 */
DBINT datehour; /* 0 - 23 */
DBINT dateminute; /* 0 - 59 */
DBINT datesecond; /* 0 - 59 */
DBINT datemsecond; /* 0 - 999 */
DBINT datetzone; /* -840 - 840 */
};
struct tds_microsoft_dbdaterec2
{
DBINT year; /* 1753 - 9999 */
DBINT quarter; /* 1 - 4 */
DBINT month; /* 1 - 12 */
DBINT day; /* 1 - 31 */
DBINT dayofyear; /* 1 - 366 */
DBINT week; /* 1 - 54 (for leap years) */
DBINT weekday; /* 1 - 7 (Mon. - Sun.) */
DBINT hour; /* 0 - 23 */
DBINT minute; /* 0 - 59 */
DBINT second; /* 0 - 59 */
DBINT nanosecond; /* 0 - 999999999 */
DBINT tzone; /* 0 - 127 (Sybase only) */
};
struct tds_sybase_dbdaterec2
{
DBINT dateyear; /* 1900 and counting */
DBINT quarter; /* 0 - 3 (Microsoft only) */
DBINT datemonth; /* 0 - 11 */
DBINT datedmonth; /* 1 - 31 */
DBINT datedyear; /* 1 - 366 */
DBINT week; /* 1 - 54 (Microsoft only) */
DBINT datedweek; /* 0 - 6 */
DBINT datehour; /* 0 - 23 */
DBINT dateminute; /* 0 - 59 */
DBINT datesecond; /* 0 - 59 */
DBINT datensecond; /* 0 - 999999999 */
DBINT datetzone; /* 0 - 127 */
};
#ifdef MSDBLIB
typedef struct tds_microsoft_dbdaterec DBDATEREC;
typedef struct tds_microsoft_dbdaterec2 DBDATEREC2;
#else
typedef struct tds_sybase_dbdaterec DBDATEREC;
typedef struct tds_sybase_dbdaterec2 DBDATEREC2;
#endif
typedef int (*EHANDLEFUNC) (DBPROCESS * dbproc, int severity, int dberr, int oserr, char *dberrstr, char *oserrstr);
typedef int (*MHANDLEFUNC) (DBPROCESS * dbproc, DBINT msgno, int msgstate, int severity, char *msgtext, char *srvname,
char *proc, int line);
/* dbpoll() result codes, sybtcl needs DBRESULT */
#define DBRESULT 1
#define DBNOTIFICATION 2
#define DBTIMEOUT 3
#define DBINTERRUPT 4
/* more sybtcl needs: */
#define DBTXTSLEN 8
/* bind types */
#define CHARBIND 0
#define STRINGBIND 1
#define NTBSTRINGBIND 2
#define VARYCHARBIND 3
#define VARYBINBIND 4
#define TINYBIND 6
#define SMALLBIND 7
#define INTBIND 8
#define FLT8BIND 9
#define REALBIND 10
#define DATETIMEBIND 11
#define SMALLDATETIMEBIND 12
#define MONEYBIND 13
#define SMALLMONEYBIND 14
#define BINARYBIND 15
#define BITBIND 16
#define NUMERICBIND 17
#define DECIMALBIND 18
#define SRCNUMERICBIND 19
#define SRCDECIMALBIND 20
#define DATEBIND 21
#define TIMEBIND 22
#define BIGDATETIMEBIND 23
#define BIGTIMEBIND 24
#define BIGINTBIND 30
#define DATETIME2BIND 31
#define MAXBINDTYPES 32 /* keep last */
#define DBPRCOLSEP 21
#define DBPRLINELEN 22
#define DBRPCNORETURN 0
#define DBRPCRETURN 1
#define DBRPCDEFAULT 2
#define REG_ROW -1
#define MORE_ROWS -1
#define NO_MORE_ROWS -2
#define BUF_FULL -3
#define NO_MORE_RESULTS 2
#define SUCCEED 1
#define FAIL 0
#define DB_IN 1
#define DB_OUT 2
#define DB_QUERYOUT 3
#define DBSINGLE 0
#define DBDOUBLE 1
#define DBBOTH 2
/* remote procedure call (rpc) options */
#define DBRPCRECOMPILE TDS_STATIC_CAST(DBSMALLINT, 0x0001)
#define DBRPCRESET TDS_STATIC_CAST(DBSMALLINT, 0x0002)
#define DBRPCCURSOR TDS_STATIC_CAST(DBSMALLINT, 0x0008)
#if defined(DBLIB_UNIMPLEMENTED)
DBBOOL db12hour(DBPROCESS * dbprocess, const char language[]);
DBBOOL dbcolbrowse(DBPROCESS * dbprocess, int colnum);
RETCODE dbcursor(DBCURSOR * hc, DBINT optype, DBINT bufno, BYTE * table, BYTE * values);
RETCODE dbcursorbind(DBCURSOR * hc, int col, int vartype, DBINT varlen, DBINT * poutlen, BYTE * pvaraddr, DBTYPEINFO * typeinfo);
void dbcursorclose(DBCURSOR * hc);
RETCODE dbcursorcolinfo(DBCURSOR * hc, DBINT column, DBCHAR * colname, DBINT * coltype, DBINT * collen, DBINT * usertype);
RETCODE dbcursorfetch(DBCURSOR * hc, DBINT fetchtype, DBINT rownum);
RETCODE dbcursorinfo(DBCURSOR * hc, DBINT * ncols, DBINT * nrows);
DBCURSOR *dbcursoropen(DBPROCESS * dbprocess, BYTE * stmt, SHORT scollopt, SHORT concuropt, USHORT nrows, DBINT * pstatus);
int dbdate4cmp(DBPROCESS * dbprocess, DBDATETIME4 * d1, DBDATETIME4 * d2);
RETCODE dbdate4zero(DBPROCESS * dbprocess, DBDATETIME4 * d1);
RETCODE dbdatechar(DBPROCESS * dbprocess, char *buf, int datepart, int value);
int dbdatename(DBPROCESS * dbprocess, char *buf, int date, DBDATETIME * datetime);
char *dateorder(DBPROCESS * dbprocess, char *language);
DBINT dbdatepart(DBPROCESS * dbprocess, int datepart, DBDATETIME * datetime);
RETCODE dbdatezero(DBPROCESS * dbprocess, DBDATETIME * d1);
char *dbdayname(DBPROCESS * dbprocess, char *language, int daynum);
int dbgetoff(DBPROCESS * dbprocess, DBUSMALLINT offtype, int startfrom);
char *dbqual(DBPROCESS * dbprocess, int tabnum, char *tabname);
void dbfreequal(char *qualptr);
DBSORTORDER *dbloadsort(DBPROCESS * dbprocess);
RETCODE dbfreesort(DBPROCESS * dbprocess, DBSORTORDER * sortorder);
RETCODE dbload_xlate(DBPROCESS * dbprocess, char *srv_charset, char *clt_name, DBXLATE ** xlt_tosrv, DBXLATE ** xlt_todisp);
RETCODE dbmny4divide(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * quotient);
RETCODE dbmny4mul(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * prod);
RETCODE dbmnyadd(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * sum);
RETCODE dbmnydivide(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * quotient);
RETCODE dbmnydown(DBPROCESS * dbproc, DBMONEY * mnyptr, int divisor, int *remainder);
RETCODE dbmnyinit(DBPROCESS * dbproc, DBMONEY * mnyptr, int trim, DBBOOL * negative);
RETCODE dbmnyndigit(DBPROCESS * dbproc, DBMONEY * mnyptr, DBCHAR * value, DBBOOL * zero);
RETCODE dbmnymul(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * prod);
RETCODE dbmnydigit(DBPROCESS * dbprocess, DBMONEY * m1, DBCHAR * value, DBBOOL * zero);
RETCODE dbmnyscale(DBPROCESS * dbproc, DBMONEY * dest, int multiplier, int addend);
RETCODE dbnpcreate(DBPROCESS * dbprocess);
RETCODE dbnpdefine(DBPROCESS * dbprocess, DBCHAR * procedure_name, DBSMALLINT namelen);
int DBNUMORDERS(DBPROCESS * dbprocess);
RETCODE dbpoll(DBPROCESS * dbproc, long milliseconds, DBPROCESS ** ready_dbproc, int *return_reason);
int dbordercol(DBPROCESS * dbprocess, int order);
RETCODE dbregdrop(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen);
RETCODE dbregexec(DBPROCESS * dbproc, DBUSMALLINT options);
RETCODE dbreghandle(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen, INTFUNCPTR handler);
RETCODE dbreginit(DBPROCESS * dbproc, DBCHAR * procedure_name, DBSMALLINT namelen);
RETCODE dbreglist(DBPROCESS * dbproc);
RETCODE dbregnowatch(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen);
RETCODE dbregparam(DBPROCESS * dbproc, char *param_name, int type, DBINT datalen, BYTE * data);
RETCODE dbregwatch(DBPROCESS * dbprocess, DBCHAR * procnm, DBSMALLINT namelen, DBUSMALLINT options);
RETCODE dbregwatchlist(DBPROCESS * dbprocess);
void dbrpwclr(LOGINREC * login);
RETCODE dbrpwset(LOGINREC * login, char *srvname, char *password, int pwlen);
DBINT dbreadpage(DBPROCESS * dbprocess, char *p_dbname, DBINT pageno, BYTE * buf);
RETCODE dbwritepage(DBPROCESS * dbprocess, char *p_dbname, DBINT pageno, DBINT size, BYTE * buf);
RETCODE dbsetdeflang(char *language);
int dbstrcmp(DBPROCESS * dbprocess, char *s1, int l1, char *s2, int l2, DBSORTORDER * sort);
int dbstrsort(DBPROCESS * dbprocess, char *s1, int l1, char *s2, int l2, DBSORTORDER * sort);
DBBOOL dbtabbrowse(DBPROCESS * dbprocess, int tabnum);
int dbtabcount(DBPROCESS * dbprocess);
char *dbtabname(DBPROCESS * dbprocess, int tabnum);
char *dbtabsource(DBPROCESS * dbprocess, int colnum, int *tabnum);
RETCODE dbsendpassthru(DBPROCESS * dbprocess, DBVOIDPTR bufp);
RETCODE dbrecvpassthru(DBPROCESS * dbprocess, DBVOIDPTR * bufp);
RETCODE dbgetloginfo(DBPROCESS * dbprocess, DBLOGINFO ** loginfo);
RETCODE dbsetloginfo(LOGINREC * loginrec, DBLOGINFO * loginfo);
int dbtsnewlen(DBPROCESS * dbprocess);
DBBINARY *dbtsnewval(DBPROCESS * dbprocess);
RETCODE dbtsput(DBPROCESS * dbprocess, DBBINARY * newts, int newtslen, int tabnum, char *tabname);
RETCODE dbfree_xlate(DBPROCESS * dbprocess, DBXLATE * xlt_tosrv, DBXLATE * clt_todisp);
int dbxlate(DBPROCESS * dbprocess, char *src, int srclen, char *dest, int destlen, DBXLATE * xlt, int *srcbytes_used,
DBBOOL srcend, int status);
RETCODE bcp_moretext(DBPROCESS * dbproc, DBINT size, BYTE * text);
RETCODE bcp_writefmt(DBPROCESS * dbproc, const char filename[]);
void build_xact_string(char *xact_name, char *service_name, DBINT commid, char *result);
RETCODE remove_xact(DBPROCESS * connect, DBINT commid, int n);
RETCODE abort_xact(DBPROCESS * connect, DBINT commid);
void close_commit(DBPROCESS * connect);
RETCODE commit_xact(DBPROCESS * connect, DBINT commid);
DBPROCESS *open_commit(LOGINREC * login, char *servername);
RETCODE scan_xact(DBPROCESS * connect, DBINT commid);
DBINT start_xact(DBPROCESS * connect, char *application_name, char *xact_name, int site_count);
DBINT stat_xact(DBPROCESS * connect, DBINT commid);
#endif /* define unimplemented */
BYTE *dbadata(DBPROCESS * dbproc, int computeid, int column);
DBINT dbadlen(DBPROCESS * dbproc, int computeid, int column);
RETCODE dbaltbind(DBPROCESS * dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE * varaddr);
RETCODE dbaltbind_ps(DBPROCESS * dbprocess, int computeid, int column, int vartype, DBINT varlen, BYTE * varaddr,
DBTYPEINFO * typeinfo);
int dbaltcolid(DBPROCESS * dbproc, int computeid, int column);
DBINT dbaltlen(DBPROCESS * dbproc, int computeid, int column);
int dbaltop(DBPROCESS * dbproc, int computeid, int column);
int dbalttype(DBPROCESS * dbproc, int computeid, int column);
DBINT dbaltutype(DBPROCESS * dbproc, int computeid, int column);
RETCODE dbanullbind(DBPROCESS * dbprocess, int computeid, int column, DBINT * indicator);
RETCODE dbbind(DBPROCESS * dbproc, int column, int vartype, DBINT varlen, BYTE * varaddr);
RETCODE dbbind_ps(DBPROCESS * dbprocess, int column, int vartype, DBINT varlen, BYTE * varaddr, DBTYPEINFO * typeinfo);
int dbbufsize(DBPROCESS * dbprocess);
BYTE *dbbylist(DBPROCESS * dbproc, int computeid, int *size);
RETCODE dbcancel(DBPROCESS * dbproc);
RETCODE dbcanquery(DBPROCESS * dbproc);
char *dbchange(DBPROCESS * dbprocess);
DBBOOL dbcharsetconv(DBPROCESS * dbprocess);
void dbclose(DBPROCESS * dbproc);
void dbclrbuf(DBPROCESS * dbproc, DBINT n);
RETCODE dbclropt(DBPROCESS * dbproc, int option, const char param[]);
RETCODE dbcmd(DBPROCESS * dbproc, const char cmdstring[]);
RETCODE dbcmdrow(DBPROCESS * dbproc);
#define DBCMDROW(x) dbcmdrow((x))
RETCODE dbtablecolinfo (DBPROCESS *dbproc, DBINT column, DBCOL *pdbcol );
RETCODE dbcolinfo (DBPROCESS *dbproc, CI_TYPE type, DBINT column, DBINT computeid, DBCOL *pdbcol);
DBINT dbcollen(DBPROCESS * dbproc, int column);
char *dbcolname(DBPROCESS * dbproc, int column);
const char *dbacolname(DBPROCESS * dbproc, int computeid, int column);
char *dbcolsource(DBPROCESS * dbproc, int colnum);
int dbcoltype(DBPROCESS * dbproc, int column);
DBTYPEINFO *dbcoltypeinfo(DBPROCESS * dbproc, int column);
DBINT dbcolutype(DBPROCESS * dbprocess, int column);
DBINT dbconvert(DBPROCESS * dbproc, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen);
DBINT dbconvert_ps(DBPROCESS * dbprocess, int srctype, const BYTE * src, DBINT srclen, int desttype, BYTE * dest, DBINT destlen,
DBTYPEINFO * typeinfo);
BOOL dbiscount(DBPROCESS * dbproc);
DBINT dbcount(DBPROCESS * dbproc);
#define DBCOUNT(x) dbcount((x))
int dbcurcmd(DBPROCESS * dbproc);
#define DBCURCMD(x) dbcurcmd((x))
DBINT dbcurrow(DBPROCESS * dbproc);
#define DBCURROW(x) dbcurrow((x))
BYTE *dbdata(DBPROCESS * dbproc, int column);
int dbdatecmp(DBPROCESS * dbproc, DBDATETIME * d1, DBDATETIME * d2);
RETCODE dbdatecrack(DBPROCESS * dbproc, DBDATEREC * di, DBDATETIME * dt);
RETCODE dbanydatecrack(DBPROCESS * dbproc, DBDATEREC2 * di, int type, const void *data);
DBINT dbdatlen(DBPROCESS * dbproc, int column);
DBBOOL dbdead(DBPROCESS * dbproc);
#define DBDEAD(x) dbdead((x))
EHANDLEFUNC dberrhandle(EHANDLEFUNC handler);
void dbexit(void);
RETCODE dbfcmd(DBPROCESS * dbproc, const char *fmt, ...);
DBINT dbfirstrow(DBPROCESS * dbproc);
#define DBFIRSTROW(x) dbfirstrow((x))
void dbfreebuf(DBPROCESS * dbproc);
char *dbgetchar(DBPROCESS * dbprocess, int n);
char *dbgetcharset(DBPROCESS * dbprocess);
int dbgetlusername(LOGINREC * login, BYTE * name_buffer, int buffer_len);
int dbgetmaxprocs(void);
char *dbgetnatlanf(DBPROCESS * dbprocess);
int dbgetpacket(DBPROCESS * dbproc);
RETCODE dbgetrow(DBPROCESS * dbproc, DBINT row);
int dbgettime(void);
#define DBGETTIME dbgettime
BYTE *dbgetuserdata(DBPROCESS * dbproc);
DBBOOL dbhasretstat(DBPROCESS * dbproc);
RETCODE dbinit(void);
int dbiordesc(DBPROCESS * dbproc);
#define DBIORDESC(x) dbiordesc((x))
int dbiowdesc(DBPROCESS * dbproc);
#define DBIOWDESC(x) dbiowdesc((x))
DBBOOL dbisavail(DBPROCESS * dbprocess);
#define DBISAVAIL(x) dbisavail((x))
DBBOOL dbisopt(DBPROCESS * dbproc, int option, const char param[]);
DBINT dblastrow(DBPROCESS * dbproc);
#define DBLASTROW(x) dblastrow((x))
LOGINREC *dblogin(void);
void dbloginfree(LOGINREC * login);
int dbmny4cmp(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2);
int dbmnycmp(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2);
RETCODE dbmny4add(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * sum);
RETCODE dbmnydec(DBPROCESS * dbproc, DBMONEY * mnyptr);
RETCODE dbmnyinc(DBPROCESS * dbproc, DBMONEY * mnyptr);
RETCODE dbmnymaxpos(DBPROCESS * dbproc, DBMONEY * dest);
RETCODE dbmnymaxneg(DBPROCESS * dbproc, DBMONEY * dest);
RETCODE dbmny4minus(DBPROCESS * dbproc, DBMONEY4 * src, DBMONEY4 * dest);
RETCODE dbmnyminus(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest);
RETCODE dbmny4sub(DBPROCESS * dbproc, DBMONEY4 * m1, DBMONEY4 * m2, DBMONEY4 * diff);
RETCODE dbmnysub(DBPROCESS * dbproc, DBMONEY * m1, DBMONEY * m2, DBMONEY * diff);
RETCODE dbmny4copy(DBPROCESS * dbprocess, DBMONEY4 * m1, DBMONEY4 * m2);
RETCODE dbmnycopy(DBPROCESS * dbproc, DBMONEY * src, DBMONEY * dest);
RETCODE dbmny4zero(DBPROCESS * dbproc, DBMONEY4 * dest);
RETCODE dbmnyzero(DBPROCESS * dbproc, DBMONEY * dest);
const char *dbmonthname(DBPROCESS * dbproc, char *language, int monthnum, DBBOOL shortform);
RETCODE dbmorecmds(DBPROCESS * dbproc);
#define DBMORECMDS(x) dbmorecmds((x))
RETCODE dbmoretext(DBPROCESS * dbproc, DBINT size, const BYTE text[]);
MHANDLEFUNC dbmsghandle(MHANDLEFUNC handler);
char *dbname(DBPROCESS * dbproc);
STATUS dbnextrow(DBPROCESS * dbproc);
RETCODE dbnullbind(DBPROCESS * dbproc, int column, DBINT * indicator);
int dbnumalts(DBPROCESS * dbproc, int computeid);
int dbnumcols(DBPROCESS * dbproc);
int dbnumcompute(DBPROCESS * dbprocess);
int dbnumrets(DBPROCESS * dbproc);
DBPROCESS *tdsdbopen(LOGINREC * login, const char *server, int msdblib);
DBPROCESS *dbopen(LOGINREC * login, const char *server);
/* pivot functions */
struct col_t;
void dbpivot_count (struct col_t *output, const struct col_t *input);
void dbpivot_sum (struct col_t *output, const struct col_t *input);
void dbpivot_min (struct col_t *output, const struct col_t *input);
void dbpivot_max (struct col_t *output, const struct col_t *input);
struct pivot_t;
typedef void (*DBPIVOT_FUNC)(struct col_t *output, const struct col_t *input);
struct pivot_t * dbrows_pivoted(DBPROCESS *dbproc);
STATUS dbnextrow_pivoted(DBPROCESS *dbproc, struct pivot_t *pp);
RETCODE dbpivot(DBPROCESS *dbproc, int nkeys, int *keys, int ncols, int *cols, DBPIVOT_FUNC func, int val);
DBPIVOT_FUNC dbpivot_lookup_name( const char name[] );
#ifdef MSDBLIB
#define dbopen(x,y) tdsdbopen((x),(y), 1)
#else
#define dbopen(x,y) tdsdbopen((x),(y), 0)
#endif
/* fix PHP problem */
#ifdef PHP_SYBASE_DBOPEN
#undef PHP_SYBASE_DBOPEN
#define PHP_SYBASE_DBOPEN dbopen
#endif
void dbprhead(DBPROCESS * dbproc);
DBINT dbprcollen(DBPROCESS * dbproc, int column);
RETCODE dbprrow(DBPROCESS * dbproc);
const char *dbprtype(int token);
DBBOOL DRBUF(DBPROCESS * dbprocess);
STATUS dbreadtext(DBPROCESS * dbproc, void *buf, DBINT bufsize);
void dbrecftos(const char filename[]);
RETCODE dbresults(DBPROCESS * dbproc);
RETCODE dbresults_r(DBPROCESS * dbproc, int recursive);
BYTE *dbretdata(DBPROCESS * dbproc, int retnum);
int dbretlen(DBPROCESS * dbproc, int retnum);
char *dbretname(DBPROCESS * dbproc, int retnum);
DBINT dbretstatus(DBPROCESS * dbproc);
int dbrettype(DBPROCESS * dbproc, int retnum);
RETCODE dbrows(DBPROCESS * dbproc);
#define DBROWS(x) dbrows((x))
STATUS dbrowtype(DBPROCESS * dbprocess);
#define DBROWTYPE(x) dbrowtype((x))
RETCODE dbrpcinit(DBPROCESS * dbproc, const char rpcname[], DBSMALLINT options);
RETCODE dbrpcparam(DBPROCESS * dbproc, const char paramname[], BYTE status, int type, DBINT maxlen, DBINT datalen, BYTE * value);
RETCODE dbrpcsend(DBPROCESS * dbproc);
RETCODE dbsafestr(DBPROCESS * dbproc, const char *src, DBINT srclen, char *dest, DBINT destlen, int quotetype);
RETCODE *dbsechandle(DBINT type, INTFUNCPTR handler);
char *dbservcharset(DBPROCESS * dbprocess);
void dbsetavail(DBPROCESS * dbprocess);
void dbsetbusy(DBPROCESS * dbprocess, DB_DBBUSY_FUNC busyfunc);
RETCODE dbsetdefcharset(char *charset);
void dbsetidle(DBPROCESS * dbprocess, DB_DBIDLE_FUNC idlefunc);
void dbsetifile(char *filename);
void dbsetinterrupt(DBPROCESS * dbproc, DB_DBCHKINTR_FUNC chkintr, DB_DBHNDLINTR_FUNC hndlintr);
RETCODE dbsetlogintime(int seconds);
RETCODE dbsetmaxprocs(int maxprocs);
RETCODE dbsetnull(DBPROCESS * dbprocess, int bindtype, int bindlen, BYTE * bindval);
RETCODE dbsetopt(DBPROCESS * dbproc, int option, const char *char_param, int int_param);
STATUS dbsetrow(DBPROCESS * dbprocess, DBINT row);
RETCODE dbsettime(int seconds);
void dbsetuserdata(DBPROCESS * dbproc, BYTE * ptr);
RETCODE dbsetversion(DBINT version);
int dbspid(DBPROCESS * dbproc);
RETCODE dbspr1row(DBPROCESS * dbproc, char *buffer, DBINT buf_len);
DBINT dbspr1rowlen(DBPROCESS * dbproc);
RETCODE dbsprhead(DBPROCESS * dbproc, char *buffer, DBINT buf_len);
RETCODE dbsprline(DBPROCESS * dbproc, char *buffer, DBINT buf_len, DBCHAR line_char);
RETCODE dbsqlexec(DBPROCESS * dbproc);
RETCODE dbsqlok(DBPROCESS * dbproc);
RETCODE dbsqlsend(DBPROCESS * dbproc);
int dbstrbuild(DBPROCESS * dbproc, char *charbuf, int bufsize, char *text, char *formats, ...);
RETCODE dbstrcpy(DBPROCESS * dbproc, int start, int numbytes, char *dest);
int dbstrlen(DBPROCESS * dbproc);
DBINT dbvarylen(DBPROCESS * dbproc, int column);
#define SYBEVERDOWN 100 /* TDS version downgraded . */
#define SYBEICONVIU 2400 /* Some character(s) could not be converted into client's character set. */
#define SYBEICONVAVAIL 2401 /* Character set conversion is not available between client character set '%.*s' and server character set '%.*s'.*/
#define SYBEICONVO 2402 /* Error converting characters into server's character set. Some character(s) could not be converted.*/
#define SYBEICONVI 2403 /* Some character(s) could not be converted into client's character set. Unconverted bytes were changed to question marks ('?').*/
#define SYBEICONV2BIG 2404 /* Buffer overflow converting characters from client into server's character set.*/
/* cf. doc/dblib_errors.txt for more iconv error values. */
/* Reserve a few slots for other iconv-related issues. */
#define SYBETDSVER 2410 /* Cannot bcp with TDSVER < 5.0 */
#define SYBEPORT 2500 /* Both port and instance specified */
#define SYBESYNC 20001 /* Read attempted while out of synchronization with SQL Server. */
#define SYBEFCON 20002 /* SQL Server connection failed. */
#define SYBETIME 20003 /* SQL Server connection timed out. */
#define SYBEREAD 20004 /* Read from SQL Server failed. */
#define SYBEBUFL 20005 /* DB-LIBRARY internal error - send buffer length corrupted. */
#define SYBEWRIT 20006 /* Write to SQL Server failed. */
#define SYBEVMS 20007 /* Sendflush: VMS I/O error. */
#define SYBESOCK 20008 /* Unable to open socket */
#define SYBECONN 20009 /* Unable to connect socket -- SQL Server is unavailable or does not exist. */
#define SYBEMEM 20010 /* Unable to allocate sufficient memory */
#define SYBEDBPS 20011 /* Maximum number of DBPROCESSes already allocated. */
#define SYBEINTF 20012 /* Server name not found in interface file */
#define SYBEUHST 20013 /* Unknown host machine name */
#define SYBEPWD 20014 /* Incorrect password. */
#define SYBEOPIN 20015 /* Could not open interface file. */
#define SYBEINLN 20016 /* Interface file: unexpected end-of-line. */
#define SYBESEOF 20017 /* Unexpected EOF from SQL Server. */
#define SYBESMSG 20018 /* General SQL Server error: Check messages from the SQL Server. */
#define SYBERPND 20019 /* Attempt to initiate a new SQL Server operation with results pending. */
#define SYBEBTOK 20020 /* Bad token from SQL Server: Data-stream processing out of sync. */
#define SYBEITIM 20021 /* Illegal timeout value specified. */
#define SYBEOOB 20022 /* Error in sending out-of-band data to SQL Server. */
#define SYBEBTYP 20023 /* Unknown bind type passed to DB-LIBRARY function. */
#define SYBEBNCR 20024 /* Attempt to bind user variable to a non-existent compute row. */
#define SYBEIICL 20025 /* Illegal integer column length returned by SQL Server. Legal integer lengths are 1, 2, and 4 bytes. */
#define SYBECNOR 20026 /* Column number out of range. */
#define SYBENPRM 20027 /* NULL parameter not allowed for this dboption. */
#define SYBEUVDT 20028 /* Unknown variable-length datatype encountered. */
#define SYBEUFDT 20029 /* Unknown fixed-length datatype encountered. */
#define SYBEWAID 20030 /* DB-LIBRARY internal error: ALTFMT following ALTNAME has wrong id. */
#define SYBECDNS 20031 /* Datastream indicates that a compute column is derived from a non-existent select-list member. */
#define SYBEABNC 20032 /* Attempt to bind to a non-existent column. */
#define SYBEABMT 20033 /* User attempted a dbbind() with mismatched column and variable types. */
#define SYBEABNP 20034 /* Attempt to bind using NULL pointers. */
#define SYBEAAMT 20035 /* User attempted a dbaltbind() with mismatched column and variable types. */
#define SYBENXID 20036 /* The Server did not grant us a distributed-transaction ID. */
#define SYBERXID 20037 /* The Server did not recognize our distributed-transaction ID. */
#define SYBEICN 20038 /* Invalid computeid or compute column number. */
#define SYBENMOB 20039 /* No such member of 'order by' clause. */
#define SYBEAPUT 20040 /* Attempt to print unknown token. */
#define SYBEASNL 20041 /* Attempt to set fields in a null loginrec. */
#define SYBENTLL 20042 /* Name too long for loginrec field. */
#define SYBEASUL 20043 /* Attempt to set unknown loginrec field. */
#define SYBERDNR 20044 /* Attempt to retrieve data from a non-existent row. */
#define SYBENSIP 20045 /* Negative starting index passed to dbstrcpy(). */
#define SYBEABNV 20046 /* Attempt to bind to a NULL program variable. */
#define SYBEDDNE 20047 /* DBPROCESS is dead or not enabled. */
#define SYBECUFL 20048 /* Data-conversion resulted in underflow. */
#define SYBECOFL 20049 /* Data-conversion resulted in overflow. */
#define SYBECSYN 20050 /* Attempt to convert data stopped by syntax error in source field. */
#define SYBECLPR 20051 /* Data-conversion resulted in loss of precision. */
#define SYBECNOV 20052 /* Attempt to set variable to NULL resulted in overflow. */
#define SYBERDCN 20053 /* Requested data-conversion does not exist. */
#define SYBESFOV 20054 /* dbsafestr() overflowed its destination buffer. */
#define SYBEUNT 20055 /* Unknown network type found in interface file. */
#define SYBECLOS 20056 /* Error in closing network connection. */
#define SYBEUAVE 20057 /* Unable to allocate VMS event flag. */
#define SYBEUSCT 20058 /* Unable to set communications timer. */
#define SYBEEQVA 20059 /* Error in queueing VMS AST routine. */
#define SYBEUDTY 20060 /* Unknown datatype encountered. */
#define SYBETSIT 20061 /* Attempt to call dbtsput() with an invalid timestamp. */
#define SYBEAUTN 20062 /* Attempt to update the timestamp of a table which has no timestamp column. */
#define SYBEBDIO 20063 /* Bad bulk-copy direction. Must be either IN or OUT. */
#define SYBEBCNT 20064 /* Attempt to use Bulk Copy with a non-existent Server table. */
#define SYBEIFNB 20065 /* Illegal field number passed to bcp_control(). */
#define SYBETTS 20066 /* The table which bulk-copy is attempting to copy to a host-file is shorter than the number of rows which bulk-copy was instructed to skip. */
#define SYBEKBCO 20067 /* 1000 rows successfully bulk-copied to host-file. */
#define SYBEBBCI 20068 /* Batch successfully bulk-copied to SQL Server. */
#define SYBEKBCI 20069 /* Bcp: 1000 rows sent to SQL Server. */
#define SYBEBCRE 20070 /* I/O error while reading bcp data-file. */
#define SYBETPTN 20071 /* Syntax error: only two periods are permitted in table names. */
#define SYBEBCWE 20072 /* I/O error while writing bcp data-file. */
#define SYBEBCNN 20073 /* Attempt to bulk-copy a NULL value into Server column %d, which does not accept NULL values. */
#define SYBEBCOR 20074 /* Attempt to bulk-copy an oversized row to the SQL Server. */
#define SYBEBCIS 20075 /* Attempt to bulk-copy an illegally-sized column value to the SQL Server. */
#define SYBEBCPI 20076 /* bcp_init() must be called before any other bcp routines. */