home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / dbmsg / sql / ods / xp_odbc / odbcss.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-10-14  |  10.4 KB  |  292 lines

  1. /*
  2. ** ODBCSS.H - This is the application include file for the
  3. ** SQL Server driver specific defines.
  4. **
  5. ** (C) Copyright 1993-1996 By Microsoft Corp.
  6. **
  7. */
  8.  
  9. //    SQLSetConnectOption/SQLSetStmtOption driver specific defines.
  10. //    Microsoft has 1200 thru 1249 reserved for Microsoft SQL Server driver usage.
  11.  
  12. //    Connection Options
  13. #define SQL_COPT_SS_BASE                1200
  14. #define SQL_REMOTE_PWD                    (SQL_COPT_SS_BASE+1) // dbrpwset SQLSetConnectOption only
  15. #define SQL_USE_PROCEDURE_FOR_PREPARE    (SQL_COPT_SS_BASE+2) // Use create proc for SQLPrepare
  16. #define SQL_INTEGRATED_SECURITY         (SQL_COPT_SS_BASE+3) // Force integrated security on login
  17. #define SQL_PRESERVE_CURSORS            (SQL_COPT_SS_BASE+4) // Preserve server cursors after SQLTransact
  18. #define SQL_COPT_SS_USER_DATA            (SQL_COPT_SS_BASE+5) // dbgetuserdata/dbsetuserdata
  19. #define SQL_COPT_SS_ANSI_OEM            (SQL_COPT_SS_BASE+6) // dbsetopt/DBANSItoOEM/DBOEMtoANSI
  20. #define SQL_COPT_SS_ENLIST_IN_DTC        (SQL_COPT_SS_BASE+7) // Enlist in a Viper transaction
  21. #define SQL_COPT_SS_ENLIST_IN_XA        (SQL_COPT_SS_BASE+8) // Enlist in a XA transaction
  22. #define SQL_COPT_SS_CONNECTION_DEAD        (SQL_COPT_SS_BASE+9) // dbdead SQLGetConnectOption only
  23. #define SQL_COPT_SS_FALLBACK_CONNECT    (SQL_COPT_SS_BASE+10) // Enables FallBack connections
  24. #define SQL_COPT_SS_PERF_DATA            (SQL_COPT_SS_BASE+11) // Used to access SQL Server ODBC driver performance data
  25. #define SQL_COPT_SS_PERF_DATA_LOG        (SQL_COPT_SS_BASE+12) // Used to set the logfile name for the Performance data
  26. #define SQL_COPT_SS_PERF_QUERY_INTERVAL (SQL_COPT_SS_BASE+13) // Used to set the query logging threshold in milliseconds.
  27. #define SQL_COPT_SS_PERF_QUERY_LOG        (SQL_COPT_SS_BASE+14) // Used to set the logfile name for saving queryies.
  28. #define SQL_COPT_SS_PERF_QUERY            (SQL_COPT_SS_BASE+15) // Used to start and stop query logging.
  29. #define SQL_COPT_SS_PERF_DATA_LOG_NOW    (SQL_COPT_SS_BASE+16) // Used to make a statistics log entry to disk.
  30.  
  31. #define SQL_COPT_SS_MAX_USED            SQL_COPT_SS_PERF_DATA_LOG_NOW
  32.  
  33. //    Statement Options
  34. #define SQL_SOPT_SS_BASE                1225
  35. #define SQL_TEXTPTR_LOGGING             (SQL_SOPT_SS_BASE+0) // Text pointer logging
  36. #define SQL_SOPT_SS_CURRENT_COMMAND        (SQL_SOPT_SS_BASE+1) // dbcurcmd SQLGetStmtOption only
  37. #define SQL_SOPT_SS_MAX_USED            SQL_SOPT_SS_CURRENT_COMMAND
  38.  
  39.  
  40. //    Defines for use with SQL_USE_PROCEDURE_FOR_PREPARE
  41. #define SQL_UP_OFF        0L            //    Procedures won't be used for prepare
  42. #define SQL_UP_ON        1L            //    Procedures will be used for prepare
  43. #define SQL_UP_ON_DROP    2L            //    Temp procedures will be explicitly dropped
  44. #define SQL_UP_DEFAULT    SQL_UP_ON
  45.  
  46. //    Defines for use with SQL_INTEGRATED_SECURITY - only useable before connecting
  47. #define SQL_IS_OFF        0L            //    Integrated security isn't used
  48. #define SQL_IS_ON        1L            //    Integrated security is used
  49. #define SQL_IS_DEFAULT    SQL_IS_OFF
  50.  
  51. //    Defines for use with SQL_PRESERVE_CURSORS
  52. #define SQL_PC_OFF        0L            //    Cursors are closed on SQLTransact
  53. #define SQL_PC_ON        1L            //    Cursors remain open on SQLTransact
  54. #define SQL_PC_DEFAULT    SQL_PC_OFF
  55.  
  56. //    Defines for use with SQL_COPT_SS_USER_DATA
  57. #define SQL_UD_NOTSET    0L            //    No user data pointer set
  58.  
  59. //    Defines for use with SSQL_COPT_SS_ANSI_OEMQL_ANSI_OEM
  60. #define SQL_AO_OFF        0L            //    ANSI/OEM translation is not performed
  61. #define SQL_AO_ON        1L            //    ANSI/OEM translation is performed
  62. #define SQL_AO_DEFAULT    SQL_AO_OFF    //    Default unless DSN OEM/ANSI checkbox is checked
  63.  
  64. //    Defines for use with SQL_COPT_SS_CONNECTION_DEAD
  65. #define SQL_CD_FALSE    0L            //    Connection is open/available
  66. #define SQL_CD_TRUE        1L            //    Connection is closed/dead
  67.  
  68. //    Defines for use with SQL_COPT_SS_FALLBACK_CONNECT
  69. #define SQL_FB_OFF        0L            //    FallBack connections are disabled
  70. #define SQL_FB_ON        1L            //    FallBack connections are enabled
  71. #define SQL_FB_DEFAULT    SQL_FB_OFF
  72.  
  73. //    Defines for use with SQL_ENLIST_IN_DTC
  74. #define SQL_DTC_DONE    0L            //    Delimits end of Viper transaction
  75.  
  76. //    Defines for use with SQL_TEXTPTR_LOGGING
  77. #define SQL_TL_OFF        0L            //    No logging on text pointer ops
  78. #define SQL_TL_ON        1L            //    Logging occurs on text pointer ops
  79. #define SQL_TL_DEFAULT    SQL_TL_ON
  80.  
  81.  
  82. //    SQLColAttributes driver specific defines.
  83. //    SQLSet/GetDescField driver specific defines.
  84. //    Microsoft has 1200 thru 1249 reserved for Microsoft SQL Server driver usage.
  85.  
  86. #define SQL_CA_SS_BASE                1200
  87. #define SQL_CA_SS_COLUMN_SSTYPE        (SQL_CA_SS_BASE+0)    //    dbcoltype/dbaltcoltype
  88. #define SQL_CA_SS_COLUMN_UTYPE        (SQL_CA_SS_BASE+1)    //    dbcolutype/dbaltcolutype
  89. #define SQL_CA_SS_NUM_ORDERS        (SQL_CA_SS_BASE+2)    //    dbnumorders
  90. #define SQL_CA_SS_COLUMN_ORDER        (SQL_CA_SS_BASE+3)    //    dbcolorder
  91. #define SQL_CA_SS_COLUMN_VARYLEN    (SQL_CA_SS_BASE+4)    //    dbvarylen
  92. #define SQL_CA_SS_NUM_COMPUTES        (SQL_CA_SS_BASE+5)    //    dbnumcompute
  93. #define SQL_CA_SS_COMPUTE_ID        (SQL_CA_SS_BASE+6)    //    dbnextrow status return
  94. #define SQL_CA_SS_COMPUTE_BYLIST    (SQL_CA_SS_BASE+7)    //    dbbylist
  95. #define SQL_CA_SS_COLUMN_ID            (SQL_CA_SS_BASE+8)    //    dbaltcolid
  96. #define SQL_CA_SS_COLUMN_OP            (SQL_CA_SS_BASE+9)    //    dbaltcolop
  97. #define SQL_CA_SS_MAX_USED            SQL_CA_SS_COLUMN_OP
  98.  
  99. // SQL Server Data Type Tokens. Returned by SQLColAttributes/SQL_CA_SS_COLUMN_SSTYPE.
  100. #define SQLTEXT             0x23
  101. #define SQLVARBINARY        0x25
  102. #define SQLINTN             0x26
  103. #define SQLVARCHAR            0x27
  104. #define SQLBINARY            0x2d
  105. #define SQLIMAGE            0x22
  106. #define SQLCHARACTER        0x2f
  107. #define SQLINT1             0x30
  108. #define SQLBIT                0x32
  109. #define SQLINT2             0x34
  110. #define SQLINT4             0x38
  111. #define SQLMONEY            0x3c
  112. #define SQLDATETIME         0x3d
  113. #define SQLFLT8             0x3e
  114. #define SQLFLTN             0x6d
  115. #define SQLMONEYN            0x6e
  116. #define SQLDATETIMN         0x6f
  117. #define SQLFLT4             0x3b
  118. #define SQLMONEY4            0x7a
  119. #define SQLDATETIM4         0x3a
  120. #define SQLDECIMAL            0x37
  121. #define SQLDECIMALN            0x6a
  122. #define SQLNUMERIC            0x3f
  123. #define SQLNUMERICN         0x6c
  124.  
  125. //    User Data Type definitions. Returned by SQLColAttributes/SQL_CA_SS_COLUMN_UTYPE.
  126. #define SQLudtTEXT            19
  127. #define SQLudtVARBINARY     4
  128. #define SQLudtINTN            13
  129. #define SQLudtVARCHAR        2
  130. #define SQLudtBINARY        3
  131. #define SQLudtIMAGE         20
  132. #define SQLudtCHAR            1
  133. #define SQLudtINT1            5
  134. #define SQLudtBIT            16
  135. #define SQLudtINT2            6
  136. #define SQLudtINT4            7
  137. #define SQLudtMONEY         11
  138. #define SQLudtDATETIME        12
  139. #define SQLudtFLT8            8
  140. #define SQLudtFLTN            14
  141. #define SQLudtMONEYN        17
  142. #define SQLudtDATETIMN        15
  143. #define SQLudtSYSNAME        18
  144. #define SQLudtTIMESTAMP     80
  145. #define SQLudtFLT4            23
  146. #define SQLudtMONEY4        21
  147. #define SQLudtDATETIM4        22
  148. #define SQLudtDECML            24
  149. #define SQLudtDECMLN        26
  150. #define SQLudtNUM            10
  151. #define SQLudtNUMN            25
  152. #define MIN_USER_DATATYPE    100
  153.  
  154. // aggregate operator types (returned by SQLColAttributes/SQL_CA_SS_COLUMN_OP)
  155. #define SQLAOPCNT    0x4b
  156. #define SQLAOPSUM    0x4d
  157. #define SQLAOPAVG    0x4f
  158. #define SQLAOPMIN    0x51
  159. #define SQLAOPMAX    0x52
  160. #define SQLAOPANY    0x53
  161. #define SQLAOPNOOP    0x56
  162.  
  163.  
  164. //    SQLGetInfo driver specific defines.
  165. //    Microsoft has 1200 thru 1249 reserved for Microsoft SQL Server driver usage.
  166.  
  167. #define SQL_INFO_SS_FIRST        1200
  168. #define SQL_INFO_SS_NETLIB_NAME (SQL_INFO_SS_FIRST+0) //  dbprocinfo
  169. #define SQL_INFO_SS_MAX_USED    SQL_INFO_SS_NETLIB_NAME
  170.  
  171.  
  172. //    Internal server datatypes - used when binding to SQL_C_BINARY
  173. #ifndef MAXNUMERICLEN    // Resolve ODS/DBLib conflicts
  174. typedef struct dbmoney
  175. {                        // Internal representation of MONEY data type
  176.     LONG  mnyhigh;        // Money value *10,000 (High 32 bits/signed)
  177.     ULONG mnylow;        // Money value *10,000 (Low 32 bits/unsigned)
  178. } DBMONEY;
  179.  
  180. typedef struct dbdatetime
  181. {                        // Internal representation of DATETIME data type
  182.     LONG  dtdays;        // No of days since Jan-1-1900 (maybe negative)
  183.     ULONG dttime;        // No. of 300 hundredths of a second since midnight
  184. } DBDATETIME;
  185.  
  186. typedef struct dbdatetime4
  187. {                        // Internal representation of SMALLDATETIME data type
  188.     USHORT numdays;     // No of days since Jan-1-1900
  189.     USHORT nummins;     // No. of minutes since midnight
  190. } DBDATETIM4;
  191.  
  192. typedef LONG DBMONEY4;    // Internal representation of SMALLMONEY data type
  193.                         // Money value *10,000
  194.  
  195. #define MAXNUMERICLEN 16
  196.  
  197. #define DBNUM_PREC_TYPE BYTE
  198. #define DBNUM_SCALE_TYPE BYTE
  199. #define DBNUM_VAL_TYPE BYTE
  200.  
  201. typedef struct dbnumeric
  202. {                            // Internal representation of NUMERIC data type
  203.     DBNUM_PREC_TYPE   precision;            // Precision
  204.     DBNUM_SCALE_TYPE  scale;                // Scale
  205.     BYTE              sign;                 // Sign (1 if positive, 0 if negative)
  206.     DBNUM_VAL_TYPE      val[MAXNUMERICLEN];    // Value
  207. } DBNUMERIC;
  208.  
  209. typedef DBNUMERIC DBDECIMAL;// Internal representation of DECIMAL data type
  210. #endif //    MAXNUMERICLEN
  211.  
  212. /*****************************************************************
  213.  This struct is a global used for 
  214.  gathering statistal data on the driver.
  215.  Access to this struct is controled via the 
  216.  pStatCrit;
  217. ******************************************************************/
  218.  
  219. typedef struct sqlperf
  220. {
  221.     // Application Profile Statistics
  222.     DWORD TimerResolution;
  223.     DWORD SQLidu;
  224.     DWORD SQLiduRows;
  225.     DWORD SQLSelects;
  226.     DWORD SQLSelectRows;
  227.     DWORD Transactions;
  228.     DWORD SQLPrepares;
  229.     DWORD ExecDirects;
  230.     DWORD SQLExecutes;
  231.     DWORD CursorOpens;
  232.     DWORD CursorSize;
  233.     DWORD CursorUsed;
  234.     LDOUBLE PercentCursorUsed;
  235.     LDOUBLE AvgFetchTime;
  236.     LDOUBLE AvgCursorSize; 
  237.     LDOUBLE AvgCursorUsed;
  238.     DWORD SQLFetchTime;
  239.     DWORD SQLFetchCount;
  240.     DWORD CurrentStmtCount;
  241.     DWORD MaxOpenStmt;
  242.     DWORD SumOpenStmt;
  243.     
  244.     // Connection Statistics
  245.     DWORD CurrentConnectionCount;
  246.     DWORD MaxConnectionsOpened;
  247.     DWORD SumConnectionsOpened;
  248.     DWORD SumConnectiontime;
  249.     LDOUBLE AvgTimeOpened;
  250.  
  251.     // Network Statistics
  252.     DWORD ServerRndTrips;
  253.     DWORD BuffersSent;
  254.     DWORD BuffersRec;
  255.     DWORD BytesSent;
  256.     DWORD BytesRec;
  257.  
  258.     // Time Statistics;
  259.     DWORD msExecutionTime;
  260.     DWORD msNetWorkServerTime;
  261.  
  262. }     SQLPERF;
  263.  
  264. // The following are option for SQL_COPT_SS_PERF_DATA and SQL_COPT_SS_PERF_QUERY
  265. #define SQL_PERF_START    1            // Starts the driver sampling performance data.
  266. #define SQL_PERF_STOP    2            // Stops the counters from sampling performance data.
  267.  
  268. //    The following options have been deprecated
  269.  
  270. #define SQL_FAST_CONNECT                (SQL_COPT_SS_BASE+0)
  271. //    Defines for use with SQL_FAST_CONNECT - only useable before connecting
  272. #define SQL_FC_OFF        0L            //    Fast connect is off
  273. #define SQL_FC_ON        1L            //    Fast connect is on
  274. #define SQL_FC_DEFAULT    SQL_FC_OFF
  275.  
  276. /* 
  277.  
  278. The following data struct is used as the vParam with 
  279. SQL_COPT_SS_ENLIST_IN_XA to enlist in a XA stansaction
  280. when calling SQLSetStmtAttribute();
  281.  
  282. */
  283. typedef struct SQLXaTranTAG
  284. {
  285.     void FAR *transManager;
  286.     void FAR *xaTransID;
  287.     ULONG    xaTransIDLength;
  288.     DWORD   dwErrorInfo;
  289. } SQLXaTran;
  290.                            
  291. //    End of odbcss.h
  292.