00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef _sql_h_
00021 #define _sql_h_
00022
00023 #include <tds.h>
00024
00025 #ifdef UNIXODBC
00026 #include <sql.h>
00027 #include <sqlext.h>
00028 #include <odbcinst.h>
00029 #else
00030 #include "isql.h"
00031 #include "isqlext.h"
00032 #endif
00033
00034 #ifndef SQLULEN
00035 #define SQLULEN SQLUINTEGER
00036 #endif
00037 #ifndef SQLLEN
00038 #define SQLLEN SQLINTEGER
00039 #endif
00040
00041 #ifdef __cplusplus
00042 extern "C"
00043 {
00044 #if 0
00045 }
00046 #endif
00047 #endif
00048
00049 static char rcsid_sql_h[] = "$Id: tdsodbc.h,v 1.25 2003/04/03 08:59:16 freddy77 Exp $";
00050 static void *no_unused_sql_h_warn[] = { rcsid_sql_h, no_unused_sql_h_warn };
00051
00052
00053 struct _sql_error_struct
00054 {
00055 const char *msg;
00057 char state2[6];
00059 char state3[6];
00061 };
00062
00063 struct _sql_error
00064 {
00065 const struct _sql_error_struct *err;
00066
00067 char *msg;
00068 char sqlstate[6];
00069 int msgstate;
00070 int msgnum;
00071 int linenum;
00072 };
00073
00074 struct _sql_errors
00075 {
00076 int num_errors;
00077 struct _sql_error *errs;
00078 };
00079
00080 enum _sql_error_types
00081 {
00082 ODBCERR_GENERIC,
00083 ODBCERR_NOTIMPLEMENTED,
00084 ODBCERR_MEMORY,
00085 ODBCERR_NODSN,
00086 ODBCERR_CONNECT,
00087 ODBCERR_INVALIDINDEX,
00088 ODBCERR_INVALIDTYPE,
00089 ODBCERR_INVALIDBUFFERLEN,
00090 ODBCERR_DATATRUNCATION,
00091 ODBCERR_NORESULT,
00092 ODBCERR_INVALIDOPTION
00093 };
00094
00096 void odbc_errs_reset(struct _sql_errors *errs);
00097
00099 void odbc_errs_add(struct _sql_errors *errs, enum _sql_error_types err_type, const char *msg);
00100
00102 void odbc_errs_add_rdbms(struct _sql_errors *errs, enum _sql_error_types err_type, char *msg, char *sqlstate,
00103 int msgnum, unsigned short linenum, int msgstate);
00104
00105 struct _henv
00106 {
00107 TDSCONTEXT *tds_ctx;
00108 struct _sql_errors errs;
00109 unsigned char odbc_ver;
00110 };
00111
00112 struct _hstmt;
00113 struct _hdbc
00114 {
00115 struct _henv *henv;
00116 TDSSOCKET *tds_socket;
00118 struct _hstmt *current_statement;
00119
00121 int autocommit_state;
00122 struct _sql_errors errs;
00123 };
00124
00125 struct _hstmt
00126 {
00127 struct _hdbc *hdbc;
00128 char *query;
00129
00130 char *prepared_query;
00131 char *prepared_query_s;
00132 char *prepared_query_d;
00133 int prepared_query_need_bytes;
00134 int prepared_query_param_num;
00135 int prepared_query_quoted;
00136 char prepared_query_quote_char;
00137 int prepared_query_is_func;
00138
00139 struct _sql_bind_info *bind_head;
00140 struct _sql_param_info *param_head;
00141 unsigned int param_count;
00142 int row;
00143 TDSDYNAMIC *dyn;
00144 struct _sql_errors errs;
00145 char ard, ird, apd, ipd;
00146 };
00147
00148 struct _sql_param_info
00149 {
00150 int param_number;
00151 int param_type;
00152 int param_bindtype;
00153 int param_sqltype;
00154 char *varaddr;
00155 int param_bindlen;
00156 SQLINTEGER *param_lenbind;
00157 struct _sql_param_info *next;
00158 };
00159
00160 struct _sql_bind_info
00161 {
00162 int column_number;
00163 int column_bindtype;
00164 int column_bindlen;
00165 char *varaddr;
00166 char *column_lenbind;
00167 struct _sql_bind_info *next;
00168 };
00169
00170 typedef struct _henv TDS_ENV;
00171 typedef struct _hdbc TDS_DBC;
00172 typedef struct _hstmt TDS_STMT;
00173
00174 #ifdef __cplusplus
00175 #if 0
00176 {
00177 #endif
00178 }
00179 #endif
00180
00181 #endif