Main Page   Modules   Compound List   File List   Compound Members   File Members   Related Pages  

tdsodbc.h

00001 /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
00002  * Copyright (C) 1998-1999  Brian Bruns
00003  *
00004  * This library is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU Library General Public
00006  * License as published by the Free Software Foundation; either
00007  * version 2 of the License, or (at your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * Library General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public
00015  * License along with this library; if not, write to the
00016  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00017  * Boston, MA 02111-1307, USA.
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 /* this is usually a const struct that store all errors */
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         /* override error if specified */
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         /* spinellia@acm.org */
00121         int autocommit_state;
00122         struct _sql_errors errs;
00123 };
00124 
00125 struct _hstmt
00126 {
00127         struct _hdbc *hdbc;
00128         char *query;
00129         /* begin prepared query stuff */
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         /* end prepared query stuff */
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;        /* FIXME check if freed */
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

Generated on Sat Apr 5 23:17:40 2003 for FreeTDS API by doxygen1.2.18