void PgStatement::PrepareQuery(const ArrayRecord& raParameters) { wxASSERT_MSG(pgr == NULL, wxT("PgStatement::PrepareQuery() should only get called if pgr is NULL")); // Prepare parameter types wxString sParamTypes; if(raParameters.size() != 0) { sParamTypes = wxT(" ("); for(ArrayRecord::const_iterator it = raParameters.begin(); it != raParameters.end(); it++) { if(it != raParameters.begin()) sParamTypes += wxT(", "); // Translate wxVariant type names into Postgres type names wxString sType = it->GetType(); wxString sPgTypeName = Postgres::GetPgTypeFromVariantType(sType); sParamTypes += sPgTypeName; } sParamTypes += wxT(")"); } else sParamTypes = wxT(""); wxString sPrepareStatement = wxString::Format ( wxT("PREPARE %s%s AS %s"), sQueryHandle.c_str(), sParamTypes.c_str(), sQuery.c_str() ); PGresult * pgrPrepare = PQexec(pg->conn, sPrepareStatement.mbc_str()); ExecStatusType exs = PQresultStatus(pgrPrepare); if(exs != PGRES_COMMAND_OK) ThrowPgError(); if(pgrPrepare != NULL) { PQclear(pgrPrepare); pgr = NULL; } }