' ########################################################################################
' Microsoft Windows
' File: odbcss.inc
' Contents: This is the application include file for the SQL Server driver specific defines.
' Copyright (c) 2011 Jos? Roca
' Portions Copyright (c) Microsoft Corporation.
' All Rights Reserved.
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
' EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
' MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
' ########################################################################################
#IF NOT %DEF(PBX_odbcss_PBI)
#DEFINE PBX_odbcss_PBI
%EQUATE `ODBCSS_INC = 1
#INCLUDE ONCE "Legacy/Data/sqlext.inc"
'// Useful defines
%EQUATE `SQL_MAX_SQLSERVERNAME = 128 ' // max SQL Server identifier length
'// SQLSetConnectOption/SQLSetStmtOption driver specific defines.
'// Microsoft has 1200 thru 1249 reserved for Microsoft SQL Server driver usage.
'// Connection Options
%EQUATE `SQL_COPT_SS_BASE = 1200
%EQUATE `SQL_COPT_SS_REMOTE_PWD = %SQL_COPT_SS_BASE+1 ' // dbrpwset SQLSetConnectOption only
%EQUATE `SQL_COPT_SS_USE_PROC_FOR_PREP = %SQL_COPT_SS_BASE+2 ' // Use create proc for SQLPrepare
%EQUATE `SQL_COPT_SS_INTEGRATED_SECURITY = %SQL_COPT_SS_BASE+3 ' // Force integrated security on login
%EQUATE `SQL_COPT_SS_PRESERVE_CURSORS = %SQL_COPT_SS_BASE+4 ' // Preserve server cursors after SQLTransact
%EQUATE `SQL_COPT_SS_USER_DATA = %SQL_COPT_SS_BASE+5 ' // dbgetuserdata/dbsetuserdata
%EQUATE `SQL_COPT_SS_ENLIST_IN_DTC = %SQL_ATTR_ENLIST_IN_DTC ' // Enlist in a DTC transaction
%EQUATE `SQL_COPT_SS_ENLIST_IN_XA = %SQL_ATTR_ENLIST_IN_XA ' // Enlist in a XA transaction
'//SQL_ATTR_CONNECTION_DEAD 1209 (It will return current connection status, it will not go to server
%EQUATE `SQL_COPT_SS_FALLBACK_CONNECT = %SQL_COPT_SS_BASE+10 ' // Enables FallBack connections
%EQUATE `SQL_COPT_SS_PERF_DATA = %SQL_COPT_SS_BASE+11 ' // Used to access SQL Server ODBC driver performance data
%EQUATE `SQL_COPT_SS_PERF_DATA_LOG = %SQL_COPT_SS_BASE+12 ' // Used to set the logfile name for the Performance data
%EQUATE `SQL_COPT_SS_PERF_QUERY_INTERVAL = %SQL_COPT_SS_BASE+13 ' // Used to set the query logging threshold in milliseconds.
%EQUATE `SQL_COPT_SS_PERF_QUERY_LOG = %SQL_COPT_SS_BASE+14 ' // Used to set the logfile name for saving queryies.
%EQUATE `SQL_COPT_SS_PERF_QUERY = %SQL_COPT_SS_BASE+15 ' // Used to start and stop query logging.
%EQUATE `SQL_COPT_SS_PERF_DATA_LOG_NOW = %SQL_COPT_SS_BASE+16 ' // Used to make a statistics log entry to disk.
%EQUATE `SQL_COPT_SS_QUOTED_IDENT = %SQL_COPT_SS_BASE+17 ' // Enable/Disable Quoted Identifiers
%EQUATE `SQL_COPT_SS_ANSI_NPW = %SQL_COPT_SS_BASE+18 ' // Enable/Disable ANSI NULL, Padding and Warnings
%EQUATE `SQL_COPT_SS_BCP = %SQL_COPT_SS_BASE+19 ' // Allow BCP usage on connection
%EQUATE `SQL_COPT_SS_TRANSLATE = %SQL_COPT_SS_BASE+20 ' // Perform code page translation
%EQUATE `SQL_COPT_SS_ATTACHDBFILENAME = %SQL_COPT_SS_BASE+21 ' // File name to be attached as a database
%EQUATE `SQL_COPT_SS_CONCAT_NULL = %SQL_COPT_SS_BASE+22 ' // Enable/Disable CONCAT_NULL_YIELDS_NULL
%EQUATE `SQL_COPT_SS_ENCRYPT = %SQL_COPT_SS_BASE+23 ' // Allow strong encryption for data
'%SQL_COPT_SS_MAX_USED = %SQL_COPT_SS_ENCRYPT
'// Statement Options
%EQUATE `SQL_SOPT_SS_BASE = 1225
%EQUATE `SQL_SOPT_SS_TEXTPTR_LOGGING = %SQL_SOPT_SS_BASE+0 ' // Text pointer logging
%EQUATE `SQL_SOPT_SS_CURRENT_COMMAND = %SQL_SOPT_SS_BASE+1 ' // dbcurcmd SQLGetStmtOption only
%EQUATE `SQL_SOPT_SS_HIDDEN_COLUMNS = %SQL_SOPT_SS_BASE+2 ' // Expose FOR BROWSE hidden columns
%EQUATE `SQL_SOPT_SS_NOBROWSETABLE = %SQL_SOPT_SS_BASE+3 ' // Set NOBROWSETABLE option
%EQUATE `SQL_SOPT_SS_REGIONALIZE = %SQL_SOPT_SS_BASE+4 ' // Regionalize output character conversions
%EQUATE `SQL_SOPT_SS_CURSOR_OPTIONS = %SQL_SOPT_SS_BASE+5 ' // Server cursor options
%EQUATE `SQL_SOPT_SS_NOCOUNT_STATUS = %SQL_SOPT_SS_BASE+6 ' // Real vs. Not Real row count indicator
%EQUATE `SQL_SOPT_SS_DEFER_PREPARE = %SQL_SOPT_SS_BASE+7 ' // Defer prepare until necessary
'%SQL_SOPT_SS_MAX_USED = %SQL_SOPT_SS_DEFER_PREPARE
%EQUATE `SQL_COPT_SS_BASE_EX = 1240
%EQUATE `SQL_COPT_SS_BROWSE_CONNECT = %SQL_COPT_SS_BASE_EX+1 ' // Browse connect mode of operation
%EQUATE `SQL_COPT_SS_BROWSE_SERVER = %SQL_COPT_SS_BASE_EX+2 ' // Single Server browse request.
%EQUATE `SQL_COPT_SS_WARN_ON_CP_ERROR = %SQL_COPT_SS_BASE_EX+3 ' // Issues warning when data from the server
 ' // had a loss during code page conversion.
%EQUATE `SQL_COPT_SS_CONNECTION_DEAD = %SQL_COPT_SS_BASE_EX+4 ' // dbdead SQLGetConnectOption only
 ' // It will try to ping the server.
 ' // Expensive connection check
%EQUATE `SQL_COPT_SS_BROWSE_CACHE_DATA = %SQL_COPT_SS_BASE_EX+5 ' //Determines if we should cache browse info
 ' //Used when returned buffer is greater then ODBC limit (32K
%EQUATE `SQL_COPT_SS_RESET_CONNECTION = %SQL_COPT_SS_BASE_EX+6 ' //When this option is set, we will perform connection reset
 ' //on next packet
'%SQL_COPT_SS_EX_MAX_USED = %SQL_COPT_SS_RESET_CONNECTION
'// Defines for use with SQL_COPT_SS_USE_PROC_FOR_PREP
%EQUATE `SQL_UP_OFF = 0& ' // Procedures won't be used for prepare
%EQUATE `SQL_UP_ON = 1& ' // Procedures will be used for prepare
%EQUATE `SQL_UP_ON_DROP = 2& ' // Temp procedures will be explicitly dropped
%EQUATE `SQL_UP_DEFAULT = %SQL_UP_ON
'// Defines for use with SQL_COPT_SS_INTEGRATED_SECURITY - Pre-Connect Option only
%EQUATE `SQL_IS_OFF = 0& ' // Integrated security isn't used
%EQUATE `SQL_IS_ON = 1& ' // Integrated security is used
%EQUATE `SQL_IS_DEFAULT = %SQL_IS_OFF
'// Defines for use with SQL_COPT_SS_PRESERVE_CURSORS
%EQUATE `SQL_PC_OFF = 0& ' // Cursors are closed on SQLTransact
%EQUATE `SQL_PC_ON = 1& ' // Cursors remain open on SQLTransact
%EQUATE `SQL_PC_DEFAULT = %SQL_PC_OFF
'// Defines for use with SQL_COPT_SS_USER_DATA
%EQUATE `SQL_UD_NOTSET = %NULL ' // No user data pointer set
'// Defines for use with SQL_COPT_SS_TRANSLATE
%EQUATE `SQL_XL_OFF = 0& ' // Code page translation is not performed
%EQUATE `SQL_XL_ON = 1& ' // Code page translation is performed
%EQUATE `SQL_XL_DEFAULT = %SQL_XL_ON
'// Defines for use with SQL_COPT_SS_FALLBACK_CONNECT - Pre-Connect Option only
%EQUATE `SQL_FB_OFF = 0& ' // FallBack connections are disabled
%EQUATE `SQL_FB_ON = 1& ' // FallBack connections are enabled
%EQUATE `SQL_FB_DEFAULT = %SQL_FB_OFF
'// Defines for use with SQL_COPT_SS_BCP - Pre-Connect Option only
%EQUATE `SQL_BCP_OFF = 0& ' // BCP is not allowed on connection
%EQUATE `SQL_BCP_ON = 1& ' // BCP is allowed on connection
%EQUATE `SQL_BCP_DEFAULT = %SQL_BCP_OFF
'// Defines for use with SQL_COPT_SS_QUOTED_IDENT
%EQUATE `SQL_QI_OFF = 0& ' // Quoted identifiers are enable
%EQUATE `SQL_QI_ON = 1& ' // Quoted identifiers are disabled
%EQUATE `SQL_QI_DEFAULT = %SQL_QI_ON
'// Defines for use with SQL_COPT_SS_ANSI_NPW - Pre-Connect Option only
%EQUATE `SQL_AD_OFF = 0& ' // ANSI NULLs, Padding and Warnings are enabled
%EQUATE `SQL_AD_ON = 1& ' // ANSI NULLs, Padding and Warnings are disabled
%EQUATE `SQL_AD_DEFAULT = %SQL_AD_ON
'// Defines for use with SQL_COPT_SS_CONCAT_NULL - Pre-Connect Option only
%EQUATE `SQL_CN_OFF = 0& ' // CONCAT_NULL_YIELDS_NULL is off
%EQUATE `SQL_CN_ON = 1& ' // CONCAT_NULL_YIELDS_NULL is on
%EQUATE `SQL_CN_DEFAULT = %SQL_CN_ON
'// Defines for use with SQL_SOPT_SS_TEXTPTR_LOGGING
%EQUATE `SQL_TL_OFF = 0& ' // No logging on text pointer ops
%EQUATE `SQL_TL_ON = 1& ' // Logging occurs on text pointer ops
%EQUATE `SQL_TL_DEFAULT = %SQL_TL_ON
'// Defines for use with SQL_SOPT_SS_HIDDEN_COLUMNS
%EQUATE `SQL_HC_OFF = 0& ' // FOR BROWSE columns are hidden
%EQUATE `SQL_HC_ON = 1& ' // FOR BROWSE columns are exposed
%EQUATE `SQL_HC_DEFAULT = %SQL_HC_OFF
'// Defines for use with SQL_SOPT_SS_NOBROWSETABLE
%EQUATE `SQL_NB_OFF = 0& ' // NO_BROWSETABLE is off
%EQUATE `SQL_NB_ON = 1& ' // NO_BROWSETABLE is on
%EQUATE `SQL_NB_DEFAULT = %SQL_NB_OFF
'// Defines for use with SQL_SOPT_SS_REGIONALIZE
%EQUATE `SQL_RE_OFF = 0& ' // No regionalization occurs on output character conversions
%EQUATE `SQL_RE_ON = 1& ' // Regionalization occurs on output character conversions
%EQUATE `SQL_RE_DEFAULT = %SQL_RE_OFF
'// Defines for use with SQL_SOPT_SS_CURSOR_OPTIONS
%EQUATE `SQL_CO_OFF = 0& ' // Clear all cursor options
%EQUATE `SQL_CO_FFO = 1& ' // Fast-forward cursor will be used
%EQUATE `SQL_CO_AF = 2& ' // Autofetch on cursor open
%EQUATE `SQL_CO_FFO_AF = %SQL_CO_FFO OR %SQL_CO_AF ' // Fast-forward cursor with autofetch
%EQUATE `SQL_CO_FIREHOSE_AF = 4& ' // Auto fetch on fire-hose cursors
%EQUATE `SQL_CO_DEFAULT = %SQL_CO_OFF
'//SQL_SOPT_SS_NOCOUNT_STATUS
%EQUATE `SQL_NC_OFF = 0&
%EQUATE `SQL_NC_ON = 1&
'//SQL_SOPT_SS_DEFER_PREPARE
%EQUATE `SQL_DP_OFF = 0&
%EQUATE `SQL_DP_ON = 1&
'//SQL_COPT_SS_ENCRYPT
%EQUATE `SQL_EN_OFF = 0&
%EQUATE `SQL_EN_ON = 1&
'//SQL_COPT_SS_BROWSE_CONNECT
%EQUATE `SQL_MORE_INFO_NO = 0&
%EQUATE `SQL_MORE_INFO_YES = 1&
'//SQL_COPT_SS_BROWSE_CACHE_DATA
%EQUATE `SQL_CACHE_DATA_NO = 0&
%EQUATE `SQL_CACHE_DATA_YES = 1&
'//SQL_COPT_SS_RESET_CONNECTION
%EQUATE `SQL_RESET_YES = 1&
'//SQL_COPT_SS_WARN_ON_CP_ERROR
%EQUATE `SQL_WARN_NO = 0&
%EQUATE `SQL_WARN_YES = 1&
'// Defines returned by SQL_ATTR_CURSOR_TYPE/SQL_CURSOR_TYPE
%EQUATE `SQL_CURSOR_FAST_FORWARD_ONLY = 8 ' // Only returned by SQLGetStmtAttr/Option
'// SQLColAttributes driver specific defines.
'// SQLSet/GetDescField driver specific defines.
'// Microsoft has 1200 thru 1249 reserved for Microsoft SQL Server driver usage.
%EQUATE `SQL_CA_SS_BASE = 1200
%EQUATE `SQL_CA_SS_COLUMN_SSTYPE = %SQL_CA_SS_BASE+0 ' // dbcoltype/dbalttype
%EQUATE `SQL_CA_SS_COLUMN_UTYPE = %SQL_CA_SS_BASE+1 ' // dbcolutype/dbaltutype
%EQUATE `SQL_CA_SS_NUM_ORDERS = %SQL_CA_SS_BASE+2 ' // dbnumorders
%EQUATE `SQL_CA_SS_COLUMN_ORDER = %SQL_CA_SS_BASE+3 ' // dbordercol
%EQUATE `SQL_CA_SS_COLUMN_VARYLEN = %SQL_CA_SS_BASE+4 ' // dbvarylen
%EQUATE `SQL_CA_SS_NUM_COMPUTES = %SQL_CA_SS_BASE+5 ' // dbnumcompute
%EQUATE `SQL_CA_SS_COMPUTE_ID = %SQL_CA_SS_BASE+6 ' // dbnextrow status return
%EQUATE `SQL_CA_SS_COMPUTE_BYLIST = %SQL_CA_SS_BASE+7 ' // dbbylist
%EQUATE `SQL_CA_SS_COLUMN_ID = %SQL_CA_SS_BASE+8 ' // dbaltcolid
%EQUATE `SQL_CA_SS_COLUMN_OP = %SQL_CA_SS_BASE+9 ' // dbaltop
%EQUATE `SQL_CA_SS_COLUMN_SIZE = %SQL_CA_SS_BASE+10 ' // dbcollen
%EQUATE `SQL_CA_SS_COLUMN_HIDDEN = %SQL_CA_SS_BASE+11 ' // Column is hidden (FOR BROWSE
%EQUATE `SQL_CA_SS_COLUMN_KEY = %SQL_CA_SS_BASE+12 ' // Column is key column (FOR BROWSE
' //%SQL_DESC_BASE_COLUMN_NAME_OLD = %SQL_CA_SS_BASE+13 ' // This is defined at another location.
%EQUATE `SQL_CA_SS_COLUMN_COLLATION = %SQL_CA_SS_BASE+14 ' // Column collation (only for chars
%EQUATE `SQL_CA_SS_VARIANT_TYPE = %SQL_CA_SS_BASE+15
%EQUATE `SQL_CA_SS_VARIANT_SQL_TYPE = %SQL_CA_SS_BASE+16
%EQUATE `SQL_CA_SS_VARIANT_SERVER_TYPE = %SQL_CA_SS_BASE+17
'%SQL_CA_SS_MAX_USED = %SQL_CA_SS_BASE+18
'// SQL Server Data Type Tokens.
'// New types for 6.0 and later servers
'/* SQL Server Data Type Tokens. */
%EQUATE `SQLTEXT = &H23
%EQUATE `SQLVARBINARY = &H25
%EQUATE `SQLINTN = &H26
%EQUATE `SQLVARCHAR = &H27
%EQUATE `SQLBINARY = &H2d
%EQUATE `SQLIMAGE = &H22
%EQUATE `SQLCHARACTER = &H2f
%EQUATE `SQLINT1 = &H30
%EQUATE `SQLBIT = &H32
%EQUATE `SQLINT2 = &H34
%EQUATE `SQLINT4 = &H38
%EQUATE `SQLMONEY = &H3c
%EQUATE `SQLDATETIME = &H3d
%EQUATE `SQLFLT8 = &H3e
%EQUATE `SQLFLTN = &H6d
%EQUATE `SQLMONEYN = &H6e
%EQUATE `SQLDATETIMN = &H6f
%EQUATE `SQLFLT4 = &H3b
%EQUATE `SQLMONEY4 = &H7a
%EQUATE `SQLDATETIM4 = &H3a
'// New types for 6.0 and later servers
%EQUATE `SQLDECIMAL = &H6a
%EQUATE `SQLNUMERIC = &H6c
'// New types for 7.0 and later servers
%EQUATE `SQLUNIQUEID = &H24
%EQUATE `SQLBIGCHAR = &Haf
%EQUATE `SQLBIGVARCHAR = &Ha7
%EQUATE `SQLBIGBINARY = &Had
%EQUATE `SQLBIGVARBINARY = &Ha5
%EQUATE `SQLBITN = &H68
%EQUATE `SQLNCHAR = &Hef
%EQUATE `SQLNVARCHAR = &He7
%EQUATE `SQLNTEXT = &H63
'// New for 7.x
%EQUATE `SQLINT8 = &H7f
%EQUATE `SQLVARIANT = &H62
'// User Data Type definitions.
'// Returned by SQLColAttributes/SQL_CA_SS_COLUMN_UTYPE.
%EQUATE `SQLudtBINARY = 3
%EQUATE `SQLudtBIT = 16
%EQUATE `SQLudtBITN = 0
%EQUATE `SQLudtCHAR = 1
%EQUATE `SQLudtDATETIM4 = 22
%EQUATE `SQLudtDATETIME = 12
%EQUATE `SQLudtDATETIMN = 15
%EQUATE `SQLudtDECML = 24
%EQUATE `SQLudtDECMLN = 26
%EQUATE `SQLudtFLT4 = 23
%EQUATE `SQLudtFLT8 = 8
%EQUATE `SQLudtFLTN = 14
%EQUATE `SQLudtIMAGE = 20
%EQUATE `SQLudtINT1 = 5
%EQUATE `SQLudtINT2 = 6
%EQUATE `SQLudtINT4 = 7
%EQUATE `SQLudtINTN = 13
%EQUATE `SQLudtMONEY = 11
%EQUATE `SQLudtMONEY4 = 21
%EQUATE `SQLudtMONEYN = 17
%EQUATE `SQLudtNUM = 10
%EQUATE `SQLudtNUMN = 25
%EQUATE `SQLudtSYSNAME = 18
%EQUATE `SQLudtTEXT = 19
%EQUATE `SQLudtTIMESTAMP = 80
%EQUATE `SQLudtUNIQUEIDENTIFIER = 0
%EQUATE `SQLudtVARBINARY = 4
%EQUATE `SQLudtVARCHAR = 2
%EQUATE `MIN_USER_DATATYPE = 256
'// Aggregate operator types.
'// Returned by SQLColAttributes/SQL_CA_SS_COLUMN_OP.
%EQUATE `SQLAOPSTDEV = &H30 ' // Standard deviation
%EQUATE `SQLAOPSTDEVP = &H31 ' // Standard deviation population
%EQUATE `SQLAOPVAR = &H32 ' // Variance
%EQUATE `SQLAOPVARP = &H33 ' // Variance population
%EQUATE `SQLAOPCNT = &H4b ' // Count
%EQUATE `SQLAOPSUM = &H4d ' // Sum
%EQUATE `SQLAOPAVG = &H4f ' // Average
%EQUATE `SQLAOPMIN = &H51 ' // Min
%EQUATE `SQLAOPMAX = &H52 ' // Max
%EQUATE `SQLAOPANY = &H53 ' // Any
%EQUATE `SQLAOPNOOP = &H56 ' // None
'// SQLGetInfo driver specific defines.
'// Microsoft has 1151 thru 1200 reserved for Microsoft SQL Server driver usage.
%EQUATE `SQL_INFO_SS_FIRST = 1199
%EQUATE `SQL_INFO_SS_NETLIB_NAMEW = %SQL_INFO_SS_FIRST+0 ' // dbprocinfo
%EQUATE `SQL_INFO_SS_NETLIB_NAMEA = %SQL_INFO_SS_FIRST+1 ' // dbprocinfo
%EQUATE `SQL_INFO_SS_MAX_USED = %SQL_INFO_SS_NETLIB_NAMEA
'#ifdef UNICODE
'%SQL_INFO_SS_NETLIB_NAME = %SQL_INFO_SS_NETLIB_NAMEW
'#else
'%SQL_INFO_SS_NETLIB_NAME = %SQL_INFO_SS_NETLIB_NAMEA
'#endif
%EQUATE `SQL_INFO_SS_NETLIB_NAME = %SQL_INFO_SS_NETLIB_NAMEA
'// Driver specific SQL type defines.
'// Microsoft has -150 thru -199 reserved for Microsoft SQL Server driver usage.
%EQUATE `SQL_SS_VARIANT = -150
'// SQLGetDiagField driver specific defines.
'// Microsoft has -1150 thru -1199 reserved for Microsoft SQL Server driver usage.
%EQUATE `SQL_DIAG_SS_BASE = -1150
%EQUATE `SQL_DIAG_SS_MSGSTATE = %SQL_DIAG_SS_BASE
%EQUATE `SQL_DIAG_SS_SEVERITY = %SQL_DIAG_SS_BASE-1
%EQUATE `SQL_DIAG_SS_SRVNAME = %SQL_DIAG_SS_BASE-2
%EQUATE `SQL_DIAG_SS_PROCNAME = %SQL_DIAG_SS_BASE-3
%EQUATE `SQL_DIAG_SS_LINE = %SQL_DIAG_SS_BASE-4
'// SQLGetDiagField/SQL_DIAG_DYNAMIC_FUNCTION_CODE driver specific defines.
'// Microsoft has -200 thru -299 reserved for Microsoft SQL Server driver usage.
%EQUATE `SQL_DIAG_DFC_SS_BASE = -200
%EQUATE `SQL_DIAG_DFC_SS_ALTER_DATABASE = %SQL_DIAG_DFC_SS_BASE - 0
%EQUATE `SQL_DIAG_DFC_SS_CHECKPOINT = %SQL_DIAG_DFC_SS_BASE - 1
%EQUATE `SQL_DIAG_DFC_SS_CONDITION = %SQL_DIAG_DFC_SS_BASE - 2
%EQUATE `SQL_DIAG_DFC_SS_CREATE_DATABASE = %SQL_DIAG_DFC_SS_BASE - 3
%EQUATE `SQL_DIAG_DFC_SS_CREATE_DEFAULT = %SQL_DIAG_DFC_SS_BASE - 4
%EQUATE `SQL_DIAG_DFC_SS_CREATE_PROCEDURE = %SQL_DIAG_DFC_SS_BASE - 5
%EQUATE `SQL_DIAG_DFC_SS_CREATE_RULE = %SQL_DIAG_DFC_SS_BASE - 6
%EQUATE `SQL_DIAG_DFC_SS_CREATE_TRIGGER = %SQL_DIAG_DFC_SS_BASE - 7
%EQUATE `SQL_DIAG_DFC_SS_CURSOR_DECLARE = %SQL_DIAG_DFC_SS_BASE - 8
%EQUATE `SQL_DIAG_DFC_SS_CURSOR_OPEN = %SQL_DIAG_DFC_SS_BASE - 9
%EQUATE `SQL_DIAG_DFC_SS_CURSOR_FETCH = %SQL_DIAG_DFC_SS_BASE - 10
%EQUATE `SQL_DIAG_DFC_SS_CURSOR_CLOSE = %SQL_DIAG_DFC_SS_BASE - 11
%EQUATE `SQL_DIAG_DFC_SS_DEALLOCATE_CURSOR = %SQL_DIAG_DFC_SS_BASE - 12
%EQUATE `SQL_DIAG_DFC_SS_DBCC = %SQL_DIAG_DFC_SS_BASE - 13
%EQUATE `SQL_DIAG_DFC_SS_DISK = %SQL_DIAG_DFC_SS_BASE - 14
%EQUATE `SQL_DIAG_DFC_SS_DROP_DATABASE = %SQL_DIAG_DFC_SS_BASE - 15
%EQUATE `SQL_DIAG_DFC_SS_DROP_DEFAULT = %SQL_DIAG_DFC_SS_BASE - 16
%EQUATE `SQL_DIAG_DFC_SS_DROP_PROCEDURE = %SQL_DIAG_DFC_SS_BASE - 17
%EQUATE `SQL_DIAG_DFC_SS_DROP_RULE = %SQL_DIAG_DFC_SS_BASE - 18
%EQUATE `SQL_DIAG_DFC_SS_DROP_TRIGGER = %SQL_DIAG_DFC_SS_BASE - 19
%EQUATE `SQL_DIAG_DFC_SS_DUMP_DATABASE = %SQL_DIAG_DFC_SS_BASE - 20
%EQUATE `SQL_DIAG_DFC_SS_DUMP_TABLE = %SQL_DIAG_DFC_SS_BASE - 21
%EQUATE `SQL_DIAG_DFC_SS_DUMP_TRANSACTION = %SQL_DIAG_DFC_SS_BASE - 22
%EQUATE `SQL_DIAG_DFC_SS_GOTO = %SQL_DIAG_DFC_SS_BASE - 23
%EQUATE `SQL_DIAG_DFC_SS_INSERT_BULK = %SQL_DIAG_DFC_SS_BASE - 24
%EQUATE `SQL_DIAG_DFC_SS_KILL = %SQL_DIAG_DFC_SS_BASE - 25
%EQUATE `SQL_DIAG_DFC_SS_LOAD_DATABASE = %SQL_DIAG_DFC_SS_BASE - 26
%EQUATE `SQL_DIAG_DFC_SS_LOAD_HEADERONLY = %SQL_DIAG_DFC_SS_BASE - 27
%EQUATE `SQL_DIAG_DFC_SS_LOAD_TABLE = %SQL_DIAG_DFC_SS_BASE - 28
%EQUATE `SQL_DIAG_DFC_SS_LOAD_TRANSACTION = %SQL_DIAG_DFC_SS_BASE - 29
%EQUATE `SQL_DIAG_DFC_SS_PRINT = %SQL_DIAG_DFC_SS_BASE - 30
%EQUATE `SQL_DIAG_DFC_SS_RAISERROR = %SQL_DIAG_DFC_SS_BASE - 31
%EQUATE `SQL_DIAG_DFC_SS_READTEXT = %SQL_DIAG_DFC_SS_BASE - 32
%EQUATE `SQL_DIAG_DFC_SS_RECONFIGURE = %SQL_DIAG_DFC_SS_BASE - 33
%EQUATE `SQL_DIAG_DFC_SS_RETURN = %SQL_DIAG_DFC_SS_BASE - 34
%EQUATE `SQL_DIAG_DFC_SS_SELECT_INTO = %SQL_DIAG_DFC_SS_BASE - 35
%EQUATE `SQL_DIAG_DFC_SS_SET = %SQL_DIAG_DFC_SS_BASE - 36
%EQUATE `SQL_DIAG_DFC_SS_SET_IDENTITY_INSERT = %SQL_DIAG_DFC_SS_BASE - 37
%EQUATE `SQL_DIAG_DFC_SS_SET_ROW_COUNT = %SQL_DIAG_DFC_SS_BASE - 38
%EQUATE `SQL_DIAG_DFC_SS_SET_STATISTICS = %SQL_DIAG_DFC_SS_BASE - 39
%EQUATE `SQL_DIAG_DFC_SS_SET_TEXTSIZE = %SQL_DIAG_DFC_SS_BASE - 40
%EQUATE `SQL_DIAG_DFC_SS_SETUSER = %SQL_DIAG_DFC_SS_BASE - 41
%EQUATE `SQL_DIAG_DFC_SS_SHUTDOWN = %SQL_DIAG_DFC_SS_BASE - 42
%EQUATE `SQL_DIAG_DFC_SS_TRANS_BEGIN = %SQL_DIAG_DFC_SS_BASE - 43
%EQUATE `SQL_DIAG_DFC_SS_TRANS_COMMIT = %SQL_DIAG_DFC_SS_BASE - 44
%EQUATE `SQL_DIAG_DFC_SS_TRANS_PREPARE = %SQL_DIAG_DFC_SS_BASE - 45
%EQUATE `SQL_DIAG_DFC_SS_TRANS_ROLLBACK = %SQL_DIAG_DFC_SS_BASE - 46
%EQUATE `SQL_DIAG_DFC_SS_TRANS_SAVE = %SQL_DIAG_DFC_SS_BASE - 47
%EQUATE `SQL_DIAG_DFC_SS_TRUNCATE_TABLE = %SQL_DIAG_DFC_SS_BASE - 48
%EQUATE `SQL_DIAG_DFC_SS_UPDATE_STATISTICS = %SQL_DIAG_DFC_SS_BASE - 49
%EQUATE `SQL_DIAG_DFC_SS_UPDATETEXT = %SQL_DIAG_DFC_SS_BASE - 50
%EQUATE `SQL_DIAG_DFC_SS_USE = %SQL_DIAG_DFC_SS_BASE - 51
%EQUATE `SQL_DIAG_DFC_SS_WAITFOR = %SQL_DIAG_DFC_SS_BASE - 52
%EQUATE `SQL_DIAG_DFC_SS_WRITETEXT = %SQL_DIAG_DFC_SS_BASE - 53
%EQUATE `SQL_DIAG_DFC_SS_DENY = %SQL_DIAG_DFC_SS_BASE - 54
%EQUATE `SQL_DIAG_DFC_SS_SET_XCTLVL = %SQL_DIAG_DFC_SS_BASE - 55
'// Severity codes for SQL_DIAG_SS_SEVERITY
%EQUATE `EX_ANY = 0
%EQUATE `EX_INFO = 10
%EQUATE `EX_MAXISEVERITY = %EX_INFO
%EQUATE `EX_MISSING = 11
%EQUATE `EX_TYPE = 12
%EQUATE `EX_DEADLOCK = 13
%EQUATE `EX_PERMIT = 14
%EQUATE `EX_SYNTAX = 15
%EQUATE `EX_USER = 16
%EQUATE `EX_RESOURCE = 17
%EQUATE `EX_INTOK = 18
%EQUATE `MAXUSEVERITY = %EX_INTOK
%EQUATE `EX_LIMIT = 19
%EQUATE `EX_CMDFATAL = 20
%EQUATE `MINFATALERR = %EX_CMDFATAL
%EQUATE `EX_DBFATAL = 21
%EQUATE `EX_TABCORRUPT = 22
%EQUATE `EX_DBCORRUPT = 23
%EQUATE `EX_HARDWARE = 24
%EQUATE `EX_CONTROL = 25
'// Internal server datatypes - used when binding to SQL_C_BINARY
#IF NOT %DEF(%MAXNUMERICLEN) ' // Resolve ODS/DBLib conflicts
'// DB-Library datatypes
%EQUATE `DBMAXCHAR = 8000+1 ' // Max length of DBVARBINARY and DBVARCHAR, etc. +1 for zero byte
%EQUATE `MAXNAME = %SQL_MAX_SQLSERVERNAME+1 ' // Max server identifier length including zero byte
'#ifdef UNICODE
'typedef wchar_t DBCHAR;
'#else
'typedef char DBCHAR;
'#endif
'typedef unsigned char DBBINARY;
'typedef unsigned char DBTINYINT;
'typedef short DBSMALLINT;
'typedef unsigned short DBUSMALLINT;
'typedef double DBFLT8;
'typedef unsigned char DBBIT;
'typedef unsigned char DBBOOL;
'typedef float DBFLT4;
'typedef DBFLT4 DBREAL;
'typedef UINT DBUBOOL;
' // Size = 8004 bytes
TYPE DBVARYCHARA WORD
 len AS WORD ' DBSMALLINT
 str AS STRING * %DBMAXCHAR ' DBCHAR
END TYPE
' // Size = 16005 bytes
TYPE DBVARYCHARW WORD
 len AS WORD ' DBSMALLINT
 str AS WSTRINGZ * %DBMAXCHAR ' DBCHAR
END TYPE
#IF %DEF(%UNICODE)
 MACRO DBVARYCHAR = DBVARYCHARW
#ELSE
 MACRO DBVARYCHAR = DBVARYCHARA
#ENDIF
' // Size = 8004 bytes
TYPE DBVARYBIN WORD
 len AS WORD ' DBSMALLINT
 array(%DBMAXCHAR - 1) AS BYTE ' BYTE
END TYPE
' // Size = 8 bytes
TYPE DBMONEY DWORD
 mnyhigh AS LONG ' LONG // Money value *10,000 (High 32 bits/signed)
 mnylow AS DWORD ' ULONG // Money value *10,000 (Low 32 bits/unsigned)
END TYPE
' // Size = 8 bytes
TYPE DBDATETIME DWORD
 ' // Internal representation of DATETIME data type
 dtdays AS LONG ' LONG // No of days since Jan-1-1900 (maybe negative)
 dttime AS DWORD ' ULONG // No. of 300 hundredths of a second since midnight
END TYPE
' // Size = 4 bytes
TYPE DBDATETIM4 WORD
 ' // Internal representation of SMALLDATETIME data type
 numdays AS WORD ' USHORT // No of days since Jan-1-1900
 nummins AS WORD ' USHORT // No. of minutes since midnight
END TYPE
'typedef LONG DBMONEY4; // Internal representation of SMALLMONEY data type
' // Money value *10,000
'#define DBNUM_PREC_TYPE BYTE
'#define DBNUM_SCALE_TYPE BYTE
'#define DBNUM_VAL_TYPE BYTE
#IF %ODBCVER < &H0300
%EQUATE `MAXNUMERICLEN = 16
' // Size = 19 bytes
TYPE DBNUMERIC BYTE
 ' // Internal representation of NUMERIC data type
 precision AS BYTE ' DBNUM_PREC_TYPE // Precision
 scale AS BYTE ' DBNUM_SCALE_TYPE // Scale
 sign AS BYTE ' BYTE // Sign (1 if positive, 0 if negative)
' val(%MAXNUMERICLEN-1) AS BYTE ' DBNUM_VAL_TYPE // Value
 val AS STRING * %MAXNUMERICLEN
END TYPE
'typedef DBNUMERIC DBDECIMAL;// Internal representation of DECIMAL data type
' // Size = 19 bytes
TYPE DBDECIMAL BYTE
 ' // Internal representation of NUMERIC data type
 precision AS BYTE ' DBNUM_PREC_TYPE // Precision
 scale AS BYTE ' DBNUM_SCALE_TYPE // Scale
 sign AS BYTE ' BYTE // Sign (1 if positive, 0 if negative)
' val(%MAXNUMERICLEN-1) AS BYTE ' DBNUM_VAL_TYPE // Value
 val AS STRING * %MAXNUMERICLEN
END TYPE
#ELSE ' // Use ODBC 3.0 definitions since same as DBLib
%EQUATE `MAXNUMERICLEN = %SQL_MAX_NUMERIC_LEN
'typedef SQL_NUMERIC_STRUCT DBNUMERIC;
'typedef SQL_NUMERIC_STRUCT DBDECIMAL;
' // Size = 19 bytes
TYPE DBNUMERIC BYTE
 precision AS BYTE
 scale AS BYTE
 sign AS BYTE
 val AS STRING * %SQL_MAX_NUMERIC_LEN
END TYPE
' // Size = 19 bytes
TYPE DBDECIMAL BYTE
 precision AS BYTE
 scale AS BYTE
 sign AS BYTE
 val AS STRING * %SQL_MAX_NUMERIC_LEN
END TYPE
#ENDIF
#ENDIF ' // MAXNUMERICLEN
'#ifndef INT
'typedef int INT;
'typedef long DBINT;
'#ifndef _LPCBYTE_DEFINED
'#define _LPCBYTE_DEFINED
'typedef const LPBYTE LPCBYTE;
'#endif
'typedef DBINT * LPDBINT;
'#endif
'/*****************************************************************
' This struct is a global used for
' gathering statistical data on the driver.
' Access to this structure is controlled via the
' pStatCrit;
'******************************************************************/
' // Size = 160 bytes
TYPE SQLPERF ' Must be 8 byte aligned
 ' // Application Profile Statistics
 TimerResolution AS DWORD
 SQLidu AS DWORD
 SQLiduRows AS DWORD
 SQLSelects AS DWORD
 SQLSelectRows AS DWORD
 Transactions AS DWORD
 SQLPrepares AS DWORD
 ExecDirects AS DWORD
 SQLExecutes AS DWORD
 CursorOpens AS DWORD
 CursorSize AS DWORD
 CursorUsed AS DWORD
 PercentCursorUsed AS DOUBLE ' LDOUBLE
 AvgFetchTime AS DOUBLE ' LDOUBLE
 AvgCursorSize AS DOUBLE ' LDOUBLE
 AvgCursorUsed AS DOUBLE ' LDOUBLE
 SQLFetchTime AS DWORD
 SQLFetchCount AS DWORD
 CurrentStmtCount AS DWORD
 MaxOpenStmt AS DWORD
 SumOpenStmt AS DWORD
 ' // Connection Statistics
 CurrentConnectionCount AS DWORD
 MaxConnectionsOpened AS DWORD
 SumConnectionsOpened AS DWORD
 SumConnectiontime AS DWORD
 alignment1__ AS DWORD ' // o keep 8 byte alignment
 AvgTimeOpened AS DOUBLE ' LDOUBLE
 ' // Network Statistics
 ServerRndTrips AS DWORD
 BuffersSent AS DWORD
 BuffersRec AS DWORD
 BytesSent AS DWORD
 BytesRec AS DWORD
 ' // Time Statistics
 msExecutionTime AS DWORD
 msNetWorkServerTime AS DWORD
 alignment2__ AS DWORD ' // o keep 8 byte alignment
END TYPE
'// The following are options for SQL_COPT_SS_PERF_DATA and SQL_COPT_SS_PERF_QUERY
%EQUATE `SQL_PERF_START = 1 ' // Starts the driver sampling performance data.
%EQUATE `SQL_PERF_STOP = 2 ' // Stops the counters from sampling performance data.
'// The following are defines for SQL_COPT_SS_PERF_DATA_LOG
'#define SQL_SS_DL_DEFAULT TEXT("STATS.LOG")
$$SQL_SS_DL_DEFAULT = "STATS.LOG"$$
'// The following are defines for SQL_COPT_SS_PERF_QUERY_LOG
'#define SQL_SS_QL_DEFAULT TEXT("QUERY.LOG")
$$SQL_SS_QL_DEFAULT = "QUERY.LOG"$$
'// The following are defines for SQL_COPT_SS_PERF_QUERY_INTERVAL
%EQUATE `SQL_SS_QI_DEFAULT = 30000 ' // 30,000 milliseconds
'// ODBC BCP prototypes and defines
'// Return codes
%EQUATE `SUCCEED = 1
%EQUATE `FAIL = 0
%EQUATE `SUCCEED_ABORT = 2
%EQUATE `SUCCEED_ASYNC = 3
'// Transfer directions
%EQUATE `DB_IN = 1 ' // Transfer from client to server
%EQUATE `DB_OUT = 2 ' // Transfer from server to client
'// bcp_control option
%EQUATE `BCPMAXERRS = 1 ' // Sets max errors allowed
%EQUATE `BCPFIRST = 2 ' // Sets first row to be copied out
%EQUATE `BCPLAST = 3 ' // Sets number of rows to be copied out
%EQUATE `BCPBATCH = 4 ' // Sets input batch size
%EQUATE `BCPKEEPNULLS = 5 ' // Sets to insert NULLs for empty input values
%EQUATE `BCPABORT = 6 ' // Sets to have bcpexec return SUCCEED_ABORT
%EQUATE `BCPODBC = 7 ' // Sets ODBC canonical character output
%EQUATE `BCPKEEPIDENTITY = 8 ' // Sets IDENTITY_INSERT on
%EQUATE `BCP6xFILEFMT = 9 ' // DEPRECATED: Sets 6x file format on
%EQUATE `BCPHINTSA = 10 ' // Sets server BCP hints (ANSI string)
%EQUATE `BCPHINTSW = 11 ' // Sets server BCP hints (UNICODE string)
%EQUATE `BCPFILECP = 12 ' // Sets clients code page for the file
%EQUATE `BCPUNICODEFILE = 13 ' // Sets that the file contains unicode header
%EQUATE `BCPTEXTFILE = 14 ' // Sets BCP mode to expect a text file and to detect Unicode or ANSI automatically
%EQUATE `BCPFILEFMT = 15 ' // Sets file format version
#IF %DEF(%UNICODE)
 %BCPHINTS = %BCPHINTSW
#ELSE
 %BCPHINTS = %BCPHINTSA
#ENDIF
'// BCPFILECP values
'// Any valid code page that is installed on the client can be passed plus:
%EQUATE `BCPFILECP_ACP = 0 ' // Data in file is in Windows code page
%EQUATE `BCPFILECP_OEMCP = 1 ' // Data in file is in OEM code page (default)
%EQUATE `BCPFILECP_RAW = -1 ' // Data in file is in Server code page (no conversion)
'// bcp_collen definition
%EQUATE `SQL_VARLEN_DATA = -10 ' // Use default length for column
'// BCP functions
DECLARE FUNCTION bcp_batch LIB "odbcbcp.dll" ALIAS "bcp_batch" ( BYVAL hdbc AS QUAD ) AS LONG ' DBINT
DECLARE FUNCTION bcp_bind LIB "odbcbcp.dll" ALIAS "bcp_bind" ( BYVAL hdbc AS QUAD , BYVAL pData AS BYTE PTR , BYVAL cbIndicator AS LONG , BYVAL cbData AS LONG , BYVAL pTerm AS BYTE PTR , BYVAL cbTerm AS LONG , BYVAL eDataType AS LONG , BYVAL idxServerCol AS LONG ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_colfmt LIB "odbcbcp.dll" ALIAS "bcp_colfmt" ( BYVAL hdbc AS QUAD , BYVAL idxUserDataCol AS LONG , BYVAL eUserDataType AS BYTE , BYVAL cbIndicator AS LONG , BYVAL cbUserData AS LONG , BYVAL pUserDataTerm AS BYTE PTR , BYVAL cbUserDataTerm AS LONG , BYVAL idxServerCol AS LONG ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_collen LIB "odbcbcp.dll" ALIAS "bcp_collen" ( BYVAL hdbc AS QUAD , BYVAL cbData AS LONG , BYVAL idxServerCol AS LONG ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_colptr LIB "odbcbcp.dll" ALIAS "bcp_colptr" ( BYVAL hdbc AS QUAD , BYVAL pData AS BYTE PTR , BYVAL idxServerCol AS LONG ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_columns LIB "odbcbcp.dll" ALIAS "bcp_columns" ( BYVAL hdbc AS QUAD , BYVAL nColumns AS LONG ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_control LIB "odbcbcp.dll" ALIAS "bcp_control" ( BYVAL hdbc AS QUAD , BYVAL eOption AS LONG , BYVAL iValue AS QUAD ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_done LIB "odbcbcp.dll" ALIAS "bcp_done" ( BYVAL hdbc AS QUAD ) AS LONG ' DBINT
DECLARE FUNCTION bcp_exec LIB "odbcbcp.dll" ALIAS "bcp_exec" ( BYVAL hdbc AS QUAD , BYREF pnRowsProcessed AS LONG ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_getcolfmt LIB "odbcbcp.dll" ALIAS "bcp_getcolfmt" ( BYVAL hdbc AS QUAD , BYVAL field AS LONG , BYVAL property AS LONG , BYREF pValue AS ANY , BYVAL cbvalue AS LONG , BYREF pcbLen AS LONG ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_initA LIB "odbcbcp.dll" ALIAS "bcp_initA" ( BYVAL hdbc AS QUAD , BYREF szTable AS ASCIIZ , BYREF szDataFile AS ASCIIZ , BYREF szErrorFile AS ASCIIZ , BYVAL eDirection AS LONG ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_initW LIB "odbcbcp.dll" ALIAS "bcp_initW" ( BYREF hdbc AS QUAD , BYREF szTable AS WSTRINGZ , BYREF szDataFile AS WSTRINGZ , BYREF szErrorFile AS WSTRINGZ , BYVAL eDirection AS LONG ) AS LONG ' RETCODE
#IF %DEF(%UNICODE)
 MACRO bcp_init = bcp_initW
#ELSE
 MACRO bcp_init = bcp_initA
#ENDIF
DECLARE FUNCTION bcp_moretext LIB "odbcbcp.dll" ALIAS "bcp_moretext" ( BYVAL hdbc AS QUAD , BYVAL cbData AS LONG , BYVAL pData AS BYTE PTR ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_readfmtA LIB "odbcbcp.dll" ALIAS "bcp_readfmtA" ( BYVAL hdbc AS QUAD , BYREF szFormatFile AS ASCIIZ ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_readfmtW LIB "odbcbcp.dll" ALIAS "bcp_readfmtW" ( BYVAL hdbc AS QUAD , BYREF szFormatFile AS WSTRINGZ ) AS LONG ' RETCODE
#IF %DEF(%UNICODE)
 MACRO bcp_readfmt = bcp_readfmtW
#ELSE
 MACRO bcp_readfmt = bcp_readfmtA
#ENDIF
DECLARE FUNCTION bcp_sendrow LIB "odbcbcp.dll" ALIAS "bcp_sendrow" ( BYVAL hdbc AS QUAD ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_setcolfmt LIB "odbcbcp.dll" ALIAS "bcp_setcolfmt" ( BYVAL hdbc AS QUAD , BYVAL field AS LONG , BYVAL property AS LONG , BYREF pValue AS ANY , BYVAL cbValue AS LONG ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_writefmtA LIB "odbcbcp.dll" ALIAS "bcp_writefmtA" ( BYVAL hdbc AS QUAD , BYREF szFormatFile AS ASCIIZ ) AS LONG ' RETCODE
DECLARE FUNCTION bcp_writefmtW LIB "odbcbcp.dll" ALIAS "bcp_writefmtW" ( BYVAL hdbc AS QUAD , BYREF szFormatFile AS WSTRINGZ ) AS LONG ' RETCODE
#IF %DEF(%UNICODE)
 MACRO bcp_writefmt = bcp_writefmtW
#ELSE
 MACRO bcp_writefmt = bcp_writefmtA
#ENDIF
DECLARE FUNCTION dbprtypeA LIB "odbcbcp.dll" ALIAS "dbprtypeA" ( BYVAL token AS LONG ) AS QUAD ' CHAR *
DECLARE FUNCTION dbprtypeW LIB "odbcbcp.dll" ALIAS "dbprtypeW" ( BYVAL token AS LONG ) AS QUAD ' WCHAR *
#IF %DEF(%UNICODE)
 MACRO dbprtype = dbprtypeW
#ELSE
 MACRO dbprtype = dbprtypeA
#ENDIF
'#ifdef UNICODE
'#define bcp_init bcp_initW
'#define bcp_readfmt bcp_readfmtW
'#define bcp_writefmt bcp_writefmtW
'#define dbprtype dbprtypeW
'#define BCPHINTS BCPHINTSW
'#else
'#define bcp_init bcp_initA
'#define bcp_readfmt bcp_readfmtA
'#define bcp_writefmt bcp_writefmtA
'#define dbprtype dbprtypeA
'#define BCPHINTS BCPHINTSA
'#endif
'// SQL Server catalog extensions for distributed queries
DECLARE FUNCTION SQLLinkedServers LIB "odbcbcp.dll" ALIAS "SQLLinkedServers" ( BYVAL hstmt AS QUAD ) AS INTEGER ' SQLRETURN
DECLARE FUNCTION SQLLinkedCatalogsA LIB "odbcbcp.dll" ALIAS "SQLLinkedCatalogsA" ( BYVAL hstmt AS QUAD , BYREF ServerName AS ASCIIZ , BYVAL NameLength1 AS INTEGER ) AS INTEGER ' SQLRETURN
DECLARE FUNCTION SQLLinkedCatalogsW LIB "odbcbcp.dll" ALIAS "SQLLinkedCatalogsW" ( BYVAL hstmt AS QUAD , BYREF ServerName AS WSTRINGZ , BYVAL NameLength1 AS INTEGER ) AS INTEGER ' SQLRETURN
#IF %DEF(%UNICODE)
 MACRO SQLLinkedCatalogs = SQLLinkedCatalogsW
#ELSE
 MACRO SQLLinkedCatalogs = SQLLinkedCatalogsA
#ENDIF
'// SQL Server extensions for server enumeration
DECLARE FUNCTION SQLInitEnumServers LIB "odbcbcp.dll" ALIAS "SQLInitEnumServers" ( BYREF pwchServerName AS WSTRINGZ , BYREF pwchInstanceName AS WSTRINGZ ) AS QUAD
DECLARE FUNCTION SQLGetNextEnumeration LIB "odbcbcp.dll" ALIAS "SQLGetNextEnumeration" ( BYVAL hEnumHandle AS QUAD
 , BYREF prgEnumData AS BYTE
 , BYREF piEnumLength AS LONG
 ) AS LONG ' RETCODE
DECLARE FUNCTION SQLCloseEnumServers LIB "odbcbcp.dll" ALIAS "SQLCloseEnumServers" ( BYVAL hEnumHandle AS QUAD ) AS LONG ' RETCODE
'#ifdef UNICODE
'#define SQLLinkedCatalogs SQLLinkedCatalogsW
'#else
'#define SQLLinkedCatalogs SQLLinkedCatalogsA
'#endif
'// BCP column format properties
%EQUATE `BCP_FMT_TYPE = &H01
%EQUATE `BCP_FMT_INDICATOR_LEN = &H02
%EQUATE `BCP_FMT_DATA_LEN = &H03
%EQUATE `BCP_FMT_TERMINATOR = &H04
%EQUATE `BCP_FMT_SERVER_COL = &H05
%EQUATE `BCP_FMT_COLLATION = &H06
%EQUATE `BCP_FMT_COLLATION_ID = &H07
'// The following options have been deprecated
%EQUATE `SQL_FAST_CONNECT = %SQL_COPT_SS_BASE + 0
'// Defines for use with SQL_FAST_CONNECT - only useable before connecting
%EQUATE `SQL_FC_OFF = 0& ' // Fast connect is off
%EQUATE `SQL_FC_ON = 1& ' // Fast connect is on
%EQUATE `SQL_FC_DEFAULT = %SQL_FC_OFF
%EQUATE `SQL_COPT_SS_ANSI_OEM = %SQL_COPT_SS_BASE + 6
%EQUATE `SQL_AO_OFF = 0&
%EQUATE `SQL_AO_ON = 1&
%EQUATE `SQL_AO_DEFAULT = %SQL_AO_OFF
'// Define old names
%EQUATE `SQL_REMOTE_PWD = %SQL_COPT_SS_REMOTE_PWD
%EQUATE `SQL_USE_PROCEDURE_FOR_PREPARE = %SQL_COPT_SS_USE_PROC_FOR_PREP
%EQUATE `SQL_INTEGRATED_SECURITY = %SQL_COPT_SS_INTEGRATED_SECURITY
%EQUATE `SQL_PRESERVE_CURSORS = %SQL_COPT_SS_PRESERVE_CURSORS
%EQUATE `SQL_TEXTPTR_LOGGING = %SQL_SOPT_SS_TEXTPTR_LOGGING
%EQUATE `SQL_CA_SS_BASE_COLUMN_NAME = %SQL_DESC_BASE_COLUMN_NAME
%EQUATE `SQLDECIMALN = &H6a
%EQUATE `SQLNUMERICN = &H6c
#ENDIF
