home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a063 / 13.img / INCLUDE / SQLFRONT.H < prev   
Encoding:
C/C++ Source or Header  |  1992-04-27  |  13.8 KB  |  527 lines

  1. /* SQLFRONT.H - DB-Library header file for the Microsoft SQL Server.
  2. **         The SYBASE SQL Server database for PC networks.
  3. **
  4. ** All constant and macro definitions for DB-Library applications
  5. ** programming are contained in this file.  This file MUST be included
  6. ** before SQLDB.H and one of the following #defines made: DBMSDOS, DBMSOS2,
  7. ** DBNTWIN32 and DBMSWIN (for the appropriate operating platform). When
  8. ** compiling a WLO 1.0 application (using Windows libraries for os/2),
  9. ** use DBMSWIN.
  10. **
  11. ** Copyright (c) 1989, 1991 by Microsoft Corp.    All rights reserved.
  12. ** Copyright (c) 1989, 1991 by Sybase, Inc.  All rights reserved.
  13. **
  14. */
  15.  
  16. /* Note this has changed because Windows 3.1 defines API as 'pascal far' */
  17.  
  18. #if !defined(M_I86SM)  && !defined(DBNTWIN32)
  19. #define SQLAPI            cdecl far
  20. #else
  21. #define SQLAPI            cdecl
  22. #endif
  23.  
  24. #ifndef  API
  25. #define  API  SQLAPI
  26. #endif
  27.  
  28. /* define datatypes used by dblib for portability */
  29.  
  30. #define DBUBOOL            unsigned int
  31.  
  32. #ifndef SHORT
  33. #define SHORT            short
  34. #endif
  35.  
  36. #ifndef INT
  37. #define INT            int
  38. #endif
  39.  
  40. #ifndef USHORT
  41. #define USHORT             unsigned short
  42. #endif
  43.  
  44. #ifndef ULONG
  45. #define ULONG             unsigned long
  46. #endif
  47.  
  48. #ifndef CHAR
  49. #define CHAR            char
  50. #endif
  51.  
  52. #ifndef DOUBLE
  53. #define DOUBLE            double
  54. #endif
  55.  
  56. #ifndef OS2_INCLUDED
  57. typedef unsigned char           BYTE;
  58. #endif
  59.  
  60. #if !defined(OS2_INCLUDED) && !defined(DBMSWIN) && !defined(DBNTWIN32)
  61. typedef DBUBOOL         BOOL;
  62. #endif
  63.  
  64. #ifndef TRUE
  65. #define TRUE                    1
  66. #endif
  67.  
  68. #ifndef FALSE
  69. #define FALSE                   0
  70. #endif
  71.  
  72. #define TINYBIND    1
  73. #define SMALLBIND       2
  74. #define INTBIND         3
  75. #define CHARBIND        4
  76. #define BINARYBIND    5
  77. #define BITBIND     6
  78. #define DATETIMEBIND    7
  79. #define MONEYBIND    8
  80. #define FLT8BIND    9
  81. #define STRINGBIND    10
  82. #define NTBSTRINGBIND    11
  83. #define VARYCHARBIND    12
  84. #define VARYBINBIND    13
  85.  
  86. /* These are version 4.2 additions */
  87. #define FLT4BIND    14
  88. #define SMALLMONEYBIND    15
  89. #define SMALLDATETIBIND 16
  90. #define  MAXBIND    SMALLDATETIBIND
  91. /* #define MAXBIND       VARYBINBIND    */
  92.  
  93.  
  94. #define DBSAVE          1
  95. #define DBNOSAVE        0
  96.  
  97. #define DBNOERR         -1
  98. #define DBFINDONE       0x04            /* definately done        */
  99. #define DBMORE          0x10            /* maybe more commands waiting  */
  100. #define DBMORE_ROWS     0x20            /* this command returned rows   */
  101.  
  102. #define MAXNAME                 31
  103.  
  104. /* Timestamp length */
  105. #define  DBTXTSLEN              8       /* length of text timestamp    */
  106.  
  107. /* Text pointer length */
  108. #define  DBTXPLEN               16
  109.  
  110. /* Error code returns */
  111. #define INT_EXIT                0
  112. #define INT_CONTINUE            1
  113. #define INT_CANCEL              2
  114.  
  115. /* Server buffer size */
  116. #define SERVBSIZE               512
  117. #define DBNETCOUNT        10
  118.  
  119. /* Dboptions */
  120. #define DBMAXOPTS        14
  121.  
  122. /* dboptions */
  123. #define DBBUFFER                0
  124. #define DBOFFSET                1
  125. #define DBROWCOUNT              2
  126. #define DBSTAT                  3
  127. #define DBTEXTLIMIT             4
  128. #define DBTEXTSIZE              5
  129. #define DBARITHABORT            6
  130. #define DBARITHIGNORE           7
  131. #define DBNOAUTOFREE            8
  132. #define DBNOCOUNT               9
  133. #define DBNOEXEC                10
  134. #define DBPARSEONLY             11
  135. #define DBSHOWPLAN              12
  136. #define DBSTORPROCID        13
  137.     /* The following is a version 4.2 enhancement */
  138. #define DBANSItoOEM        14    /* Windows only option */
  139.  
  140. /* Data Type Tokens. */
  141. # define SQLTEXT        0x23
  142. # define SQLARRAY        0x24
  143. # define SQLVARBINARY        0x25
  144. # define SQLINTN        0x26
  145. # define SQLVARCHAR        0x27
  146. # define SQLBINARY        0x2d
  147. # define SQLIMAGE        0x22
  148. # define SQLCHAR        0x2f
  149. # define SQLINT1        0x30
  150. # define SQLBIT         0x32
  151. # define SQLINT2        0x34
  152. # define SQLINT4        0x38
  153. # define SQLMONEY        0x3c
  154. # define SQLDATETIME        0x3d
  155. # define SQLFLT8        0x3e
  156. # define SQLFLTN        0x6d
  157. # define SQLMONEYN        0x6e
  158. # define SQLDATETIMN        0x6f
  159.  
  160. /* These are version 4.2 additions */
  161. # define SQLFLT4        0x3b
  162. # define SQLMONEY4        0x7a
  163. # define SQLDATETIM4        0x3a
  164.  
  165.  
  166. /* Data stream tokens */
  167. # define SQLCOLFMT        0xa1
  168. # define OLD_SQLCOLFMT        0x2a
  169. # define SQLPROCID        0x7c
  170. # define SQLCOLNAME        0xa0
  171. # define SQLTABNAME        0xa4
  172. # define SQLCOLINFO        0xa5
  173. # define SQLALTNAME        0xa7
  174. # define SQLALTFMT        0xa8
  175. # define SQLERROR        0xaa
  176. # define SQLINFO        0xab
  177. # define SQLRETURNVALUE     0xac
  178. # define SQLRETURNSTATUS        0x79
  179. # define SQLRETURN        0xdb
  180. # define SQLCONTROL        0xae
  181. # define SQLALTCONTROL        0xaf
  182. # define SQLROW         0xd1
  183. # define SQLALTROW        0xd3
  184. # define SQLDONE        0xfd
  185. # define SQLDONEPROC        0xfe
  186. # define SQLDONEINPROC        0xff
  187. # define SQLOFFSET        0x78
  188. # define SQLORDER               0xa9
  189. # define SQLLOGINACK        0xad    /* >>> NOTICE: change to real value */
  190.  
  191. /* Ag op tokens */
  192. # define SQLAOPCNT        0x4b
  193. # define SQLAOPSUM        0x4d
  194. # define SQLAOPAVG        0x4f
  195. # define SQLAOPMIN        0x51
  196. # define SQLAOPMAX        0x52
  197. # define SQLAOPANY        0x53
  198. # define SQLAOPNOOP        0x56
  199.  
  200. /* error numbers (dberrs) DB-Library error codes */
  201. #define SQLEMEM         10000
  202. #define SQLENULL        10001
  203. #define SQLENLOG        10002
  204. #define SQLEPWD         10003
  205. #define SQLECONN        10004
  206. #define SQLEDDNE        10005
  207. #define SQLENULLO       10006
  208. #define SQLESMSG        10007
  209. #define SQLEBTOK        10008
  210. #define SQLENSPE        10009
  211. #define SQLEREAD        10010
  212. #define SQLECNOR        10011
  213. #define SQLETSIT        10012
  214. #define SQLEPARM        10013
  215. #define SQLEAUTN        10014
  216. #define SQLECOFL        10015
  217. #define SQLERDCN        10016
  218. #define SQLEICN         10017
  219. #define SQLECLOS        10018
  220. #define SQLENTXT        10019  /* new error number/message */
  221. #define SQLEDNTI        10020
  222. #define SQLETMTD        10021
  223. #define SQLEASEC        10022
  224. #define SQLENTLL        10023
  225. #define SQLETIME        10024
  226. #define SQLEWRIT        10025
  227. #define SQLEMODE        10026
  228. #define SQLEOOB         10027
  229. #define SQLEITIM        10028
  230. #define SQLEDBPS        10029
  231. #define SQLEIOPT        10030
  232. #define SQLEASNL        10031
  233. #define SQLEASUL        10032
  234. #define SQLENPRM        10033
  235. #define SQLEDBOP        10034
  236. #define SQLENSIP        10035
  237. #define SQLECNULL       10036
  238. #define SQLESEOF    10037
  239. #define SQLERPND    10038
  240. #define SQLECSYN    10039
  241. #define SQLENONET    10040
  242. #define SQLEBTYP    10041
  243. #define SQLEABNC    10042
  244. #define SQLEABMT    10043
  245. #define SQLEABNP    10044
  246. #define SQLEBNCR    10045
  247. #define SQLEAAMT    10046
  248. #define SQLENXID    10047
  249. #define SQLEIFNB    10048
  250. #define SQLEKBCO    10049
  251. #define SQLEBBCI    10050
  252. #define SQLEKBCI    10051
  253. #define SQLEBCWE    10052
  254. #define SQLEBCNN    10053
  255. #define SQLEBCOR    10054
  256. #define SQLEBCPI    10055
  257. #define SQLEBCPN    10056
  258. #define SQLEBCPB    10057
  259. #define SQLEVDPT    10058
  260. #define SQLEBIVI    10059
  261. #define SQLEBCBC    10060
  262. #define SQLEBCFO    10061
  263. #define SQLEBCVH    10062
  264. #define SQLEBCUO    10063
  265. #define SQLEBUOE    10064
  266. #define SQLEBWEF    10065
  267. #define SQLEBTMT    10066
  268. #define SQLEBEOF    10067
  269. #define SQLEBCSI    10068
  270. #define SQLEPNUL    10069
  271. #define SQLEBSKERR    10070
  272. #define SQLEBDIO    10071
  273. #define SQLEBCNT    10072
  274. #define SQLEMDBP    10073
  275. #define SQLINIT     10074
  276. #define SQLCRSINV    10075
  277. #define SQLCRSCMD    10076
  278. #define SQLCRSNOIND    10077
  279. #define SQLCRSDIS    10078
  280. #define SQLCRSAGR    10079
  281. #define SQLCRSORD    10080
  282. #define SQLCRSMEM    10081
  283. #define SQLCRSBSKEY    10082
  284. #define SQLCRSNORES    10083
  285. #define SQLCRSVIEW    10084
  286. #define SQLCRSBUFR    10085
  287. #define SQLCRSFROWN    10086
  288. #define SQLCRSBROL    10087
  289. #define SQLCRSFRAND    10088
  290. #define SQLCRSFLAST    10089
  291. #define SQLCRSRO    10090
  292. #define SQLCRSTAB    10091
  293. #define SQLCRSUPDTAB    10092
  294. #define SQLCRSUPDNB    10093
  295. #define SQLCRSVIIND    10094
  296. #define SQLCRSNOUPD    10095
  297. #define SQLCRSOS2    10096
  298. #define SQLEBCSA        10097
  299. #define SQLEBCRO    10098
  300. #define SQLEBCNE    10099
  301. #define SQLEBCSK    10100
  302. #define SQLEUVBF    10101
  303. #define SQLEBIHC    10102
  304. #define SQLEBWFF    10103
  305.  
  306. /* The severity levels are defined here */
  307. #define    EXINFO        1    /* informational, non-error */
  308. #define    EXUSER        2    /* user error */
  309. #define    EXNONFATAL    3    /* non-fatal error */
  310. #define EXCONVERSION    4    /* Error in DB-LIBRARY data conversion. */
  311. #define EXSERVER    5    /* The Server has returned an error flag. */
  312. #define EXTIME        6    /* We have exceeded our timeout period while
  313.                  * waiting for a response from the Server -
  314.                  * the DBPROCESS is still alive.
  315.                  */
  316. #define EXPROGRAM    7    /* coding error in user program */
  317. #define    EXRESOURCE    8    /* running out of resources - the DBPROCESS
  318.                  * may be dead.
  319.                  */
  320. #define    EXCOMM        9    /* failure in communication with Server -
  321.                  * the DBPROCESS is dead.
  322.                  */
  323. #define    EXFATAL        10    /* fatal error - the DBPROCESS is dead. */
  324. #define    EXCONSISTENCY    11    /* internal software error  - notify MS
  325.                  * Technical Supprt.
  326.                  */
  327.  
  328.  
  329. /* offset identifiers */
  330. #define OFF_SELECT      0x16d
  331. #define OFF_FROM        0x14f
  332. #define OFF_ORDER       0x165
  333. #define OFF_COMPUTE     0x139
  334. #define OFF_TABLE       0x173
  335. #define OFF_PROCEDURE   0x16a
  336. #define OFF_STATEMENT   0x1cb
  337. #define OFF_PARAM       0x1c4
  338. #define OFF_EXEC    0x12c
  339.  
  340. /* print lengths for certain fixed length data types. */
  341. #define PRINT4      11
  342. #define PRINT2      6
  343. #define PRINT1      3
  344. #define PRFLT8        20
  345. #define PRMONEY     26
  346. #define PRBIT        3
  347. #define PRDATETIME    27
  348.  
  349.  
  350. #define MAXTYPES    11
  351. #define DBMAXCHAR       256     /* max length of DBVARBINARY and DBVARCHAR,etc */
  352.  
  353. #ifndef DBTYPEDEFS    /* srv.h (Open Server include) not already included*/
  354.  
  355. #define DBTYPEDEFS
  356.  
  357. /* dblib datatypes */
  358. typedef char            DBCHAR;
  359. typedef unsigned char   DBBINARY;
  360. typedef unsigned char   DBTINYINT;
  361. typedef short           DBSMALLINT;
  362. typedef unsigned short  DBUSMALLINT;
  363. typedef long            DBINT;
  364. typedef double          DBFLT8;
  365. typedef unsigned char   DBBIT;
  366. typedef unsigned char   DBBOOL;
  367.  
  368. /* These are version 4.2 additions */
  369. typedef float  DBFLT4;
  370. typedef long   DBMONEY4;
  371.  
  372. #define DBREAL    DBFLT4
  373.  
  374. typedef struct dbdatetime4
  375. {
  376.     unsigned short numdays;         /* No of days since Jan-1-1900 */
  377.     unsigned short nummins;         /* No. of minutes since midnight */
  378. }DBDATETIM4;
  379.  
  380.  
  381.  
  382. typedef struct dbvarychar
  383. {
  384.     DBSMALLINT  len;
  385.     DBCHAR      str[DBMAXCHAR];
  386. }DBVARYCHAR;
  387.  
  388. typedef struct dbvarybin
  389. {
  390.     DBSMALLINT  len;
  391.     BYTE        array[DBMAXCHAR];
  392. }DBVARYBIN;
  393.  
  394. typedef struct dbmoney
  395. {
  396.     DBINT mnyhigh;
  397.     ULONG mnylow;
  398. }DBMONEY;
  399.  
  400. typedef struct dbdatetime
  401. {
  402.     DBINT dtdays;
  403.     ULONG dttime;
  404. }DBDATETIME;
  405.  
  406. /* DBDATEREC structure used by dbdatecrack. This is a version 4.2 addition */
  407. typedef struct dbdaterec
  408. {
  409.     int     year;        /* 1753 - 9999 */
  410.     int     quarter;        /* 1 - 4 */
  411.     int     month;        /* 1 - 12 */
  412.     int     dayofyear;        /* 1 - 366 */
  413.     int     day;        /* 1 - 31 */
  414.     int     week;        /* 1 - 54 (for leap years) */
  415.     int     weekday;        /* 1 - 7  (Mon - Sun) */
  416.     int     hour;        /* 0 - 23 */
  417.     int     minute;        /* 0 - 59 */
  418.     int     second;        /* 0 - 59 */
  419.     int     millisecond;    /* 0 - 999 */
  420. } DBDATEREC;
  421.  
  422. #endif        /* end DBTYPEDEFS */
  423.  
  424. /* various datatype and return codes */
  425. #define RETCODE        INT
  426. #define STATUS          INT
  427. #define SUCCEED        1
  428. #define FAIL        0
  429.  
  430.  
  431. #define MORE_ROWS    -1
  432. #define NO_MORE_ROWS    -2
  433. #define REG_ROW         MORE_ROWS
  434. #define BUF_FULL    -3
  435.  
  436. /*
  437. **  Status code for dbresults(). Possible return values are
  438. **  SUCCEED, FAIL, and NO_MORE_RESULTS.
  439. */
  440. #define NO_MORE_RESULTS 2
  441.  
  442. /* macros for dbsetlname() */
  443. #define DBSETHOST    1
  444. #define DBSETUSER    2
  445. #define DBSETPWD    3
  446. #define DBSETAPP    4
  447. #define DBSETID         5
  448.     /* The following is a version 4.2 addition */
  449. #define DBSETLANG    6
  450.  
  451. /* standard exit and error values */
  452. #define STDEXIT        0
  453. #define ERREXIT        -1
  454.  
  455. /* The following are version 4.2 additions */
  456.  
  457. #define  DBRPCRECOMPILE     1
  458. #define  DBRPCRETURN        1
  459.  
  460.  
  461. /* Cursor related constants */
  462.  
  463. /*
  464.  ** Following flags are used in the concuropt parameter in the
  465.  ** dbcursoropen function
  466.  */
  467. #define CUR_READONLY        1    /* Read only cursor, no data modifications*/
  468. #define CUR_LOCKCC        2    /* Intent to update, all fetched data locked
  469.                  **  when dbcursorfetch is called inside a
  470.                  **  transaction block
  471.                  */
  472. #define CUR_OPTCC        3    /* Optimistic concurrency control, data
  473.                  **  modifications succeed only if the row
  474.                  **  hasn't been updated since the last fetch
  475.                  */
  476. #define CUR_OPTCCVAL        4    /* Optimistic concurrency control based on
  477.                  ** selected column values
  478.                  */
  479.  
  480.  
  481. /*
  482.  ** Following flags are used in the scrollopt parameter in the
  483.  ** dbcursoropen function
  484.  */
  485. #define CUR_FORWARD        0    /* Forward only scrolling */
  486. #define CUR_KEYSET       -1    /* Keyset driven scrolling */
  487. #define CUR_DYNAMIC        1    /* Fully dynamic */
  488. /* Any other number indicates mixed scrolling. (Keyset driven within the given
  489.  **  number, dynamic outside)
  490.  */
  491.  
  492. /*
  493.  ** Following flags define the fetchtype in the dbcursorfetch function
  494.  */
  495. #define  FETCH_FIRST    1    /* Fetch first n rows */
  496. #define  FETCH_NEXT    2    /* Fetch next n rows */
  497. #define  FETCH_PREV    3    /* Fetch previous n rows */
  498. #define  FETCH_RANDOM    4    /* Fetch n rows beginning with given row# */
  499. #define  FETCH_RELATIVE 5    /* Fetch relative to previous fetch row # */
  500. #define  FETCH_LAST    6    /* Fetch the last n rows */
  501.  
  502. /*
  503.  ** Following flags define the per row status as filled by dbcursorfetch
  504.  */
  505. #define FTC_SUCCEED    0x01    /* Fetch succeeded, (failed if not set) */
  506. #define FTC_MISSING    0x02    /* The row is missing */
  507. #define FTC_ENDOFKEYSET 0x04    /* End of the keyset reached */
  508. #define FTC_ENDOFRESULTS 0x08    /* End of results set reached */
  509.  
  510. /*
  511.  ** Following flags define the operator types for the dbcursor function
  512.  */
  513. #define CRS_UPDATE    1    /* Update operation */
  514. #define CRS_DELETE    2    /* Delete operation */
  515. #define CRS_INSERT    3    /* Insert operation */
  516. #define CRS_REFRESH    4    /* Refetch given row */
  517. #define CRS_LOCKCC    5    /* Lock given row
  518.                  ** (if only inside a transaction)
  519.                  */
  520.  
  521.  
  522. /*
  523.  ** Following value can be passed to the dbcursorbind function for NOBIND
  524.  **   type.
  525.  */
  526. #define NOBIND        -2        /* Return length and pointer to data */
  527.