}
-#if defined ( HAVE_IBMDB2 ) || defined ( HAVE_UNIXODBC )
-void ODBC_SQL_ERROR(SQLHANDLE henv, SQLHANDLE conn, SQLHANDLE stmt, char *func)
-#else
-void ODBC_SQL_ERROR(HENV henv, HDBC conn, HSTMT stmt, char *func)
-#endif
+void odbc_sql_error(ODBC_SQL_ERROR_PARAMS)
{
char state[6];
SDWORD error; /* Not used */
*/
}
-void php_odgbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
+void php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAMETERS, int mode)
{
odbc_result *result;
pval **pv_res, **pv_flag;
rc = SQLTransact(conn->henv, conn->hdbc, (UWORD)((type)?SQL_COMMIT:SQL_ROLLBACK));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTransact");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTransact");
RETURN_FALSE;
}
Handle binary column data */
PHP_FUNCTION(odbc_binmode)
{
- php_odgbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,0);
+ php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
}
/* }}} */
Handle LONG columns */
PHP_FUNCTION(odbc_longreadlen)
{
- php_odgbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU,1);
+ php_odbc_fetch_attribs(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
}
/* }}} */
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
if ((rc = SQLPrepare(result->stmt, query, SQL_NTS)) != SQL_SUCCESS) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, result->stmt, "SQLPrepare");
+ odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLPrepare");
SQLFreeStmt(result->stmt, SQL_DROP);
RETURN_FALSE;
}
rc = SQLFreeStmt(result->stmt, SQL_CLOSE);
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLFreeStmt");
+ odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLFreeStmt");
}
rc = SQLExecute(result->stmt);
}
} else {
if (rc != SQL_SUCCESS) {
- ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLExecute");
+ odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLExecute");
RETVAL_FALSE;
}
}
if (!strncmp(state,"S1015",5)) {
sprintf(cursorname,"php_curs_%d", (int)result->stmt);
if (SQLSetCursorName(result->stmt,cursorname,SQL_NTS) != SQL_SUCCESS) {
- ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc,
+ odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc,
result->stmt, "SQLSetCursorName");
RETVAL_FALSE;
} else {
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
*/
if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, SQL_CURSOR_DYNAMIC)
== SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, result->stmt, " SQLSetStmtOption");
+ odbc_sql_error(conn->henv, conn->hdbc, result->stmt, " SQLSetStmtOption");
SQLFreeStmt(result->stmt, SQL_DROP);
efree(result);
RETURN_FALSE;
/* XXX FIXME we should really check out SQLSTATE with SQLError
* in case rc is SQL_SUCCESS_WITH_INFO here.
*/
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, result->stmt, "SQLExecDirect");
+ odbc_sql_error(conn->henv, conn->hdbc, result->stmt, "SQLExecDirect");
SQLFreeStmt(result->stmt, SQL_DROP);
efree(result);
RETURN_FALSE;
buf, result->longreadlen + 1, &result->values[i].vallen);
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
+ odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(buf);
RETURN_FALSE;
}
field, fieldsize, &result->values[field_ind].vallen);
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
+ odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(field);
RETURN_FALSE;
}
field, fieldsize, &result->values[field_ind].vallen);
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
+ odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
efree(field);
RETURN_FALSE;
}
php_printf("<td>");
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
+ odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SQLGetData");
php_printf("</td></tr></table>");
efree(buf);
RETURN_FALSE;
if (cur_opt != SQL_CUR_DEFAULT) {
rc = SQLSetConnectOption((*conn)->hdbc, SQL_ODBC_CURSORS, cur_opt);
if (rc != SQL_SUCCESS) { /* && rc != SQL_SUCCESS_WITH_INFO ? */
- ODBC_SQL_ERROR((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLSetConnectOption");
+ odbc_sql_error((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLSetConnectOption");
SQLFreeConnect((*conn)->hdbc);
pefree(*conn, persistent);
return FALSE;
#endif
#endif
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- ODBC_SQL_ERROR((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLConnect");
+ odbc_sql_error((*conn)->henv, (*conn)->hdbc, SQL_NULL_HSTMT, "SQLConnect");
SQLFreeConnect((*conn)->hdbc);
pefree((*conn), persistent);
return FALSE;
((*pv_onoff)->value.lval) ?
SQL_AUTOCOMMIT_ON : SQL_AUTOCOMMIT_OFF);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Set autocommit");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Set autocommit");
RETURN_FALSE;
}
RETVAL_TRUE;
rc = SQLGetConnectOption(conn->hdbc, SQL_AUTOCOMMIT, (PTR)&status);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Get commit status");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "Get commit status");
RETURN_FALSE;
}
RETVAL_LONG((long)status);
}
rc = SQLSetConnectOption(conn->hdbc, (unsigned short)((*pv_opt)->value.lval), (*pv_val)->value.lval);
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SetConnectOption");
RETURN_FALSE;
}
break;
rc = SQLSetStmtOption(result->stmt, (unsigned short)((*pv_opt)->value.lval), ((*pv_val)->value.lval));
if (rc != SQL_SUCCESS && rc != SQL_SUCCESS_WITH_INFO) {
- ODBC_SQL_ERROR(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SetStmtOption");
+ odbc_sql_error(result->conn_ptr->henv, result->conn_ptr->hdbc, result->stmt, "SetStmtOption");
RETURN_FALSE;
}
break;
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
type, SAFE_SQL_NTS(type));
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTables");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTables");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
column, SAFE_SQL_NTS(column));
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumns");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumns");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
column, SAFE_SQL_NTS(column));
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumnPrivileges");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLColumnPrivileges");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
ftable, SAFE_SQL_NTS(ftable) );
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLForeignKeys");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLForeignKeys");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
rc = SQLGetTypeInfo(result->stmt, data_type );
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLGetTypeInfo");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLGetTypeInfo");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
table, SAFE_SQL_NTS(table) );
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLPrimaryKeys");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLPrimaryKeys");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
col, SAFE_SQL_NTS(col) );
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedureColumns");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedureColumns");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
proc, SAFE_SQL_NTS(proc) );
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedures");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLProcedures");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
nullable);
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLSpecialColumns");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLSpecialColumns");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
reserved);
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLStatistics");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLStatistics");
efree(result);
RETURN_FALSE;
}
}
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLAllocStmt");
efree(result);
RETURN_FALSE;
}
table, SAFE_SQL_NTS(table));
if (rc == SQL_ERROR) {
- ODBC_SQL_ERROR(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTablePrivileges");
+ odbc_sql_error(conn->henv, conn->hdbc, SQL_NULL_HSTMT, "SQLTablePrivileges");
efree(result);
RETURN_FALSE;
}