10 m_pStatement = pStatement;
11 m_strOriginalQuery = strQuery;
39 TDS_INT8 saved_rows_affected = 0;
40 while ((rc = tds_process_tokens(
m_pDatabase, &result_type, NULL, TDS_TOKEN_RESULTS)) == TDS_SUCCESS)
45 case TDS_DONEPROC_RESULT:
47 case TDS_STATUS_RESULT:
49 case TDS_DONEINPROC_RESULT:
52 case TDS_ROWFMT_RESULT:
53 case TDS_COMPUTEFMT_RESULT:
54 case TDS_DESCRIBE_RESULT:
60 while (tds_process_tokens(
m_pDatabase, &result_type, NULL, TDS_STOPAT_ROWFMT|TDS_RETURN_DONE|TDS_RETURN_ROW) == TDS_SUCCESS)
63 if (result_type != TDS_ROW_RESULT)
90 else if (rc != TDS_NO_MORE_RESULTS)
102 while ((pParameters == NULL) || (nPosition > (pParameters->num_cols)))
104 pParameters = tds_alloc_param_result(pParameters);
105 if (pParameters == NULL)
124 TDSCOLUMN* curcol =
m_pStatement->params->columns[nPosition-1];
125 tds_set_param_type(
m_pDatabase->conn, curcol, SYBINTN);
126 curcol->column_size =
sizeof(TDS_INT);
127 curcol->on_server.column_size =
sizeof(TDS_INT);
128 curcol->column_cur_size =
sizeof(TDS_INT);
130 tds_alloc_param_data(curcol);
131 memcpy(curcol->column_data, &nValue,
sizeof(nValue));
140 TDSCOLUMN* curcol =
m_pStatement->params->columns[nPosition-1];
141 tds_set_param_type(
m_pDatabase->conn, curcol, SYBFLTN);
142 curcol->column_size =
sizeof(TDS_FLOAT);
143 curcol->on_server.column_size =
sizeof(TDS_FLOAT);
144 curcol->column_cur_size =
sizeof(TDS_FLOAT);
146 tds_alloc_param_data(curcol);
147 memcpy(curcol->column_data, &dblValue,
sizeof(dblValue));
168 TDSCOLUMN* curcol =
m_pStatement->params->columns[nPosition-1];
169 tds_set_param_type(
m_pDatabase->conn, curcol, XSYBNVARCHAR);
170 curcol->column_size = nLength+1;
171 curcol->column_cur_size = nLength;
173 tds_alloc_param_data(curcol);
174 memcpy(curcol->column_data, valueBuffer, nLength+1);
183 TDSCOLUMN* curcol =
m_pStatement->params->columns[nPosition-1];
184 tds_set_param_type(
m_pDatabase->conn, curcol, SYBVARCHAR);
186 tds_alloc_param_data(curcol);
200 int ret = tds_convert(tds_get_ctx(this->
m_pDatabase), SYBBINARY, (TDS_CHAR*)pData, nDataLength, SYBVARBINARY, &cr);
202 TDSCOLUMN* curcol =
m_pStatement->params->columns[nPosition-1];
203 tds_set_param_type(
m_pDatabase->conn, curcol, SYBVARBINARY);
204 curcol->column_size = ret;
205 curcol->on_server.column_size = ret;
206 curcol->column_cur_size = ret;
208 tds_alloc_param_data(curcol);
210 memcpy(curcol->column_data, cr.ib, ret);
211 int x =
sizeof(cr.ib);
223 wxString dateAsString = dateValue.Format(_(
"%Y-%m-%d %H:%M:%S"));
234 int ret = tds_convert(tds_get_ctx(this->
m_pDatabase), SYBVARCHAR, (TDS_CHAR*)(
const char*)dateCharBuffer, bufferLength, SYBDATETIME, &cr);
237 int valueSize = (ret < 0) ?
sizeof(TDS_DATETIME) : ret;
239 TDSCOLUMN* curcol =
m_pStatement->params->columns[nPosition-1];
240 tds_set_param_type(
m_pDatabase->conn, curcol, SYBDATETIMN);
241 curcol->column_size = valueSize;
242 curcol->on_server.column_size = valueSize;
243 curcol->column_cur_size = valueSize;
245 tds_alloc_param_data(curcol);
246 memcpy(curcol->column_data, &cr.dt, valueSize);
258 TDSCOLUMN* curcol =
m_pStatement->params->columns[nPosition-1];
259 tds_set_param_type(
m_pDatabase->conn, curcol, SYBBITN);
260 curcol->column_size =
sizeof(bool);
261 curcol->on_server.column_size =
sizeof(bool);
262 curcol->column_cur_size =
sizeof(bool);
264 tds_alloc_param_data(curcol);
265 memcpy(curcol->column_data, &bValue ,
sizeof(
bool));
278 bool bInStringLiteral =
false;
282 if (
'\'' == character)
285 bInStringLiteral = !bInStringLiteral;
287 else if ((
'?' == character) && !bInStringLiteral)
306 if (nReturn != TDS_SUCCESS)
329 if (nReturn != TDS_SUCCESS)
355 if (pDatabase != NULL)
362 #endif//wxUSE_DATABASE_TDS virtual void SetParamDate(int nPosition, const wxDateTime &dateValue)
Set the parameter at the 1-based position to a wxDateTime value.
virtual void Close()
Close the result set (call wxDatabase::ClosePreparedStatement() instead on the statement)
virtual void SetParamBlob(int nPosition, const void *pData, long nDataLength)
Set the parameter at the 1-based position to a Blob value.
virtual void SetParamString(int nPosition, const wxString &strValue)
Set the parameter at the 1-based position to a wxString value.
virtual int GetParameterCount()
int FindStatementAndAdjustPositionIndex(int *pPosition)
void FreeAllocatedResultSets()
wxTdsPreparedStatement(TDSSOCKET *pDatabase, TDSDYNAMIC *pStatement, const wxString &strQuery)
static wxTdsDatabase * LookupTdsLayer(const TDSCONTEXT *pContext)
void SetErrorInformationFromDatabaseLayer()
TDSDYNAMIC * m_pStatement
virtual wxDatabaseResultSet * RunQueryWithResults()
Run an insert, update, or delete query on the database.
virtual void SetParamBool(int nPosition, bool bValue)
Set the parameter at the 1-based position to a boolean value.
void ThrowDatabaseException()
const wxString & GetErrorMessage()
virtual ~wxTdsPreparedStatement()
#define wxDATABASE_ALLOCATION_ERROR
virtual void SetParamNull(int nPosition)
Set the parameter at the 1-based position to a NULL value.
void SetErrorMessage(const wxString &strErrorMessage)
void LogResultSetForCleanup(wxDatabaseResultSet *pResultSet)
Add result set object pointer to the list for "garbage collection".
void SetEncoding(wxFontEncoding encoding)
void AllocateParameter(int nPosition)
wxString m_strOriginalQuery
virtual size_t GetEncodedStreamLength(const wxString &inputString)
void CloseResultSets()
Close all result set objects that have been generated but not yet closed.
void SetErrorCode(int nErrorCode)
const wxCSConv * GetEncoding()
virtual void SetParamInt(int nPosition, int nValue)
Set the parameter at the 1-based position to an int value.
virtual int RunQuery()
Run an insert, update, or delete query on the database.
virtual const wxCharBuffer ConvertToUnicodeStream(const wxString &inputString)
virtual void SetParamDouble(int nPosition, double dblValue)
Set the parameter at the 1-based position to a double value.