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 SQLNWSTATEMENT_H
21 #define SQLNWSTATEMENT_H
22 #include <AbsSqlStatement.h>
23 #include <SqlNwConnection.h>
24 #include <SqlFactory.h>
26 class SqlNwStatement
: public AbsSqlStatement
29 SqlNwStatement(){innerStmt
= NULL
; con
= NULL
; isPrepared
=false; isSel
= true; nullInfoDml
= NULL
; nullInfoSel
= NULL
; }
30 void setConnection(AbsSqlConnection
*conn
)
32 if (innerStmt
) innerStmt
->setConnection(conn
->getInnerConnection());
35 ~SqlNwStatement() { if (isPrepared
) free(); }
37 DbRetVal
executeDirect(char *stmt
);
38 DbRetVal
prepare(char *stmt
);
40 DbRetVal
execute(int &rowsAffect
);
41 DbRetVal
bindParam(int pos
, void*);
43 DbRetVal
bindField(int pos
, void* val
);
46 void* fetch(DbRetVal
&rv
);
47 void* fetchAndPrint(bool SQL
);
52 void* getFieldValuePtr( int pos
);
53 void* getFieldValuePtr( char *name
){ return NULL
;}
57 int noOfParamFields();
59 DbRetVal
getProjFldInfo(int projPos
, FieldInfo
*&info
);
61 DbRetVal
getParamFldInfo(int paramPos
, FieldInfo
*&info
);
63 void setShortParam(int paramPos
, short value
);
64 void setIntParam(int paramPos
, int value
);
65 void setLongParam(int paramPos
, long value
);
66 void setLongLongParam(int paramPos
, long long value
);
67 void setByteIntParam(int paramPos
, ByteInt value
);
68 void setFloatParam(int paramPos
, float value
);
69 void setDoubleParam(int paramPos
, double value
);
70 void setStringParam(int paramPos
, char *value
);
71 void setDateParam(int paramPos
, Date value
);
72 void setTimeParam(int paramPos
, Time value
);
73 void setTimeStampParam(int paramPos
, TimeStamp value
);
74 void setBinaryParam(int paramPos
, void *value
, int length
);
75 bool isSelect(){return isSel
;}
76 void getPrimaryKeyFieldName(char *tablename
, char *pkfieldname
);
77 int getStmtID() { return stmtID
; }
78 bool isFldNull(int pos
);
79 bool isFldNull(char *name
);
80 void setNull(int pos
);
81 void setStmtID(int id
) { stmtID
= id
; }
82 int getFldPos(char *name
){ return -1;}
83 List
getAllTableNames(DbRetVal
&ret
);
84 List
getAllUserNames(DbRetVal
&ret
){ List dummy
; return dummy
;}
85 char *getTableName(){ return "";}
86 StatementType
getStmtType() { return UnknownStatement
; }
87 int getNoOfPagesForTable(char *tbl
){ return -1;}
88 bool isTablePresent(char *tbName
, DbRetVal
&rv
);
89 void *getLoadedRecords(char *tbName
, DbRetVal
&rv
);
90 DbRetVal
loadRecords(char *tbName
, void *buf
){ return ErrBadCall
;}
91 ResultSetPlan
getResultSetPlan() { return plan
;}
92 bool isPrepd() { return isPrepared
; }
93 void getProjFieldType(int *data
);
94 long long getLastInsertedVal(DbRetVal
&rv
);
105 char *nullInfoSel
; // for nullinfo in fetch
106 char *nullInfoDml
; // for nullinfo in insert and update
107 friend class SqlFactory
;