#ifndef __PGSQL_WRAPPER_H__ #define __PGSQL_WRAPPER_H__ #include "exceptions.h" enum { DBS_ALL=0, DBS_VALID=1, DBS_STREAM=2 }; class CEscape; #define NEED_ESC CEscape __esc( cmd ); #define esc( param ) __esc.Escape( param ) #define ESCAPE_MAX_VARS 50 void map_to_cvars(mapf, CVars &rec); void load_db_record( const char * table, CVars &rec, const char * where, ... ); long load_db_record( CVars &rec, const char * query, ... ); long insert_db_record( int mode, const char *table, const char *seq, CVars &rec ); void update_db_record( int mode, const char * table, CVars &rec, long id, const char * where=NULL, ... ) throw ( bad_parameter ); void v_update_db_record( int mode, const char * table, CVars &rec, const char *index, long id, const char * where=NULL, va_list ap=NULL ) throw ( bad_parameter ); void update_db_record( int mode, const char * table, CVars &rec, const char *index, long id, const char * where=NULL, ... ) throw ( bad_parameter ); long curr_val( const char *seq ); class CEscape { public: char * New( int sz ); CEscape( char * st ); ~CEscape(); char * Escape( const char * param ); private: char * vars[ESCAPE_MAX_VARS]; int n; char * st; char esc[1000]; int EscapeLength( const char * par ); // Calculate the required buffer size for escaped par char *EscapeReal( const char * cmd, char * _esc=NULL, int sz=0 ); // Escape a string for SQL server }; #endif