3 #if wxUSE_DATABASE_POSTGRESQL 5 #include "wx/tokenzr.h" 7 #include "wx/arrimpl.cpp" 8 WX_DEFINE_OBJARRAY(ArrayOfPostgresPreparedStatementWrappers);
13 m_pInterface = pInterface;
19 m_pInterface = pInterface;
20 AddStatement(pDatabase, strSQL, strStatementName);
47 wxArrayString::iterator start = Queries.begin();
48 wxArrayString::iterator stop = Queries.end();
52 wxCSConv conv((
const wxChar*)strEncoding);
60 PGresult* pResult = pInterface->
GetPQprepare()(pDatabase, nameBuffer, sqlBuffer, 0, NULL);
127 m_Statements[nIndex].SetParam(nPosition, pData, nDataLength);
208 wxString strReturn = _(
"databaselayer_");
209 for (
int i=0; i<10; i++)
211 strReturn << (int) (10.0*rand()/(RAND_MAX+1.0));
226 int nParametersInThisStatement =
m_Statements[i].GetParameterCount();
228 if (*pPosition > nParametersInThisStatement)
230 *pPosition -= nParametersInThisStatement;
243 int nParameterIndex = 1;
244 wxString strReturn = wxEmptyString;
253 bool bInStringLiteral =
false;
254 size_t len = strOriginalSQL.length();
255 for (
size_t i = 0; i < len; i++)
257 wxChar character = strOriginalSQL[i];
258 if (
'\'' == character)
261 bInStringLiteral = !bInStringLiteral;
263 strReturn += character;
267 if (
'?' == character)
269 if (bInStringLiteral)
272 strReturn += character;
277 strReturn += wxString::Format(_(
"$%d"), nParameterIndex);
284 strReturn += character;
292 #endif//wxUSE_DATABASE_POSTGRESQL PQprepareType GetPQprepare()
wxPostgresPreparedStatement(wxDynamicPostgresInterface *pInterface)
virtual void SetParamBool(int nPosition, bool bValue)
Set the parameter at the 1-based position to a boolean value.
static wxPostgresPreparedStatement * CreateStatement(wxDynamicPostgresInterface *pInterface, PGconn *pDatabase, const wxString &strSQL)
PQclientEncodingType GetPQclientEncoding()
virtual int GetParameterCount()
wxDatabaseResultSet * RunQueryWithResults()
ArrayOfPostgresPreparedStatementWrappers m_Statements
void AddStatement(PGconn *pDatabase, const wxString &strSQL, const wxString &strStatementName)
static int TranslateErrorCode(int nCode)
PQencodingToCharType GetPQencodingToChar()
void ThrowDatabaseException()
const wxString & GetErrorMessage()
static wxString TranslateSQL(const wxString &strOriginalSQL)
virtual wxDatabaseResultSet * RunQueryWithResults()
Run an insert, update, or delete query on the database.
void SetErrorMessage(const wxString &strErrorMessage)
void LogResultSetForCleanup(wxDatabaseResultSet *pResultSet)
Add result set object pointer to the list for "garbage collection".
wxArrayString ParseQueries(const wxString &strQuery)
PQresultErrorMessageType GetPQresultErrorMessage()
void SetEncoding(wxFontEncoding encoding)
#define wxDATABASE_QUERY_RESULT_ERROR
virtual void Close()
Close the result set (call wxDatabase::ClosePreparedStatement() instead on the statement)
virtual void SetParamString(int nPosition, const wxString &strValue)
Set the parameter at the 1-based position to a wxString value.
virtual void SetParamDouble(int nPosition, double dblValue)
Set the parameter at the 1-based position to a double value.
virtual ~wxPostgresPreparedStatement()
static wxString GenerateRandomStatementName()
wxDynamicPostgresInterface * m_pInterface
void CloseResultSets()
Close all result set objects that have been generated but not yet closed.
void SetErrorCode(int nErrorCode)
int FindStatementAndAdjustPositionIndex(int *pPosition)
virtual void SetParamDate(int nPosition, const wxDateTime &dateValue)
Set the parameter at the 1-based position to a wxDateTime value.
virtual wxString ConvertFromUnicodeStream(const char *inputBuffer)
PQresultStatusType GetPQresultStatus()
const wxCSConv * GetEncoding()
virtual int RunQuery()
Run an insert, update, or delete query on the database.
virtual void SetParamNull(int nPosition)
Set the parameter at the 1-based position to a NULL value.
virtual void SetParamBlob(int nPosition, const void *pData, long nDataLength)
Set the parameter at the 1-based position to a Blob value.
virtual const wxCharBuffer ConvertToUnicodeStream(const wxString &inputString)
virtual void SetParamInt(int nPosition, int nValue)
Set the parameter at the 1-based position to an int value.