RETCODE SQL_API SQLExecDirect(HSTMT StatementHandle, SQLCHAR *StatementText, SQLINTEGER TextLength) { CSTR func = "SQLExecDirect"; RETCODE ret; StatementClass *stmt = (StatementClass *) StatementHandle; UWORD flag = 0; mylog("[%s]", func); ENTER_STMT_CS(stmt); SC_clear_error(stmt); if (PG_VERSION_GE(SC_get_conn(stmt), 7.4)) flag |= PODBC_WITH_HOLD; if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else { StartRollbackState(stmt); ret = PGAPI_ExecDirect(StatementHandle, StatementText, TextLength, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); } LEAVE_STMT_CS(stmt); return ret; }
RETCODE SQL_API SQLExecDirectW(HSTMT StatementHandle, SQLWCHAR *StatementText, SQLINTEGER TextLength) { CSTR func = "SQLExecDirectW"; RETCODE ret; char *stxt; SQLLEN slen; StatementClass *stmt = (StatementClass *) StatementHandle; UWORD flag = 0; mylog("[%s]", func); stxt = ucs2_to_utf8(StatementText, TextLength, &slen, FALSE); ENTER_STMT_CS(stmt); SC_clear_error(stmt); flag |= PODBC_WITH_HOLD; StartRollbackState(stmt); if (SC_opencheck(stmt, func)) ret = SQL_ERROR; else ret = PGAPI_ExecDirect(StatementHandle, (SQLCHAR *) stxt, (SQLINTEGER) slen, flag); ret = DiscardStatementSvp(stmt, ret, FALSE); LEAVE_STMT_CS(stmt); if (stxt) free(stxt); return ret; }
static char * CC_lookup_cs_old(ConnectionClass *self) { char *encstr = NULL; HSTMT hstmt; RETCODE result; result = PGAPI_AllocStmt(self, &hstmt); if (!SQL_SUCCEEDED(result)) return encstr; result = PGAPI_ExecDirect(hstmt, "Show Client_Encoding", SQL_NTS, 0); if (result == SQL_SUCCESS_WITH_INFO) { char sqlState[8], errormsg[128], enc[32]; if (PGAPI_Error(NULL, NULL, hstmt, sqlState, NULL, errormsg, sizeof(errormsg), NULL) == SQL_SUCCESS && sscanf(errormsg, "%*s %*s %*s %*s %*s %s", enc) > 0) encstr = strdup(enc); } PGAPI_FreeStmt(hstmt, SQL_DROP); return encstr; }