' api_sql.sbp

/* API declaration data types */
TypeDef SQLCHAR        = Byte
TypeDef SQLSCHAR       = Char
TypeDef SQLDATE        = Byte
TypeDef SQLDECIMAL     = Byte
TypeDef SQLDOUBLE      = Double
TypeDef SQLFLOAT       = Double
TypeDef SQLINTEGER     = Long
TypeDef SQLUINTEGER    = DWord
TypeDef SQLSMALLINT    = Integer
TypeDef SQLUSMALLINT   = Word
#ifdef _WIN64
TypeDef SQLLEN         = Int64
TypeDef SQLULEN        = QWord
TypeDef SQLSETPOSIROW  = QWord
#else 
TypeDef SQLLEN         = SQLINTEGER
TypeDef SQLULEN        = SQLUINTEGER
TypeDef SQLSETPOSIROW  = SQLUSMALLINT
#endif

'For Backward compatibility
TypeDef SQLROWCOUNT    = SQLULEN
TypeDef SQLROWSETSIZE  = SQLULEN
TypeDef SQLTRANSID     = SQLULEN
TypeDef SQLROWOFFSET   = SQLLEN

TypeDef SQLNUMERIC = Byte
TypeDef SQLPOINTER = VoidPtr
TypeDef SQLREAL = Single
TypeDef SQLSMALLINT = Integer
TypeDef SQLUSMALLINT = Word
TypeDef SQLTIME = Byte
TypeDef SQLTIMESTAMP = Byte
TypeDef SQLVARCHAR = Byte

/* function return type */
TypeDef SQLRETURN = SQLSMALLINT

/* generic data structures */
TypeDef SQLHANDLE = VoidPtr
TypeDef SQLHENV = SQLHANDLE
TypeDef SQLHDBC = SQLHANDLE
TypeDef SQLHSTMT = SQLHANDLE
TypeDef SQLHDESC = SQLHANDLE



/* transfer types for DATE, TIME, TIMESTAMP */
Type DATE_STRUCT
	year As SQLSMALLINT
	month As SQLUSMALLINT
	day As SQLUSMALLINT
End Type
TypeDef SQL_DATE_STRUCT = DATE_STRUCT


Type TIME_STRUCT
	hour As SQLUSMALLINT
	minute As SQLUSMALLINT
	second As SQLUSMALLINT
End Type
TypeDef SQL_TIME_STRUCT = TIME_STRUCT


Type TIMESTAMP_STRUCT
	year As SQLSMALLINT
	month As SQLUSMALLINT
	day As SQLUSMALLINT
	hour As SQLUSMALLINT
	minute As SQLUSMALLINT
	second As SQLUSMALLINT
	fraction As SQLUSMALLINT
End Type
TypeDef SQL_TIMESTAMP_STRUCT = TIMESTAMP_STRUCT


Const Enum SQLINTERVAL
	SQL_IS_YEAR						= 1
	SQL_IS_MONTH					= 2
	SQL_IS_DAY						= 3
	SQL_IS_HOUR						= 4
	SQL_IS_MINUTE					= 5
	SQL_IS_SECOND					= 6
	SQL_IS_YEAR_TO_MONTH			= 7
	SQL_IS_DAY_TO_HOUR				= 8
	SQL_IS_DAY_TO_MINUTE			= 9
	SQL_IS_DAY_TO_SECOND			= 10
	SQL_IS_HOUR_TO_MINUTE			= 11
	SQL_IS_HOUR_TO_SECOND			= 12
	SQL_IS_MINUTE_TO_SECOND			= 13
End Enum


Type SQL_YEAR_MONTH_STRUCT
	year As SQLUINTEGER
	month As SQLUINTEGER
End Type

Type SQL_DAY_SECOND_STRUCT
	day As SQLUINTEGER
	hour As SQLUINTEGER
	minute As SQLUINTEGER
	second As SQLUINTEGER
	fraction As SQLUINTEGER
End Type

Type SQL_INTERVAL_STRUCT
	interval_type As SQLINTERVAL
	interval_sign As SQLSMALLINT

	'Union intval
		year_month As SQL_YEAR_MONTH_STRUCT
		'day_second As SQL_DAY_SECOND_STRUCT
	'End Union
End Type


Const SQL_MAX_NUMERIC_LEN = 16
Type SQL_NUMERIC_STRUCT
	precision As SQLCHAR
	scale As SQLSCHAR
	sign As SQLCHAR
	val[ELM(SQL_MAX_NUMERIC_LEN)] As SQLCHAR
End Type


TypeDef SQLGUID = GUID

TypeDef BOOKMARK = SQLULEN

typedef SQLWCHAR = Word
TypeDef SQLTCHAR = SQLCHAR




/* special length/indicator values */
Const SQL_NULL_DATA             = (-1)
Const SQL_DATA_AT_EXEC          = (-2)


/* return values from functions */
Const SQL_SUCCESS                = 0
Const SQL_SUCCESS_WITH_INFO      = 1
Const SQL_NO_DATA              = 100
Const SQL_ERROR                 = (-1)
Const SQL_INVALID_HANDLE        = (-2)

Const SQL_STILL_EXECUTING        = 2
Const SQL_NEED_DATA             = 99

/* test for SQL_SUCCESS or SQL_SUCCESS_WITH_INFO */
Const SQL_SUCCEEDED(rc) = (((rc) and (not 1))=0)

/* flags for null-terminated string */
Const SQL_NTS                   = (-3)
Const SQL_NTSL                  = (-3)

/* maximum message length */
Const SQL_MAX_MESSAGE_LENGTH   = 512

/* date/time length constants */
Const SQL_DATE_LEN           = 10
Const SQL_TIME_LEN           =  8  /* add P+1 if precision is nonzero */
Const SQL_TIMESTAMP_LEN      = 19  /* add P+1 if precision is nonzero */

/* handle type identifiers */
Const SQL_HANDLE_ENV             = 1
Const SQL_HANDLE_DBC             = 2
Const SQL_HANDLE_STMT            = 3
Const SQL_HANDLE_DESC            = 4

/* environment attribute */
Const SQL_ATTR_OUTPUT_NTS    = 10001

/* connection attributes */
Const SQL_ATTR_AUTO_IPD      = 10001
Const SQL_ATTR_METADATA_ID   = 10014

/* statement attributes */
Const SQL_ATTR_APP_ROW_DESC       = 10010
Const SQL_ATTR_APP_PARAM_DESC     = 10011
Const SQL_ATTR_IMP_ROW_DESC       = 10012
Const SQL_ATTR_IMP_PARAM_DESC     = 10013
Const SQL_ATTR_CURSOR_SCROLLABLE  = (-1)
Const SQL_ATTR_CURSOR_SENSITIVITY = (-2)

/* SQL_ATTR_CURSOR_SCROLLABLE values */
Const SQL_NONSCROLLABLE		 = 0
Const SQL_SCROLLABLE			 = 1

/* identifiers of fields in the SQL descriptor */
Const SQL_DESC_COUNT                  = 1001
Const SQL_DESC_TYPE                   = 1002
Const SQL_DESC_LENGTH                 = 1003
Const SQL_DESC_OCTET_LENGTH_PTR       = 1004
Const SQL_DESC_PRECISION              = 1005
Const SQL_DESC_SCALE                  = 1006
Const SQL_DESC_DATETIME_INTERVAL_CODE = 1007
Const SQL_DESC_NULLABLE               = 1008
Const SQL_DESC_INDICATOR_PTR          = 1009
Const SQL_DESC_DATA_PTR               = 1010
Const SQL_DESC_NAME                   = 1011
Const SQL_DESC_UNNAMED                = 1012
Const SQL_DESC_OCTET_LENGTH           = 1013
Const SQL_DESC_ALLOC_TYPE             = 1099

/* identifiers of fields in the diagnostics area */
Const SQL_DIAG_RETURNCODE        = 1
Const SQL_DIAG_NUMBER            = 2
Const SQL_DIAG_ROW_COUNT         = 3
Const SQL_DIAG_SQLSTATE          = 4
Const SQL_DIAG_NATIVE            = 5
Const SQL_DIAG_MESSAGE_TEXT      = 6
Const SQL_DIAG_DYNAMIC_FUNCTION  = 7
Const SQL_DIAG_CLASS_ORIGIN      = 8
Const SQL_DIAG_SUBCLASS_ORIGIN   = 9
Const SQL_DIAG_CONNECTION_NAME  = 10
Const SQL_DIAG_SERVER_NAME      = 11
Const SQL_DIAG_DYNAMIC_FUNCTION_CODE = 12

/* dynamic function codes */
Const SQL_DIAG_ALTER_DOMAIN		 = 3
Const SQL_DIAG_ALTER_TABLE            = 4
Const SQL_DIAG_CALL				 = 7
Const SQL_DIAG_CREATE_ASSERTION	 = 6
Const SQL_DIAG_CREATE_CHARACTER_SET = 8
Const SQL_DIAG_CREATE_COLLATION	 = 10
Const SQL_DIAG_CREATE_DOMAIN		 = 23
Const SQL_DIAG_CREATE_INDEX          = (-1)
Const SQL_DIAG_CREATE_SCHEMA		 = 64
Const SQL_DIAG_CREATE_TABLE          = 77
Const SQL_DIAG_CREATE_TRANSLATION	 = 79
Const SQL_DIAG_CREATE_VIEW           = 84
Const SQL_DIAG_DELETE_WHERE          = 19
Const SQL_DIAG_DROP_ASSERTION		 = 24
Const SQL_DIAG_DROP_CHARACTER_SET	 = 25
Const SQL_DIAG_DROP_COLLATION		 = 26
Const SQL_DIAG_DROP_DOMAIN		 = 27
Const SQL_DIAG_DROP_INDEX            = (-2)
Const SQL_DIAG_DROP_SCHEMA		 = 31
Const SQL_DIAG_DROP_TABLE            = 32
Const SQL_DIAG_DROP_TRANSLATION      = 33
Const SQL_DIAG_DROP_VIEW             = 36
Const SQL_DIAG_DYNAMIC_DELETE_CURSOR = 38
Const SQL_DIAG_DYNAMIC_UPDATE_CURSOR = 81
Const SQL_DIAG_GRANT                 = 48
Const SQL_DIAG_INSERT                = 50
Const SQL_DIAG_REVOKE                = 59
Const SQL_DIAG_SELECT_CURSOR         = 85
Const SQL_DIAG_UNKNOWN_STATEMENT      = 0
Const SQL_DIAG_UPDATE_WHERE          = 82

/* SQL data type codes */
Const SQL_UNKNOWN_TYPE = 0
Const SQL_CHAR            = 1
Const SQL_NUMERIC         = 2
Const SQL_DECIMAL         = 3
Const SQL_INTEGER         = 4
Const SQL_SMALLINT        = 5
Const SQL_FLOAT           = 6
Const SQL_REAL            = 7
Const SQL_DOUBLE          = 8
Const SQL_DATETIME        = 9
Const SQL_VARCHAR        = 12

/* One-parameter shortcuts for date/time data types */
Const SQL_TYPE_DATE      = 91
Const SQL_TYPE_TIME      = 92
Const SQL_TYPE_TIMESTAMP = 93

/* Statement attribute values for cursor sensitivity */
Const SQL_UNSPECIFIED     = 0
Const SQL_INSENSITIVE     = 1
Const SQL_SENSITIVE       = 2

/* GetTypeInfo() request for all data types */
Const SQL_ALL_TYPES       = 0

/* Default conversion code for SQLBindCol(), SQLBindParam() and SQLGetData() */
Const SQL_DEFAULT        = 99

/* SQLSQLLEN GetData() code indicating that the application row descriptor
 * specifies the data type
 */
Const SQL_ARD_TYPE      = (-99)

/* SQL date/time type subcodes */
Const SQL_CODE_DATE       = 1
Const SQL_CODE_TIME       = 2
Const SQL_CODE_TIMESTAMP  = 3

/* CLI option values */
Const SQL_FALSE           = 0
Const SQL_TRUE            = 1

/* values of NULLABLE field in descriptor */
Const SQL_NO_NULLS        = 0
Const SQL_NULLABLE        = 1

/* Value returned by SQLGetTypeInfo() to denote that it is
 * not known whether or not a data type supports null values.
 */
Const SQL_NULLABLE_UNKNOWN  = 2

/* Values returned by SQLGetTypeInfo() to show WHERE clause
 * supported
 */
Const SQL_PRED_NONE     = 0
Const SQL_PRED_CHAR     = 1
Const SQL_PRED_BASIC    = 2

/* values of UNNAMED field in descriptor */
Const SQL_NAMED           = 0
Const SQL_UNNAMED         = 1

/* values of ALLOC_TYPE field in descriptor */
Const SQL_DESC_ALLOC_AUTO = 1
Const SQL_DESC_ALLOC_USER = 2

/* FreeStmt() options */
Const SQL_CLOSE           = 0
Const SQL_DROP            = 1
Const SQL_UNBIND          = 2
Const SQL_RESET_PARAMS    = 3

/* Codes used for FetchOrientation in SQLFetchScroll(), 
   and in SQLDataSources() 
*/
Const SQL_FETCH_NEXT      = 1
Const SQL_FETCH_FIRST     = 2

/* Other codes used for FetchOrientation in SQLFetchScroll() */
Const SQL_FETCH_LAST      = 3
Const SQL_FETCH_PRIOR     = 4
Const SQL_FETCH_ABSOLUTE  = 5
Const SQL_FETCH_RELATIVE  = 6

/* SQLEndTran() options */
Const SQL_COMMIT          = 0
Const SQL_ROLLBACK        = 1

/* null handles returned by SQLAllocHandle() */
Const SQL_NULL_HENV       = 0
Const SQL_NULL_HDBC       = 0
Const SQL_NULL_HSTMT      = 0
Const SQL_NULL_HDESC      = 0

/* null handle used in place of parent handle when allocating HENV */
Const SQL_NULL_HANDLE     = 0

/* Values that may appear in the result set of SQLSpecialColumns() */
Const SQL_SCOPE_CURROW    = 0
Const SQL_SCOPE_TRANSACTION = 1
Const SQL_SCOPE_SESSION   = 2

Const SQL_PC_UNKNOWN      = 0
Const SQL_PC_NON_PSEUDO   = 1
Const SQL_PC_PSEUDO       = 2

/* Reserved value for the IdentifierType argument of SQLSpecialColumns() */
Const SQL_ROW_IDENTIFIER  = 1

/* Reserved values for UNIQUE argument of SQLStatistics() */
Const SQL_INDEX_UNIQUE    = 0
Const SQL_INDEX_ALL       = 1

/* Values that may appear in the result set of SQLStatistics() */
Const SQL_INDEX_CLUSTERED = 1
Const SQL_INDEX_HASHED    = 2
Const SQL_INDEX_OTHER     = 3

/* SQLGetFunctions() values to identify ODBC APIs */
Const SQL_API_SQLALLOCCONNECT         = 1
Const SQL_API_SQLALLOCENV             = 2
Const SQL_API_SQLALLOCHANDLE       = 1001
Const SQL_API_SQLALLOCSTMT            = 3
Const SQL_API_SQLBINDCOL              = 4
Const SQL_API_SQLBINDPARAM         = 1002
Const SQL_API_SQLCANCEL               = 5
Const SQL_API_SQLCLOSECURSOR       = 1003
Const SQL_API_SQLCOLATTRIBUTE         = 6
Const SQL_API_SQLCOLUMNS             = 40
Const SQL_API_SQLCONNECT              = 7
Const SQL_API_SQLCOPYDESC          = 1004
Const SQL_API_SQLDATASOURCES         = 57
Const SQL_API_SQLDESCRIBECOL          = 8
Const SQL_API_SQLDISCONNECT           = 9
Const SQL_API_SQLENDTRAN           = 1005
Const SQL_API_SQLERROR               = 10
Const SQL_API_SQLEXECDIRECT          = 11
Const SQL_API_SQLEXECUTE             = 12
Const SQL_API_SQLFETCH               = 13
Const SQL_API_SQLFETCHSCROLL       = 1021
Const SQL_API_SQLFREECONNECT         = 14
Const SQL_API_SQLFREEENV             = 15
Const SQL_API_SQLFREEHANDLE        = 1006
Const SQL_API_SQLFREESTMT            = 16
Const SQL_API_SQLGETCONNECTATTR    = 1007
Const SQL_API_SQLGETCONNECTOPTION    = 42
Const SQL_API_SQLGETCURSORNAME       = 17
Const SQL_API_SQLGETDATA             = 43
Const SQL_API_SQLGETDESCFIELD      = 1008
Const SQL_API_SQLGETDESCREC        = 1009
Const SQL_API_SQLGETDIAGFIELD      = 1010
Const SQL_API_SQLGETDIAGREC        = 1011
Const SQL_API_SQLGETENVATTR        = 1012
Const SQL_API_SQLGETFUNCTIONS        = 44
Const SQL_API_SQLGETINFO             = 45
Const SQL_API_SQLGETSTMTATTR       = 1014
Const SQL_API_SQLGETSTMTOPTION       = 46
Const SQL_API_SQLGETTYPEINFO         = 47
Const SQL_API_SQLNUMRESULTCOLS       = 18
Const SQL_API_SQLPARAMDATA           = 48
Const SQL_API_SQLPREPARE             = 19
Const SQL_API_SQLPUTDATA             = 49
Const SQL_API_SQLROWCOUNT            = 20
Const SQL_API_SQLSETCONNECTATTR    = 1016
Const SQL_API_SQLSETCONNECTOPTION    = 50
Const SQL_API_SQLSETCURSORNAME       = 21
Const SQL_API_SQLSETDESCFIELD      = 1017
Const SQL_API_SQLSETDESCREC        = 1018
Const SQL_API_SQLSETENVATTR        = 1019
Const SQL_API_SQLSETPARAM            = 22
Const SQL_API_SQLSETSTMTATTR       = 1020
Const SQL_API_SQLSETSTMTOPTION       = 51
Const SQL_API_SQLSPECIALCOLUMNS      = 52
Const SQL_API_SQLSTATISTICS          = 53
Const SQL_API_SQLTABLES              = 54
Const SQL_API_SQLTRANSACT            = 23

/* Information requested by SQLGetInfo() */
Const SQL_MAX_DRIVER_CONNECTIONS           = 0
Const SQL_MAXIMUM_DRIVER_CONNECTIONS	 = SQL_MAX_DRIVER_CONNECTIONS
Const SQL_MAX_CONCURRENT_ACTIVITIES        = 1
Const SQL_MAXIMUM_CONCURRENT_ACTIVITIES = SQL_MAX_CONCURRENT_ACTIVITIES
Const SQL_DATA_SOURCE_NAME                 = 2
Const SQL_FETCH_DIRECTION                  = 8
Const SQL_SERVER_NAME                     = 13
Const SQL_SEARCH_PATTERN_ESCAPE           = 14
Const SQL_DBMS_NAME                       = 17
Const SQL_DBMS_VER                        = 18
Const SQL_ACCESSIBLE_TABLES               = 19
Const SQL_ACCESSIBLE_PROCEDURES         = 20
Const SQL_CURSOR_COMMIT_BEHAVIOR          = 23
Const SQL_DATA_SOURCE_READ_ONLY           = 25
Const SQL_DEFAULT_TXN_ISOLATION           = 26
Const SQL_IDENTIFIER_CASE                 = 28
Const SQL_IDENTIFIER_QUOTE_CHAR           = 29
Const SQL_MAX_COLUMN_NAME_LEN             = 30
Const SQL_MAXIMUM_COLUMN_NAME_LENGTH	 = SQL_MAX_COLUMN_NAME_LEN
Const SQL_MAX_CURSOR_NAME_LEN             = 31
Const SQL_MAXIMUM_CURSOR_NAME_LENGTH	 = SQL_MAX_CURSOR_NAME_LEN
Const SQL_MAX_SCHEMA_NAME_LEN             = 32
Const SQL_MAXIMUM_SCHEMA_NAME_LENGTH	 = SQL_MAX_SCHEMA_NAME_LEN
Const SQL_MAX_CATALOG_NAME_LEN            = 34
Const SQL_MAXIMUM_CATALOG_NAME_LENGTH	 = SQL_MAX_CATALOG_NAME_LEN
Const SQL_MAX_TABLE_NAME_LEN              = 35
Const SQL_SCROLL_CONCURRENCY              = 43
Const SQL_TXN_CAPABLE                     = 46
Const SQL_TRANSACTION_CAPABLE			 = SQL_TXN_CAPABLE
Const SQL_USER_NAME                       = 47
Const SQL_TXN_ISOLATION_OPTION            = 72
Const SQL_TRANSACTION_ISOLATION_OPTION = SQL_TXN_ISOLATION_OPTION
Const SQL_INTEGRITY                       = 73
Const SQL_GETDATA_EXTENSIONS              = 81
Const SQL_NULL_COLLATION                  = 85
Const SQL_ALTER_TABLE                     = 86
Const SQL_ORDER_BY_COLUMNS_IN_SELECT      = 90
Const SQL_SPECIAL_CHARACTERS              = 94
Const SQL_MAX_COLUMNS_IN_GROUP_BY         = 97
Const SQL_MAXIMUM_COLUMNS_IN_GROUP_BY	 = SQL_MAX_COLUMNS_IN_GROUP_BY
Const SQL_MAX_COLUMNS_IN_INDEX            = 98
Const SQL_MAXIMUM_COLUMNS_IN_INDEX	 = SQL_MAX_COLUMNS_IN_INDEX
Const SQL_MAX_COLUMNS_IN_ORDER_BY         = 99
Const SQL_MAXIMUM_COLUMNS_IN_ORDER_BY	 = SQL_MAX_COLUMNS_IN_ORDER_BY
Const SQL_MAX_COLUMNS_IN_SELECT          = 100
Const SQL_MAXIMUM_COLUMNS_IN_SELECT	   = SQL_MAX_COLUMNS_IN_SELECT
Const SQL_MAX_COLUMNS_IN_TABLE           = 101
Const SQL_MAX_INDEX_SIZE                 = 102
Const SQL_MAXIMUM_INDEX_SIZE			   = SQL_MAX_INDEX_SIZE
Const SQL_MAX_ROW_SIZE                   = 104
Const SQL_MAXIMUM_ROW_SIZE			   = SQL_MAX_ROW_SIZE
Const SQL_MAX_STATEMENT_LEN              = 105
Const SQL_MAXIMUM_STATEMENT_LENGTH	   = SQL_MAX_STATEMENT_LEN
Const SQL_MAX_TABLES_IN_SELECT           = 106
Const SQL_MAXIMUM_TABLES_IN_SELECT	   = SQL_MAX_TABLES_IN_SELECT
Const SQL_MAX_USER_NAME_LEN              = 107
Const SQL_MAXIMUM_USER_NAME_LENGTH	   = SQL_MAX_USER_NAME_LEN
Const SQL_OJ_CAPABILITIES                = 115
Const SQL_OUTER_JOIN_CAPABILITIES		   = SQL_OJ_CAPABILITIES

Const SQL_XOPEN_CLI_YEAR               = 10000
Const SQL_CURSOR_SENSITIVITY           = 10001
Const SQL_DESCRIBE_PARAMETER           = 10002
Const SQL_CATALOG_NAME                 = 10003
Const SQL_COLLATION_SEQ                = 10004
Const SQL_MAX_IDENTIFIER_LEN           = 10005
Const SQL_MAXIMUM_IDENTIFIER_LENGTH	 = SQL_MAX_IDENTIFIER_LEN

/* SQL_ALTER_TABLE bitmasks */
Const SQL_AT_ADD_COLUMN                    = &H00000001
Const SQL_AT_DROP_COLUMN                   = &H00000002
Const SQL_AT_ADD_CONSTRAINT                = &H00000008

/* SQL_ASYNC_MODE values */
Const SQL_AM_NONE                         = 0
Const SQL_AM_CONNECTION                   = 1
Const SQL_AM_STATEMENT                    = 2

/* SQL_CURSOR_COMMIT_BEHAVIOR values */
Const SQL_CB_DELETE                       = 0
Const SQL_CB_CLOSE                        = 1
Const SQL_CB_PRESERVE                     = 2

/* SQL_FETCH_DIRECTION bitmasks */
Const SQL_FD_FETCH_NEXT                   = &H00000001
Const SQL_FD_FETCH_FIRST                  = &H00000002
Const SQL_FD_FETCH_LAST                   = &H00000004
Const SQL_FD_FETCH_PRIOR                  = &H00000008
Const SQL_FD_FETCH_ABSOLUTE               = &H00000010
Const SQL_FD_FETCH_RELATIVE               = &H00000020

/* SQL_GETDATA_EXTENSIONS bitmasks */
Const SQL_GD_ANY_COLUMN                   = &H00000001
Const SQL_GD_ANY_ORDER                    = &H00000002

/* SQL_IDENTIFIER_CASE values */
Const SQL_IC_UPPER                        = 1
Const SQL_IC_LOWER                        = 2
Const SQL_IC_SENSITIVE                    = 3
Const SQL_IC_MIXED                        = 4

/* SQL_OJ_CAPABILITIES bitmasks */
/* NB: this means 'outer join', not what  you may be thinking */


Const SQL_OJ_LEFT                         = &H00000001
Const SQL_OJ_RIGHT                        = &H00000002
Const SQL_OJ_FULL                         = &H00000004
Const SQL_OJ_NESTED                       = &H00000008
Const SQL_OJ_NOT_ORDERED                  = &H00000010
Const SQL_OJ_INNER                        = &H00000020
Const SQL_OJ_ALL_COMPARISON_OPS           = &H00000040

/* SQL_SCROLL_CONCURRENCY bitmasks */
Const SQL_SCCO_READ_ONLY                  = &H00000001
Const SQL_SCCO_LOCK                       = &H00000002
Const SQL_SCCO_OPT_ROWVER                 = &H00000004
Const SQL_SCCO_OPT_VALUES                 = &H00000008

/* SQL_TXN_CAPABLE values */
Const SQL_TC_NONE                         = 0
Const SQL_TC_DML                          = 1
Const SQL_TC_ALL                          = 2
Const SQL_TC_DDL_COMMIT                   = 3
Const SQL_TC_DDL_IGNORE                   = 4

/* SQL_TXN_ISOLATION_OPTION bitmasks */
Const SQL_TXN_READ_UNCOMMITTED            = &H00000001
Const SQL_TRANSACTION_READ_UNCOMMITTED = SQL_TXN_READ_UNCOMMITTED
Const SQL_TXN_READ_COMMITTED              = &H00000002
Const SQL_TRANSACTION_READ_COMMITTED	 = SQL_TXN_READ_COMMITTED
Const SQL_TXN_REPEATABLE_READ             = &H00000004
Const SQL_TRANSACTION_REPEATABLE_READ	 = SQL_TXN_REPEATABLE_READ
Const SQL_TXN_SERIALIZABLE                = &H00000008
Const SQL_TRANSACTION_SERIALIZABLE	 = SQL_TXN_SERIALIZABLE

/* SQL_NULL_COLLATION values */
Const SQL_NC_HIGH                         = 0
Const SQL_NC_LOW                          = 1


Declare Function SQLAllocConnect Lib "odbc32.dll" (
	EnvironmentHandle As SQLHENV,
	ByRef ConnectionHandle As SQLHDBC) As SQLRETURN

Declare Function SQLAllocEnv Lib "odbc32.dll" (ByRef EnvironmentHandle As SQLHENV) As SQLRETURN

Declare Function SQLAllocHandle Lib "odbc32.dll" (HandleType As SQLSMALLINT,
           InputHandle As SQLHANDLE, ByRef OutputHandle As SQLHANDLE) As SQLRETURN

Declare Function SQLAllocStmt Lib "odbc32.dll" (ConnectionHandle As SQLHDBC,
           ByRef StatementHandle As SQLHSTMT) As SQLRETURN

Declare Function SQLBindCol Lib "odbc32.dll" (StatementHandle As SQLHSTMT, 
		   ColumnNumber As SQLUSMALLINT, TargetType As SQLSMALLINT, 
		   ByRef TargetValue As Any, BufferLength As SQLLEN, 
	   	   ByRef StrLen_or_Ind As SQLLEN) As SQLRETURN

Declare Function SQLBindParam Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           ParameterNumber As SQLUSMALLINT, ValueType As SQLSMALLINT,
           ParameterType As SQLSMALLINT, LengthPrecision As SQLULEN,
           ParameterScale As SQLSMALLINT, ParameterValue As SQLPOINTER,
           ByRef StrLen_or_Ind As SQLLEN) As SQLRETURN

Declare Function SQLCancel Lib "odbc32.dll" (StatementHandle As SQLHSTMT) As SQLRETURN

Declare Function SQLCloseCursor Lib "odbc32.dll" (StatementHandle As SQLHSTMT) As SQLRETURN

#ifdef _WIN64
Declare Function SQLColAttribute Lib "odbc32.dll"  (StatementHandle As SQLHSTMT,
           ColumnNumber As SQLUSMALLINT, FieldIdentifier As SQLUSMALLINT,
           CharacterAttribute As SQLPOINTER, BufferLength As SQLSMALLINT,
           ByRef StringLength As SQLSMALLINT, ByRef NumericAttribute As SQLLEN) As SQLRETURN
#else
Declare Function SQLColAttribute Lib "odbc32.dll"  (StatementHandle As SQLHSTMT,
           ColumnNumber As SQLUSMALLINT, FieldIdentifier As SQLUSMALLINT,
           CharacterAttribute As SQLPOINTER, BufferLength As SQLSMALLINT,
           ByRef StringLength As SQLSMALLINT, NumericAttribute As SQLPOINTER) As SQLRETURN
#endif


Declare Function SQLColumns Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           CatalogName As *SQLCHAR, NameLength1 As SQLSMALLINT,
           SchemaName As *SQLCHAR, NameLength2 As SQLSMALLINT,
           TableName As *SQLCHAR, NameLength3 As SQLSMALLINT,
           ColumnName As *SQLCHAR, NameLength4 As SQLSMALLINT) As SQLRETURN


Declare Function SQLConnect Lib "odbc32.dll" (ConnectionHandle As SQLHDBC,
           ServerName As *SQLCHAR, NameLength1 As SQLSMALLINT,
           UserName As *SQLCHAR, NameLength2 As SQLSMALLINT,
           Authentication As *SQLCHAR, NameLength3 As SQLSMALLINT) As SQLRETURN

Declare Function SQLCopyDesc Lib "odbc32.dll" (SourceDescHandle As SQLHDESC,
           TargetDescHandle As SQLHDESC) As SQLRETURN

Declare Function SQLDataSources Lib "odbc32.dll" (EnvironmentHandle As SQLHENV,
           Direction As SQLUSMALLINT, ServerName As *SQLCHAR,
           BufferLength1 As SQLSMALLINT, ByRef NameLength1 As SQLSMALLINT,
           Description As *SQLCHAR, BufferLength2 As SQLSMALLINT,
           ByRef NameLength2 As SQLSMALLINT) As SQLRETURN

Declare Function SQLDescribeCol Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           ColumnNumber As SQLSMALLINT, ColumnName As *SQLCHAR,
           BufferLength As SQLSMALLINT, ByRef NameLength As SQLSMALLINT,
           ByRef DataType As SQLSMALLINT, ByRef ColumnSize As SQLINTEGER,
           ByRef DecimalDigits As SQLSMALLINT, ByRef Nullable As SQLSMALLINT) As SQLRETURN

Declare Function SQLDisconnect Lib "odbc32.dll" (ConnectionHandle As SQLHDBC) As SQLRETURN

Declare Function SQLEndTran Lib "odbc32.dll" (HandleType As SQLSMALLINT, Handle As SQLHANDLE,
           CompletionType As SQLSMALLINT) As SQLRETURN

Declare Function SQLError Lib "odbc32.dll" (EnvironmentHandle As SQLHENV,
           ConnectionHandle As SQLHDBC, StatementHandle As SQLHSTMT,
           Sqlstate As *SQLCHAR, ByRef NativeError As SQLINTEGER,
           MessageText As *SQLCHAR, BufferLength As SQLSMALLINT,
           ByRef TextLength As SQLSMALLINT) As SQLRETURN

Declare Function SQLExecDirect Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           StatementText As *SQLCHAR, TextLength As SQLINTEGER) As SQLRETURN

Declare Function SQLExecute Lib "odbc32.dll" (StatementHandle As SQLHSTMT) As SQLRETURN

Declare Function SQLFetch Lib "odbc32.dll" (StatementHandle As SQLHSTMT) As SQLRETURN

Declare Function SQLFetchScroll Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           FetchOrientation As SQLSMALLINT, FetchOffset As SQLLEN) As SQLRETURN

Declare Function SQLFreeConnect Lib "odbc32.dll" (ConnectionHandle As SQLHDBC) As SQLRETURN

Declare Function SQLFreeEnv Lib "odbc32.dll" (EnvironmentHandle As SQLHENV) As SQLRETURN

Declare Function SQLFreeHandle Lib "odbc32.dll" (HandleType As SQLSMALLINT, Handle As SQLHANDLE) As SQLRETURN

Declare Function SQLFreeStmt Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           Option As SQLUSMALLINT) As SQLRETURN

Declare Function SQLGetConnectAttr Lib "odbc32.dll" (ConnectionHandle As SQLHDBC,
           Attribute As SQLINTEGER, Value As SQLPOINTER,
           BufferLength As SQLINTEGER, ByRef StringLength As SQLINTEGER) As SQLRETURN

Declare Function SQLGetConnectOption Lib "odbc32.dll" (ConnectionHandle As SQLHDBC,
           Option As SQLUSMALLINT, Value As SQLPOINTER) As SQLRETURN

Declare Function SQLGetCursorName Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           CursorName As *SQLCHAR, BufferLength As SQLSMALLINT,
           ByRef NameLength As SQLSMALLINT) As SQLRETURN

Declare Function SQLGetData Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           ColumnNumber As SQLUSMALLINT, TargetType As SQLSMALLINT,
           TargetValue As SQLPOINTER, BufferLength As SQLLEN,
           ByRef StrLen_or_Ind As SQLLEN) As SQLRETURN

Declare Function SQLGetDescField Lib "odbc32.dll" (DescriptorHandle As SQLHDESC,
           RecNumber As SQLSMALLINT, FieldIdentifier As SQLSMALLINT,
           Value As SQLPOINTER, BufferLength As SQLINTEGER,
           ByRef StringLength As SQLINTEGER) As SQLRETURN

Declare Function SQLGetDescRec Lib "odbc32.dll" (DescriptorHandle As SQLHDESC,
           RecNumber As SQLSMALLINT, Name As *SQLCHAR,
           BufferLength As SQLSMALLINT, ByRef StringLength As SQLSMALLINT,
           ByRef iType As SQLSMALLINT, ByRef SubType As SQLSMALLINT, 
           ByRef Length As SQLLEN, ByRef Precision As SQLSMALLINT, 
           ByRef Scale As SQLSMALLINT, ByRef Nullable As SQLSMALLINT) As SQLRETURN

Declare Function SQLGetDiagField Lib "odbc32.dll" (HandleType As SQLSMALLINT, Handle As SQLHANDLE,
           RecNumber As SQLSMALLINT, DiagIdentifier As SQLSMALLINT,
           DiagInfo As SQLPOINTER, BufferLength As SQLSMALLINT,
           ByRef StringLength As SQLSMALLINT) As SQLRETURN

Declare Function SQLGetDiagRec Lib "odbc32.dll" (HandleType As SQLSMALLINT, Handle As SQLHANDLE,
           RecNumber As SQLSMALLINT, Sqlstate As *SQLCHAR,
           ByRef NativeError As SQLINTEGER, MessageText As *SQLCHAR,
           BufferLength As SQLSMALLINT, ByRef TextLength As SQLSMALLINT) As SQLRETURN

Declare Function SQLGetEnvAttr Lib "odbc32.dll" (EnvironmentHandle As SQLHENV,
           Attribute As SQLINTEGER, Value As SQLPOINTER,
           BufferLength As SQLINTEGER, ByRef StringLength As SQLINTEGER) As SQLRETURN

Declare Function SQLGetFunctions Lib "odbc32.dll" (ConnectionHandle As SQLHDBC,
           FunctionId As SQLUSMALLINT, ByRef Supported As SQLUSMALLINT) As SQLRETURN

Declare Function SQLGetInfo Lib "odbc32.dll" (ConnectionHandle As SQLHDBC,
           InfoType As SQLUSMALLINT, InfoValue As SQLPOINTER,
           BufferLength As SQLSMALLINT, ByRef StringLength As SQLSMALLINT) As SQLRETURN

Declare Function SQLGetStmtAttr Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           Attribute As SQLINTEGER, Value As SQLPOINTER,
           BufferLength As SQLINTEGER, ByRef StringLength As SQLINTEGER) As SQLRETURN

Declare Function SQLGetStmtOption Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           Option As SQLUSMALLINT, Value As SQLPOINTER) As SQLRETURN

Declare Function SQLGetTypeInfo Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           DataType As SQLSMALLINT) As SQLRETURN

Declare Function SQLNumResultCols Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           ByRef ColumnCount As SQLSMALLINT) As SQLRETURN

Declare Function SQLParamData Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           ByRef Value As SQLPOINTER) As SQLRETURN

Declare Function SQLPrepare Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           StatementText As *SQLCHAR, TextLength As SQLINTEGER) As SQLRETURN

Declare Function SQLPutData Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           Data As SQLPOINTER, StrLen_or_Ind As SQLLEN) As SQLRETURN

Declare Function SQLRowCount Lib "odbc32.dll" (StatementHandle As SQLHSTMT, 
	   ByRef RowCount As SQLLEN) As SQLRETURN

Declare Function SQLSetConnectAttr Lib "odbc32.dll" (ConnectionHandle As SQLHDBC,
           Attribute As SQLINTEGER, Value As SQLPOINTER,
           StringLength As SQLINTEGER) As SQLRETURN

Declare Function SQLSetConnectOption Lib "odbc32.dll" (ConnectionHandle As SQLHDBC,
           Option As SQLUSMALLINT, Value As SQLULEN) As SQLRETURN

Declare Function SQLSetCursorName Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           CursorName As *SQLCHAR, NameLength As SQLSMALLINT) As SQLRETURN

Declare Function SQLSetDescField Lib "odbc32.dll" (DescriptorHandle As SQLHDESC,
           RecNumber As SQLSMALLINT, FieldIdentifier As SQLSMALLINT,
           Value As SQLPOINTER, BufferLength As SQLINTEGER) As SQLRETURN

Declare Function SQLSetDescRec Lib "odbc32.dll" (DescriptorHandle As SQLHDESC,
           RecNumber As SQLSMALLINT, iType As SQLSMALLINT,
           SubType As SQLSMALLINT, Length As SQLLEN,
           Precision As SQLSMALLINT, Scale As SQLSMALLINT,
           Data As SQLPOINTER, ByRef StringLength As SQLLEN,
           ByRef Indicator As SQLLEN) As SQLRETURN

Declare Function SQLSetEnvAttr Lib "odbc32.dll" (EnvironmentHandle As SQLHENV,
           Attribute As SQLINTEGER, Value As SQLPOINTER,
           StringLength As SQLINTEGER) As SQLRETURN

Declare Function SQLSetParam Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           ParameterNumber As SQLUSMALLINT, ValueType As SQLSMALLINT,
           ParameterType As SQLSMALLINT, LengthPrecision As SQLULEN,
           ParameterScale As SQLSMALLINT, ParameterValue As SQLPOINTER,
           ByRef StrLen_or_Ind As SQLLEN) As SQLRETURN

Declare Function SQLSetStmtAttr Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           Attribute As SQLINTEGER, Value As SQLPOINTER,
           StringLength As SQLINTEGER) As SQLRETURN

Declare Function SQLSetStmtOption Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           Option As SQLUSMALLINT, Value As SQLULEN) As SQLRETURN

Declare Function SQLSpecialColumns Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           IdentifierType As SQLUSMALLINT, CatalogName As *SQLCHAR,
           NameLength1 As SQLSMALLINT, SchemaName As *SQLCHAR,
           NameLength2 As SQLSMALLINT, TableName As *SQLCHAR,
           NameLength3 As SQLSMALLINT, Scope As SQLUSMALLINT,
           Nullable As SQLUSMALLINT) As SQLRETURN

Declare Function SQLStatistics Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           CatalogName As *SQLCHAR, NameLength1 As SQLSMALLINT,
           SchemaName As *SQLCHAR, NameLength2 As SQLSMALLINT,
           TableName As *SQLCHAR, NameLength3 As SQLSMALLINT,
           Unique As SQLUSMALLINT, Reserved As SQLUSMALLINT) As SQLRETURN

Declare Function SQLTables Lib "odbc32.dll" (StatementHandle As SQLHSTMT,
           CatalogName As *SQLCHAR, NameLength1 As SQLSMALLINT,
           SchemaName As *SQLCHAR, NameLength2 As SQLSMALLINT,
           TableName As *SQLCHAR, NameLength3 As SQLSMALLINT,
           TableType As *SQLCHAR, NameLength4 As SQLSMALLINT) As SQLRETURN

Declare Function SQLTransact Lib "odbc32.dll" (EnvironmentHandle As SQLHENV,
           ConnectionHandle As SQLHDBC, CompletionType As SQLUSMALLINT) As SQLRETURN
