9#if __DCL_HAVE_ALLOC_DEBUG
10#undef __DCL_ALLOC_LEVEL
11#define __DCL_ALLOC_LEVEL __DCL_ALLOC_INTERNAL
24#define __DCL_TRACE0_N __DCL_TRACE0
25#define __DCL_TRACE1_N __DCL_TRACE1
26#define __DCL_TRACE2_N __DCL_TRACE2
27#define __DCL_TRACE3_N __DCL_TRACE3
28#define __DCL_TRACE4_N __DCL_TRACE4
29#define __DCL_TRACE5_N __DCL_TRACE5
30#define __DCL_TRACE6_N __DCL_TRACE6
32#define __DCL_TRACE0_N(fmt)
33#define __DCL_TRACE1_N(fmt, arg)
34#define __DCL_TRACE2_N(fmt, arg1, arg2)
35#define __DCL_TRACE3_N(fmt, arg1, arg2, arg3)
36#define __DCL_TRACE4_N(fmt, arg1, arg2, arg3, arg4)
37#define __DCL_TRACE5_N(fmt, arg1, arg2, arg3, arg4, arg5)
38#define __DCL_TRACE6_N(fmt, arg1, arg2, arg3, arg4, arg5, arg6)
46#define __SET_ERROR(_error) \
47 connection()->setErrorStatus(_error, __THIS_FILE__, __LINE__)
48#define __SET_ERROR_MSG(_message) \
49 conn()->setErrorMessage(_message, __THIS_FILE__, __LINE__)
56 Query::__placeholder = L
'$';
69 size_t buflen =
sizeof(buf) - 1;
70 bool b = conn()->__getErrorMessage(buf, &buflen);
71 buf[b ? buflen : 0] =
'\0';
87 Query::__affectedRows = -1;
94 Query::__fieldCount = 0;
102 Query::__paramCount = 0;
107 int rc = sqlite3_finalize(
__stmt);
108 if (rc != SQLITE_OK) {
118 const char* _sql,
size_t _sqllen,
size_t _paramCount
124 sqlite3_stmt* stmt =
NULL;
125 const char* pzTail =
NULL;
126 int rc = sqlite3_prepare_v2(conn()->connHandle(),
127 _sql, (
int)_sqllen, &stmt, &pzTail);
128 if (rc != SQLITE_OK) {
133#if defined(__DCL_DEBUG) && __TRACE_THIS
135 sqlite3_bind_parameter_count(stmt)
138 sqlite3_column_count(stmt)
143 && (Query::__paramCount == 0)
146 Query::__paramCount = sqlite3_bind_parameter_count(stmt);
147 if (Query::__paramCount) {
154 for (
size_t i = 0; i < Query::__paramCount; i++) {
155 int number = (int) i + 1;
156 const char* name = sqlite3_bind_parameter_name(stmt, number);
157 if (!
__params[i].init(
this, number, name)) {
171 for (
size_t i = 0; i < Query::__paramCount; i++) {
172 if (!(
__params[i].onBeforeExecute()))
176 int rc = sqlite3_step(
__stmt);
181 && (Query::__fieldCount == 0)
183 Query::__fieldCount = sqlite3_column_count(
__stmt);
190 for (
size_t i = 0; i < Query::__fieldCount; i++) {
191 if (!
__fields[i].init(
this, (
int) i))
194 Query::__eof =
false;
200#if SQLITE_VERSION_NUMBER >= 3037000
201 Query::__affectedRows = sqlite3_changes64(conn()->connHandle());
203 Query::__affectedRows = sqlite3_changes(conn()->connHandle());
206 rc, Query::__affectedRows
216 if (Query::__paramCount) {
217 for (
size_t i = 0; i < Query::__paramCount; i++) {
218 if (!(
__params[i].onAfterExecute()))
221 rc = sqlite3_reset(
__stmt);
222 if (rc != SQLITE_OK) {
237 int rc = sqlite3_step(
__stmt);
257 __DCL_ASSERT((0 <= _index) && (_index < Query::__fieldCount));
258 *_fieldHandleOut = &
__fields[_index];
265 __DCL_ASSERT((0 <= _index) && (_index < Query::__paramCount));
266 *_paramHandleOut = &
__params[_index];
#define __DCL_TRACE1_N(fmt, arg)
#define __DCL_TRACE2_N(fmt, arg1, arg2)
#define __SET_ERROR_MSG(_message)
#define __DCL_TRACE1(fmt, arg1)
#define __DCL_ASSERT(expr)
#define IMPLEMENT_CLASSINFO(class_name, base_class_name)
#define __SET_ERROR(_errorCode)
virtual bool __getField(size_t _index, SQL::Field **_fieldHandleOut)
virtual bool __getParam(size_t _index, SQL::Param **_paramHandleOut)
SqQuery(SqConnection *pConnection)
virtual bool __prepare(const char *_sql, size_t _sqllen, size_t _paramCount)