Main Page   Modules   File List   Globals   Related Pages   Examples  

sqlora.h

Go to the documentation of this file.
00001 #ifndef __SQLORA8_H_LOADED
00002 #define __SQLORA8_H_LOADED
00003 /* $Id: sqlora.h,v 1.27 2002/10/30 19:19:25 kpoitschke Exp $ */
00017 /*
00018  *
00019  * Permission to use, copy, modify, and distribute this software for
00020  * any purpose with or without fee is hereby granted, provided that
00021  * the above copyright notice and this permission notice appear in all
00022  * copies.
00023  *
00024  *    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
00025  *    WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00026  *    MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
00027  *    IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
00028  *    CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00029  *    SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00030  *    LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
00031  *    USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00032  *    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00033  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00034  *    OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00035  *    SUCH DAMAGE.
00036  *
00037  */
00038 
00039 
00063 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00064 #include <stdio.h>
00065 #include "libsqlora8-config.h"
00066 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
00067 
00068 /*
00069  * Definitions that allow this header file to be used either with or
00070  * without ANSI C features like function prototypes.
00071  */
00072 
00073 
00074 /* @def __BEGIN_DECLS
00075  * __BEGIN_DECLS should be used at the beginning of your declarations,
00076  *  so that C++ compilers don't mangle their names.  Use @ref__END_DECLS at
00077  *  the end of C declarations. 
00078  */
00079 
00080 /* @def __END_DECLS
00081  * Opposite of @ref __BEGIN_DECLS
00082  */
00083 #undef __BEGIN_DECLS
00084 #undef __END_DECLS
00085 #ifdef __cplusplus
00086 # define __BEGIN_DECLS extern "C" {
00087 # define __END_DECLS }
00088 #else
00089 # define __BEGIN_DECLS /* empty */
00090 # define __END_DECLS /* empty */
00091 #endif
00092 
00093 /*
00094  * @def __P
00095  * __P is a macro used to wrap function prototypes.
00096  *
00097  * Compilers that don't understand ANSI C prototypes still work, and ANSI C
00098  * compilers can issue warnings about type mismatches. 
00099  * Use autoconf macro AC_C_PROTOTYPES to check for prototypes.
00100 */
00101 #undef __P
00102 #if (defined(PROTOTYPES) || defined(__STDC__) || defined(__cplusplus) )
00103 # define __P(protos) protos
00104 #else
00105 # define __P(protos) ()
00106 #endif
00107 
00108 /*
00109  * @def CONST
00110  * Used to define constants.
00111  *
00112  * For ANSI C compilers this expands to const, for others its an empty definition.
00113  * @note AC_C_CONST defines const empty if it is not supported.
00114  */
00115 #undef CONST
00116 
00117 #ifndef const
00118 #  if (defined(__STDC__) || defined(PROTOTYPES) || defined(__cplusplus))
00119 #    define CONST const
00120 #  else
00121 #    define CONST
00122 #  endif
00123 #else
00124 #  define CONST
00125 #endif
00126 
00138 enum sqlo_status_codes {
00139   SQLO_SUCCESS             = 0,   
00140   SQLO_ERROR               = -1,      
00141   SQLO_INVALID_HANDLE      = -2,                  
00142   SQLO_STILL_EXECUTING     = -3123,              
00143   SQLO_CONTINUE            = -24200,                    
00144   SQLO_SUCCESS_WITH_INFO   = 1,                
00145   SQLO_NEED_DATA           = 99,                       
00146   SQLO_NO_DATA             = 100                         
00147 };
00148 
00155 enum sqlo_error_codes {
00156   SQLO_ERROR_BASE          = -30000,     
00157   SQLO_INVALID_DB_HANDLE   = (SQLO_ERROR_BASE - 1),      
00158   SQLO_ERRMALLOC           = (SQLO_ERROR_BASE - 2),  
00159   SQLO_INVALID_STMT_HANDLE = (SQLO_ERROR_BASE - 3), 
00160   SQLO_STMT_NOT_OPENED     = (SQLO_ERROR_BASE - 4), 
00162   SQLO_INVALID_STMT_TYPE   = (SQLO_ERROR_BASE - 5), 
00164   SQLO_STMT_NOT_PARSED     = (SQLO_ERROR_BASE - 6), 
00166   SQLO_INVALID_OCI_HANDLE_TYPE = (SQLO_ERROR_BASE - 7), 
00168   SQLO_MALFORMED_VERSION_STR = (SQLO_ERROR_BASE - 8), 
00170   SQLO_WRONG_VERSION       = (SQLO_ERROR_BASE - 9), 
00172   SQLO_INVALID_COLPOS      = (SQLO_ERROR_BASE - 10), 
00173   SQLO_INVALID_SQL         = (SQLO_ERROR_BASE -11) 
00174 };
00175 
00180 enum sqlo_constants {
00181   SQLO_OFF                 =  0, 
00182   SQLO_ON                  =  1, 
00183   SQLO_NULL_IND            = -1, 
00184   SQLO_NOT_NULL_IND        =  0, 
00185   SQLO_STH_INIT            = -1, 
00188   /* constants for piece operations (lob writes). */
00189   SQLO_ONE_PIECE           = 0, 
00191   SQLO_FIRST_PIECE         = 1, 
00193   SQLO_NEXT_PIECE          = 2, 
00195   SQLO_LAST_PIECE          = 3 
00198 };
00199 
00208 enum sqlo_data_types {
00209   SQLOT_CHR  = 1,                      
00210   SQLOT_NUM  = 2,                        
00211   SQLOT_INT  = 3,                               
00212   SQLOT_FLT  = 4,                 
00213   SQLOT_STR  = 5,                              
00214   SQLOT_VNU  = 6,                      
00215   SQLOT_PDN  = 7,                
00216   SQLOT_LNG  = 8,                                                
00217   SQLOT_VCS  = 9,                           
00218   SQLOT_NON  = 10,                    
00219   SQLOT_RID  = 11,                                              
00220   SQLOT_DAT  = 12,                              
00221   SQLOT_VBI  = 15,                               
00222   SQLOT_BIN  = 23,                                
00223   SQLOT_LBI  = 24,                                        
00224   SQLOT_UIN  = 68,                                   
00225   SQLOT_SLS  = 91,                      
00226   SQLOT_LVC  = 94,                                
00227   SQLOT_LVB  = 95,                                 
00228   SQLOT_AFC  = 96,                                    
00229   SQLOT_AVC  = 97,                                      
00230   SQLOT_CUR  = 102,                                      
00231   SQLOT_RDD  = 104,                                  
00232   SQLOT_LAB  = 105,                                        
00233   SQLOT_OSL  = 106,                                      
00234   SQLOT_NTY  = 108,                                 
00235   SQLOT_REF  = 110,                                          
00236   SQLOT_CLOB = 112,                                     
00237   SQLOT_BLOB = 113,                                        
00238   SQLOT_BFILEE = 114,                                 
00239   SQLOT_CFILEE = 115,                              
00240   SQLOT_RSET = 116,                                   
00241   SQLOT_NCO  = 122,    
00242   SQLOT_VST  = 155,                                    
00243   SQLOT_ODT  = 156,                                      
00245 /* datetimes and intervals */
00246   SQLOT_DATE                   = 184,                      
00247   SQLOT_TIME                   = 185,                           
00248   SQLOT_TIME_TZ                = 186,            
00249   SQLOT_TIMESTAMP              = 187,                      
00250   SQLOT_TIMESTAMP_TZ           = 188,       
00251   SQLOT_INTERVAL_YM            = 189,         
00252   SQLOT_INTERVAL_DS            = 190,         
00253   SQLOT_TIMESTAMP_LTZ          = 232         
00254 };
00255 
00256 /* cxcheng: this has been added for backward compatibility -
00257    it needs to be here because ocidfn.h can get included ahead of sqldef.h */
00258 #define SQLOT_FILE SQLOT_BFILEE                              /* binary file lob */
00259 #define SQLOT_CFILE SQLOT_CFILEE
00260 #define SQLOT_BFILE SQLOT_BFILEE
00261 
00266 enum sqlo_statement_states {
00267   SQLO_STMT_STATE_INITIALIZED = 1, 
00268   SQLO_STMT_STATE_EXECUTED    = 2, 
00269   SQLO_STMT_STATE_END_OF_FETCH = 3 
00270 };
00271 
00282 typedef int sqlo_db_handle_t;
00283 
00287 typedef int sqlo_stmt_handle_t;
00288 
00292 typedef enum {
00293   SQLO_OCI_HTYPE_ENV     = 1,   
00294   SQLO_OCI_HTYPE_ERROR   = 2,   
00295   SQLO_OCI_HTYPE_SVCCTX  = 3,   
00296   SQLO_OCI_HTYPE_SERVER  = 4,   
00297   SQLO_OCI_HTYPE_SESSION = 5,   
00298   SQLO_OCI_HTYPE_STMT    = 6    
00299 } sqlo_oci_handle_types_e;
00300 
00301 
00307 typedef void * sqlo_lob_desc_t;
00308 
00309 
00313 typedef void (*sqlo_signal_handler_t) __P((void));
00314 
00315 
00318 /*-------------------------------------------------------------------------
00319  * Version Information
00320  *-----------------------------------------------------------------------*/
00330 extern CONST unsigned sqlo_major_version;
00335 extern CONST unsigned sqlo_minor_version;
00340 extern CONST unsigned sqlo_micro_version;
00345 extern CONST unsigned sqlo_interface_age;
00350 extern CONST unsigned sqlo_binary_age;
00351 
00352 /* to keep backward compatibility with <= 2.2, otherwise we break too much */
00353 extern CONST unsigned sqlora8_major_version;
00354 extern CONST unsigned sqlora8_minor_version;
00355 extern CONST unsigned sqlora8_micro_version;
00356 extern CONST unsigned sqlora8_interface_age;
00357 extern CONST unsigned sqlora8_binary_age;
00358 #define SQLORA8_MAJOR_VERSION LIBSQLORA8_MAJOR_VERSION
00359 #define SQLORA8_MINOR_VERSION LIBSQLORA8_MINOR_VERSION
00360 #define SQLORA8_MICRO_VERSION LIBSQLORA8_MICRO_VERSION
00361 
00362 /* @} */
00363 
00370 #define SQLORA8_CHECK_VERSION(major,minor,micro)    \
00371     (LIBSQLORA8_MAJOR_VERSION > (major) || \
00372      (LIBSQLORA8_MAJOR_VERSION == (major) && LIBSQLORA8_MINOR_VERSION > (minor)) || \
00373      (LIBSQLORA8_MAJOR_VERSION == (major) && LIBSQLORA8_MINOR_VERSION == (minor) && \
00374       LIBSQLORA8_MICRO_VERSION >= (micro)))
00375 
00376 
00377 
00378 /*-------------------------------------------------------------------------
00379  * FUNCTION DECLARATIONS
00380  *-----------------------------------------------------------------------*/
00381 __BEGIN_DECLS
00382 
00407 int sqlo_init __P((int threaded_mode, unsigned int max_db, unsigned int max_cursors));
00408 
00423 int sqlo_version __P((CONST char * version_str));
00424 
00439 CONST char * sqlo_geterror __P(( sqlo_db_handle_t dbh ));
00440 
00448 int sqlo_geterrcode __P(( sqlo_db_handle_t dbh ));
00449 
00478 int sqlo_exists __P(( sqlo_db_handle_t dbh, 
00479                       CONST char * table, 
00480                       CONST char * colname,
00481                       CONST char * colval, 
00482                       CONST char * where ));
00502 int sqlo_count __P((sqlo_db_handle_t dbh,
00503                     CONST char * table,
00504                     CONST char * colname,
00505                     CONST char * colval,
00506                     CONST char * where ));
00507 
00528 int sqlo_run __P(( sqlo_db_handle_t dbh, CONST char * stmt, int argc, CONST char ** argv));
00529 
00530 
00555 sqlo_stmt_handle_t sqlo_open __P((sqlo_db_handle_t dbh, 
00556                                   CONST char * stmt, 
00557                                   int argc, 
00558                                   CONST char ** argv));
00559 
00591 int sqlo_open2 __P((sqlo_stmt_handle_t * sthp, 
00592                     sqlo_db_handle_t dbh, 
00593                     CONST char * stmt, 
00594                     int argc, 
00595                     CONST char ** argv));
00596 
00619 int sqlo_reopen __P((sqlo_stmt_handle_t sth, 
00620                      int argc, 
00621                      CONST char ** argv));
00622 
00644 int sqlo_fetch __P((sqlo_stmt_handle_t sth, unsigned int nrows));
00645 
00665 CONST char **sqlo_values __P(( sqlo_stmt_handle_t sth, int * num, int dostrip ));
00666 
00681 CONST unsigned short * sqlo_value_lens __P(( sqlo_stmt_handle_t sth, int * num));
00682 
00697 CONST char **sqlo_ocol_names __P(( sqlo_stmt_handle_t sth, int * num));
00698 
00699 
00714 CONST int *sqlo_ocol_name_lens __P(( sqlo_stmt_handle_t sth, int * num));
00715 
00728 int sqlo_ncols __P((sqlo_stmt_handle_t sth, int in));
00729 
00737 CONST char *sqlo_command __P(( sqlo_stmt_handle_t sth ));
00738 
00752 int sqlo_close __P(( sqlo_stmt_handle_t sth ));
00753 
00770 int sqlo_exec __P(( sqlo_db_handle_t dbh, CONST char * stmt ));
00771 
00772 
00773 
00786 int sqlo_isopen __P((sqlo_stmt_handle_t sth));
00787 
00800 int sqlo_prows __P(( sqlo_stmt_handle_t sth ));
00801 
00827 int sqlo_connect __P(( sqlo_db_handle_t * dbhp, CONST char * cstr ));
00828 
00829 
00845 int sqlo_finish __P((sqlo_db_handle_t dbh ));
00846 
00866 int sqlo_split_cstring __P((CONST char * cstr, 
00867                             char * uid, 
00868                             char * pwd, 
00869                             char * tnsname, 
00870                             unsigned int bufsize));
00871 
00891 int sqlo_server_attach __P((sqlo_db_handle_t * dbhp, CONST char * tnsname));
00892 
00913 int sqlo_session_begin __P((sqlo_db_handle_t dbh, CONST char * username, CONST char * password));
00914 
00931 int sqlo_server_detach __P((sqlo_db_handle_t dbh));
00932 
00952 int sqlo_server_free __P((sqlo_db_handle_t dbh));
00953 
00973 int sqlo_session_end __P((sqlo_db_handle_t dbh));
00974 
00975 
00988 CONST char * sqlo_getdatabase __P((sqlo_db_handle_t dbh ));
00989 
01010 int sqlo_commit __P((sqlo_db_handle_t dbh));
01011 
01025 int sqlo_rollback __P((sqlo_db_handle_t dbh));
01059 int sqlo_prepare __P((sqlo_db_handle_t dbh, CONST char * stmt));
01060 
01089 int sqlo_bind_by_name __P((sqlo_stmt_handle_t sth, 
01090                            CONST char * name, 
01091                            int param_type, 
01092                            CONST void * param_addr, 
01093                            unsigned int param_size, 
01094                            short * ind_addr, 
01095                            int is_array));
01096 
01116 int sqlo_bind_ref_cursor __P((sqlo_stmt_handle_t sth, CONST char * cursor_name, int * sth2p));
01117 
01143 int sqlo_bind_by_pos __P((sqlo_stmt_handle_t sth, 
01144                           int position, 
01145                           int param_type, 
01146                           CONST void * param_addr, 
01147                           unsigned int param_size, 
01148                           short * ind_addr, 
01149                           int is_array));
01150 
01177 int sqlo_bind_by_pos2 __P((sqlo_stmt_handle_t sth, 
01178                            int position, 
01179                            int param_type, 
01180                            CONST void * param_addr, 
01181                            unsigned int param_size, 
01182                            short * ind_addr,
01183                            unsigned short * rcode_addr, 
01184                            unsigned int skip_size));
01185 
01186 
01221 int sqlo_define_by_pos __P((sqlo_stmt_handle_t sth, 
01222                             int value_pos, 
01223                             int value_type,
01224                             CONST void * value_addr,
01225                             unsigned int value_size,
01226                             short * ind_addr,
01227                             short * rlen_addr,
01228                             int is_array));
01229 
01265 int sqlo_define_by_pos2 __P((sqlo_stmt_handle_t sth, 
01266                              int value_pos, 
01267                              int value_type,
01268                              CONST void * value_addr,
01269                              unsigned int value_size,
01270                              short * ind_addr,
01271                              unsigned short * rlen_addr,
01272                              unsigned short * rcode_addr,
01273                              unsigned int skip_size));
01274 
01288 int sqlo_define_ntable __P((sqlo_stmt_handle_t sth, unsigned int pos, int * sth2p));
01289 
01290 
01313 int sqlo_execute __P((sqlo_stmt_handle_t sth, unsigned int iterations));
01314 
01332 int sqlo_alloc_lob_desc __P((sqlo_db_handle_t dbh, sqlo_lob_desc_t *loblpp));
01333 
01348 int sqlo_free_lob_desc __P((sqlo_db_handle_t dbh, sqlo_lob_desc_t *loblpp));
01349 
01375 int sqlo_lob_write_buffer __P((sqlo_db_handle_t dbh, sqlo_lob_desc_t loblp, unsigned int loblen, 
01376                                void *bufp, unsigned int bufl, unsigned int piece));
01402 int sqlo_lob_append_buffer __P((sqlo_db_handle_t dbh, sqlo_lob_desc_t loblp, 
01403                                 unsigned int loblen, 
01404                                 void *bufp, unsigned int bufl, 
01405                                 unsigned int piece));
01406 
01429 int sqlo_lob_write_stream __P((sqlo_db_handle_t dbh, sqlo_lob_desc_t loblp, unsigned int filelen, FILE * fp));
01430 
01431 
01445 int sqlo_lob_get_length __P((sqlo_db_handle_t dbh, sqlo_lob_desc_t loblp, unsigned int * loblenp));
01446 
01471 int sqlo_lob_read_buffer __P((sqlo_db_handle_t dbh, sqlo_lob_desc_t loblp, unsigned int loblen, void *bufp, unsigned int bufl));
01472 
01473 
01496 int sqlo_lob_read_stream __P((sqlo_db_handle_t dbh, sqlo_lob_desc_t loblp, unsigned int loblen, 
01497                               FILE *fp));
01521 int sqlo_get_oci_handle __P((int sqloh, void * ocihp, sqlo_oci_handle_types_e type));
01522 
01532 int sqlo_get_db_handle __P((sqlo_stmt_handle_t sth));
01533 
01534 
01561 int sqlo_set_blocking __P((sqlo_db_handle_t dbh, unsigned int on));
01562 
01563 
01575 int sqlo_get_blocking __P((sqlo_db_handle_t dbh, unsigned int * blocking));
01576 
01577 
01598 int sqlo_break __P((sqlo_db_handle_t dbh));
01599 
01600 
01612 int sqlo_set_prefetch_rows __P((sqlo_stmt_handle_t sth, unsigned int nrows));
01613 
01614 
01631 int sqlo_server_version __P((sqlo_db_handle_t dbh, char *bufp, unsigned int buflen));
01632 
01640 int sqlo_get_stmt_state __P((sqlo_stmt_handle_t sth));
01641 
01648 CONST char * sqlo_get_stmt __P((sqlo_stmt_handle_t sth));
01649 
01661 int sqlo_get_ocol_dtype __P((sqlo_stmt_handle_t sth, unsigned int pos));
01662 
01663 
01677 int sqlo_trace __P((sqlo_db_handle_t dbh, int on ));
01678 
01679 
01692 int sqlo_print __P(( sqlo_stmt_handle_t sth ));
01693 
01705 int sqlo_register_int_handler __P((int * handle, sqlo_signal_handler_t signal_handler));
01706 
01713 int sqlo_clear_int_handler __P((int handle));
01714 
01715 
01720 /*-----------------------------------------------------------------------*/
01721 /* Functions to keep backward compatibility                              */
01722 /* Dont use this for new developments                                    */
01723 /*-----------------------------------------------------------------------*/
01724 #ifndef DOXYGEN_SHOULD_SKIP_THIS
01725 
01726 int sql_init __P(( void ));
01727 
01728 int sql_trace __P(( int on ));
01729 
01730 CONST char * sql_geterror __P(( void ));
01731 
01732 int sql_geterrcode __P(( void ));
01733 
01734 int sql_exists __P((CONST char  * table, CONST char  * field,
01735                     CONST char * value, CONST char * where ));
01736 int sql_run __P((CONST char * stmt, int argc, CONST char ** argv));
01737 
01738 int sql_open __P((CONST char * stmt, int argc, 
01739                                     CONST char ** argv));
01740 
01741 int sql_reopen __P((int sth, int argc, CONST char ** argv));
01742 
01743 int sql_fetch __P((int sth ));
01744 
01745 CONST char **sql_values __P(( int sth, int * num, int dostrip ));
01746 
01747 CONST char *sql_command __P(( int sth ));
01748 
01749 int sql_close __P(( int sth ));
01750 
01751 int sql_print __P(( int sth ));
01752 
01753 int sql_finish __P((void));
01754 
01755 CONST char * sql_getdatabase __P(( void ));
01756 
01757 CONST char ** sql_cnam __P(( int sth, int in, int * num ));
01758 
01759 CONST char ** sql_sclen __P(( int sth, int in, int * num ));
01760 
01761 int sql_prows __P(( int sth ));
01762 
01763 int sql_connect __P(( CONST char  * connect_str ));
01764 
01765 int sql_commit __P(( void ));
01766 
01767 int sql_rollback __P(( void ));
01768 
01769 int sql_count __P((CONST char * table,
01770                    CONST char * field,
01771                    CONST char * value,
01772                    CONST char * where ));
01773 
01774 int sql_exec __P(( CONST char * stmt ));
01775 
01776 int sql_setparam __P(( int argc , CONST char ** argv));
01777 
01778 char CONST ** sql_getparam __P(( int namec, CONST char ** name, int *numvalues ));
01779 int sql_isopen __P((int sth));
01780 
01781 int sql_prepare __P((CONST char * stmt));
01782 
01783 int sql_bind_by_name __P((int sth, CONST char * name, int param_type, 
01784                           CONST void * param_addr, unsigned int param_size, 
01785                           short * ind_addr, int is_array));
01786 
01787 int sql_bind_by_pos __P((int sth, int position, int param_type, CONST void * param_addr, unsigned int param_size, short * ind_addr, int is_array));
01788 
01789 int sql_define_by_pos __P((int sth, int value_pos, int value_type,
01790                            CONST void * value_addr,
01791                            unsigned int value_size,
01792                            short * ind_addr,
01793                            short * rlen_addr,
01794                            int is_array));
01795 
01796 int sql_execute __P((int sth, int iterations));
01797 
01798 char CONST **sql_ocol_names __P((int sth, int * num));
01799 
01800 int CONST *sql_ocol_name_lens __P((int sth, int * num));
01801 
01802 unsigned short CONST * sql_value_lens __P((int sth, int * num));
01803 
01804 int sql_ncols __P((int sth, int in));
01805 
01806 int sql_getdbh __P((void));
01807 
01808 #define  SQLO_DEFDBH  (sql_getdbh())
01809 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
01810 
01811 __END_DECLS
01812 
01813 
01814 #endif
01815 

Generated on Mon Aug 25 12:28:30 2003 for libsqlora8 by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002