!SQL.DEF [102] - SQL definitions !VEDIT=103 ![100] January 21, 2009 09:20 AM Edited by Jack ! Created for use with SQL.SBR ![101] February 8, 2009 09:10 PM ! Revise symbol names (ASQLOP_xxx -> SQLOP_xxx, ! ASQLERR_xxx -> ASQLERR_xxx, MYSQL_TYPE_xxx -> SQL_TYPE_xxx ![102] March 8, 2009 12:10 PM ! Add SQLINFO_CONID, SQLINFO_CONVER, SQLINFO_CONDESCR, change ! cmdhdr.dbmsid to .dbmsconid (connector id) ![103] March 29, 2009 03:13 PM Edited by jacques ! Add DBMSCONID_ODBC !------------------------------------------------------------------------ ++ifnmap VERSYS_SQL_DEF ! [100] ![100] This is only map statement here - needs to be a map so ![100] it is included in the run (to be displayed with VERSYS.LIT) map1 VERSYS_SQL_DEF,s,40,">>@VERSYS(1)->>sql.def[102]" define DBMSID_MYSQL = 1 ! [102] (old symbol - now deprecated) define DBMSCONID_MYSQL = 1 ! [102] (new symbol naming scheme) define DBMSCONID_ODBC = 2 ! [103] ODBC (including SQL server) !***opcodes define SQLOP_INIT_LIB = 1 ! Init lib define SQLOP_CLOSE_LIB = 2 ! End lib define SQLOP_GET_ERRMSG = 3 ! Get error info for last op define SQLOP_INIT_CONN = 4 ! Init connection structure define SQLOP_OPTIONS = 5 ! Set options for connection define SQLOP_CONNECT = 6 ! Connect to database define SQLOP_DISCONNECT = 7 ! Disconnect from database define SQLOP_GET_INFO = 8 ! Get misc info - per flags define SQLOP_QUERY = 9 ! Execute query define SQLOP_FETCH_COLUMNS = 10 ! Fetch field info (for last query) define SQLOP_DEF_BIND = 11 ! Define a set of bindings for current row structure define SQLOP_FETCH_ROW = 12 ! Fetch next row define SQLOP_FREE_RESULT = 13 ! Free results !*** command opflags for SQLOP_GET_INFO define SQLINFO_HOST = 1 ! Get host info define SQLINFO_SERVER = 2 ! Get server info define SQLINFO_CLIENT = 3 ! Get client info define SQLINFO_QUERY = 4 ! Get last query info define SQLINFO_FIELDCOUNT = 5 ! # fields in current row define SQLINFO_ROWCOUNT = 6 ! # rows in result define SQLINFO_CONID = 7 ! [102] connector id (lib name) define SQLINFO_CONVER = 8 ! [102] connector version define SQLINFO_CONDESCR = 9 ! [102] connector description !*** command opflags for SQLOP_QUERY define QYRF_REAL = &h0001 ! Real (binary) query (len in cmdarg2) define QRYF_NOSTORE = &h0002 ! Leave results on server !*** command opflags for SQLOP_FETCH_ROW define FETCHR_ARRAY = &h0001 ! fetch row into array of strings define FETCHR_ROWSTR = &h0002 ! fetch row into single row string (XTREE style) define FETCHR_DELIMITER = &h0004 ! fetch row into single delimited string define FETCHR_CSV = &h008 ! fetch row into CSV format string !*** errors define SQLERR_BADDBMSID = 1 ! unsupport dbmsid define SQLERR_DBMSERR = 2 ! dbms error - use ASQLOP_GETERRINFO for details define SQLERR_TOOFEW = 3 ! too few params define SQLERR_NOTFOUND = 4 ! image file not found define SQLERR_NOTINITED = 5 ! lib not yet inited define SQLERR_ALREADYINITED= 6 ! lib already inited define SQLERR_TOOMANY = 7 ! exceeded max # connections supported define SQLERR_NOMEM = 8 ! can't malloc (or out of malloc hdls) define SQLERR_BADOPCODE = 9 ! no such IMAGE.SBR opcode define SQLERR_BADHANDLE = 10 ! bad HANDLE passed define SQLERR_PERR = 11 ! misc param error define SQLERR_LIBLINK = 12 ! can't dynamically link library define SQLERR_SYNTAX = 13 ! bad syntax in inparm string define SQLERR_NORESULT = 14 ! no query results to process defstruct ST_SQL_CMDHDR ! XCALL SQL CMDHDR structure map2 handle,B,1 ! [in/out] handle to connection map2 dbmsconid,B,1 ! [in] 0=ODBC, 1=MySQL, 2=SQL Server, etc [102] was dbmsid map2 dbmsid,B,1,@dbmsconid ! [102] old (deprecated) name map2 opflags,B,2 ! [in] flags modifying (variations of) opcode map2 cmdarg1,B,4 ! [in] general purpose argument #1 map2 cmdarg2,F,8 ! [in] general purpose argument #2 map2 lastop,B,2 ! [out] last opcode (copied from opcode param) map2 rc,B,2 ! [out] ashsql lib return code - see ASQLERR_xxxx map2 rcext,B,4 ! [out] extended error code (dbms err when RC = ASQLERR_DBMSERR) map2 info1,B,4 ! [out] return info map2 info2,F,8 ! [out] return info map2 sqlstate,s,5 ! [out] ANSI standard SQL state codes map2 misc,x,7 ! [out] ununsed so far endstruct defstruct ST_SQL_FIELD ! Basic analog to MYSQL_FIELD struct map2 name,s,32 ! field name (or alias) map2 org'name,s,32 ! original field name (no alias) map2 table,s,32 ! table name containing the field (unless calculated) map2 org'table,s,32 ! original name of table (no alias) map2 db,s,32 ! name of database map2 catalog,s,12 ! name of catalog (always "def" for MySQL 5.x) map2 dflt,s,32 ! default value of vield (set only on mysql_list_fields) map2 length,b,4 ! width of field (display width) map2 max'length,b,4 ! max width of actual field data for current result set map2 flags,b,4 ! bit flags describing field - see xxxx_FLAG map2 type,b,4 ! field type enum - see MYSQL_TYPE_xxxx map2 decimals,b,2 ! number of decimals for numeric fields map2 charsetnr,b,2 ! character set/collation ID endstruct !*** field types define SQL_TYPE_TINY = 1 ! TINYINT define SQL_TYPE_SHORT = 2 ! SMALLINT define SQL_TYPE_LONG = 3 ! INTEGER define SQL_TYPE_INT24 = 9 ! MEDIUMINT define SQL_TYPE_LONGLONG = 8 ! BIGINT define SQL_TYPE_DECIMAL = 0 ! DECIMAL or NUMERIC define SQL_TYPE_NEWDECIMAL= 246 ! precision math DECIMAL or NUMERIC define SQL_TYPE_FLOAT = 4 ! FLOAT define SQL_TYPE_DOUBLE = 5 ! DOUBLE define SQL_TYPE_BIT = 15 ! BIT define SQL_TYPE_TIMESTAMP = 7 ! TIMESTAMP define SQL_TYPE_DATE = 10 ! DATE define SQL_TYPE_TIME = 11 ! TIME define SQL_TYPE_DATETIME = 12 ! DATETIME define SQL_TYPE_YEAR = 13 ! YEAR define SQL_TYPE_VARCHAR = 14 ! VARCHAR define SQL_TYPE_STRING = 254 ! CHAR or BINARY define SQL_TYPE_VAR_STRING= 253 ! VARCHAR or VARBINARY define SQL_TYPE_BLOB = 252 ! BLOB or TEXT (see max'length) define SQL_TYPE_SET = 248 ! SET define SQL_TYPE_ENUM = 247 ! ENUM define SQL_TYPE_GEOMETRY = 255 ! spatial define SQL_TYPE_NULL = 6 ! NULL-type field !*** field flags define NOT_NULL_FLAG = &h0001 ! field can't be null define PRI_KEY_FLAG = &h0002 ! field is part of primary key define UNIQUE_KEY_FLAG = &h0004 ! field is part of unique key define MULTIPLE_KEY_FLAG = &h0008 ! fieldis part of non-unique key define UNSIGNED_FLAG = &h0020 ! field has the UNSIGNED attribute define ZEROFILL_FLAG = &h0040 ! field has the ZEROFILL attribute define BINARY_FLAG = &h0080 ! field has the BINARY attribute define AUTO_INCREMENT_FLAG = &h0200 ! field has the AUTO_INCREMENT attribute define ENUM_FLAG = &h0100 ! field is an ENUM (deprecated - use MYSQL_TYPE_ENUM) define SET_FLAG = &h0800 ! field is a SET (deprecated - use MYSQL_TYPE_SET) define BLOB_FLAG = &h0010 ! field is a BLOB or TEXT (deprecated - use MYSQL_TYPE_BLOB) define TIMESTAMP_FLAG = &h0400 ! field is a TIMESTAMP (deprecated - use MYSQL_TYPE_TIMESTAMP) define NO_DEFAULT_VALUE_FLAG= &h1000 ! field has no default value define NUM_FLAG = &h8000 ! field is numeric define SQLF_NOT_NULL = &h0001 ! field can't be null define SQLF_PRI_KEY = &h0002 ! field is part of primary key define SQLF_UNIQUE_KEY = &h0004 ! field is part of unique key define SQLF_MULTIPLE_KEY = &h0008 ! fieldis part of non-unique key define SQLF_UNSIGNED = &h0020 ! field has the UNSIGNED attribute define SQLF_ZEROFILL = &h0040 ! field has the ZEROFILL attribute define SQLF_BINARY = &h0080 ! field has the BINARY attribute define SQLF_AUTO_INCREMENT = &h0200 ! field has the AUTO_INCREMENT attribute define SQLF_ENUM = &h0100 ! field is an ENUM (deprecated - use MYSQL_TYPE_ENUM) define SQLF_SET = &h0800 ! field is a SET (deprecated - use MYSQL_TYPE_SET) define SQLF_BLOB = &h0010 ! field is a BLOB or TEXT (deprecated - use MYSQL_TYPE_BLOB) define SQLF_TIMESTAMP = &h0400 ! field is a TIMESTAMP (deprecated - use MYSQL_TYPE_TIMESTAMP) define SQLF_NO_DEFAULT_VALUE= &h1000 ! field has no default value define SQLF_NUM = &h8000 ! field is numeric ++endif