1 /***************************************************************************
2 * Copyright (C) 2007 by Prabakaran Thirumalai *
3 * praba_tuty@yahoo.com *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20 #ifndef SQLGWSTATEMENT_H
21 #define SQLGWSTATEMENT_H
22 #include<SqlGwConnection.h>
23 #include <AbsSqlStatement.h>
24 #include <SqlGwConnection.h>
25 #include <SqlFactory.h>
27 class DllExport SqlGwStatement
: public AbsSqlStatement
29 AbsSqlStatement
*adapter
;
34 innerStmt
= NULL
; adapter
= NULL
; con
= NULL
;
35 stmtHdlr
= NoHandler
; isPrepared
= false; mode
= 0;
39 if (adapter
) { adapter
->free(); delete adapter
; adapter
= NULL
; }
41 void setAdapter(AbsSqlStatement
*stmt
) { adapter
= stmt
; }
43 void setConnection(AbsSqlConnection
*conn
)
45 if (innerStmt
) innerStmt
->setConnection(conn
->getInnerConnection());
46 SqlGwConnection
*cn
= (SqlGwConnection
*) conn
;
47 // if (adapter) adapter->setConnection(cn->getAdapterConnection());
51 DbRetVal
executeDirect(char *stmt
);
52 DbRetVal
prepare(char *stmt
);
54 DbRetVal
execute(int &rowsAffect
);
55 DbRetVal
bindParam(int pos
, void*);
57 DbRetVal
bindField(int pos
, void* val
);
60 void* fetch(DbRetVal
&rv
);
61 void* fetchAndPrint(bool SQL
);
66 void* getFieldValuePtr( int pos
);
67 void* getFieldValuePtr( char *name
);
68 AbsSqlStatement
*getInnerStatement(){ return innerStmt
;}
71 int noOfParamFields();
73 DbRetVal
getProjFldInfo(int projPos
, FieldInfo
*&info
);
75 DbRetVal
getParamFldInfo(int paramPos
, FieldInfo
*&info
);
77 void setShortParam(int paramPos
, short value
);
78 void setIntParam(int paramPos
, int value
);
79 void setLongParam(int paramPos
, long value
);
80 void setLongLongParam(int paramPos
, long long value
);
81 void setByteIntParam(int paramPos
, ByteInt value
);
82 void setFloatParam(int paramPos
, float value
);
83 void setDoubleParam(int paramPos
, double value
);
84 void setStringParam(int paramPos
, char *value
);
85 void setDateParam(int paramPos
, Date value
);
86 void setTimeParam(int paramPos
, Time value
);
87 void setTimeStampParam(int paramPos
, TimeStamp value
);
88 void setBinaryParam(int paramPos
, void *value
, int length
);
90 bool isFldNull(int pos
);
91 bool isFldNull(char *name
);
92 void setNull(int pos
);
93 ResultSetPlan
getResultSetPlan();
94 int getFldPos(char *name
){ return -1;}
95 List
getAllTableNames(DbRetVal
&ret
);
96 List
getAllUserNames(DbRetVal
&ret
);
97 char *getTableName(){ return "";}
98 StatementType
getStmtType() { return UnknownStatement
; }
99 int getNoOfPagesForTable(char *tbl
){ return -1;}
100 DbRetVal
loadRecords(char *tbl
, void *buf
){ return ErrBadCall
;}
101 void setToCommit(char *dsName
);
102 void getProjFieldType(int *data
);
103 long long getLastInsertedVal(DbRetVal
&ret
);
105 bool shouldAdapterHandle();
106 bool shouldCSqlHandle();
108 friend class SqlFactory
;