71 if (!prepared_st_handle)
73 if (m_resetRequired) {
74 res = sqlite3_reset(prepared_st_handle);
75 if (SQLITE_OK != res) {
79 m_resetRequired =
false;
90 itFields = *m_whereFields;
92 itFields = m_fields->fieldsIterator();
96 for (TQValueListConstIterator<TQVariant> it = m_args.constBegin();
97 (field = itFields.current()); ++it, ++itFields, arg++)
99 if (it==m_args.constEnd() || (*it).isNull()) {
100 res = sqlite3_bind_null(prepared_st_handle, arg);
101 if (SQLITE_OK != res) {
107 if (field->isTextType()) {
109 TQCString utf8String((*it).toString().utf8());
110 res = sqlite3_bind_text(prepared_st_handle, arg,
111 (
const char*)utf8String, utf8String.length(), SQLITE_TRANSIENT );
112 if (SQLITE_OK != res) {
117 else switch (field->type()) {
124 const int value = (*it).toInt(&ok);
126 res = sqlite3_bind_int(prepared_st_handle, arg, value);
127 if (SQLITE_OK != res) {
133 res = sqlite3_bind_null(prepared_st_handle, arg);
134 if (SQLITE_OK != res) {
143 res = sqlite3_bind_double(prepared_st_handle, arg, (*it).toDouble());
144 if (SQLITE_OK != res) {
153 TQ_LLONG value = (*it).toLongLong(&ok);
155 res = sqlite3_bind_int64(prepared_st_handle, arg, value);
156 if (SQLITE_OK != res) {
162 res = sqlite3_bind_null(prepared_st_handle, arg);
163 if (SQLITE_OK != res) {
171 res = sqlite3_bind_text(prepared_st_handle, arg,
172 TQString::number((*it).toBool() ? 1 : 0).latin1(),
173 1, SQLITE_TRANSIENT );
174 if (SQLITE_OK != res) {
179 case KexiDB::Field::Time:
180 res = sqlite3_bind_text(prepared_st_handle, arg,
181 TQString((*it).toTime().toString(TQt::ISODate)).latin1(),
182 sizeof(
"HH:MM:SS"), SQLITE_TRANSIENT );
183 if (SQLITE_OK != res) {
188 case KexiDB::Field::Date:
189 res = sqlite3_bind_text(prepared_st_handle, arg,
190 TQString((*it).toDate().toString(TQt::ISODate)).latin1(),
191 sizeof(
"YYYY-MM-DD"), SQLITE_TRANSIENT );
192 if (SQLITE_OK != res) {
197 case KexiDB::Field::DateTime:
198 res = sqlite3_bind_text(prepared_st_handle, arg,
199 (*it).toDateTime().toString(TQt::ISODate).latin1(),
200 sizeof(
"YYYY-MM-DDTHH:MM:SS"), SQLITE_TRANSIENT );
201 if (SQLITE_OK != res) {
208 const TQByteArray byteArray((*it).toByteArray());
209 res = sqlite3_bind_blob(prepared_st_handle, arg,
210 (
const char*)byteArray, byteArray.size(), SQLITE_TRANSIENT );
211 if (SQLITE_OK != res) {
218 KexiDBWarn <<
"PreparedStatement::execute(): unsupported field type: "
219 << field->type() <<
" - NULL value bound to column #" << arg << endl;
220 res = sqlite3_bind_null(prepared_st_handle, arg);
221 if (SQLITE_OK != res) {
229 res = sqlite3_step(prepared_st_handle);
230 m_resetRequired =
true;
PreparedStatement(StatementType type, ConnectionInternal &conn, FieldList &fields, const TQStringList &where=TQStringList())
Creates Prepared statement. In your code use KexiDB::Connection:prepareStatement() instead.