diff --git a/src/backends/oracle/statement.cpp b/src/backends/oracle/statement.cpp index b0a4815cf..086a16743 100644 --- a/src/backends/oracle/statement.cpp +++ b/src/backends/oracle/statement.cpp @@ -164,21 +164,34 @@ std::string oracle_statement_backend::rewrite_for_procedure_call( int oracle_statement_backend::prepare_for_describe() { - sword res = OCIStmtExecute(session_.svchp_, stmtp_, session_.errhp_, - 1, 0, 0, 0, OCI_DESCRIBE_ONLY); + ub2 statementType = 0; + sword res = OCIAttrGet(static_cast(stmtp_), + static_cast(OCI_HTYPE_STMT), static_cast(&statementType), + 0, static_cast(OCI_ATTR_STMT_TYPE), session_.errhp_); if (res != OCI_SUCCESS) { throw_oracle_soci_error(res, session_.errhp_); } - int cols; - res = OCIAttrGet(static_cast(stmtp_), - static_cast(OCI_HTYPE_STMT), static_cast(&cols), - 0, static_cast(OCI_ATTR_PARAM_COUNT), session_.errhp_); - - if (res != OCI_SUCCESS) + int cols = 0; + if (statementType == OCI_STMT_SELECT) { - throw_oracle_soci_error(res, session_.errhp_); + res = OCIStmtExecute(session_.svchp_, stmtp_, session_.errhp_, + 1, 0, 0, 0, OCI_DESCRIBE_ONLY); + if (res != OCI_SUCCESS) + { + throw_oracle_soci_error(res, session_.errhp_); + } + + int cols; + res = OCIAttrGet(static_cast(stmtp_), + static_cast(OCI_HTYPE_STMT), static_cast(&cols), + 0, static_cast(OCI_ATTR_PARAM_COUNT), session_.errhp_); + + if (res != OCI_SUCCESS) + { + throw_oracle_soci_error(res, session_.errhp_); + } } return cols;