Skip to content

Commit

Permalink
Only prepare for describe if statement type is 'SELECT' for Oracle ba…
Browse files Browse the repository at this point in the history
…ckend
  • Loading branch information
iqbal-hasprime committed Jan 10, 2024
1 parent 65a7e4d commit d8673a1
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/backends/oracle/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<dvoid*>(stmtp_),
static_cast<ub4>(OCI_HTYPE_STMT), static_cast<dvoid*>(&statementType),
0, static_cast<ub4>(OCI_ATTR_STMT_TYPE), session_.errhp_);
if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}

int cols;
res = OCIAttrGet(static_cast<dvoid*>(stmtp_),
static_cast<ub4>(OCI_HTYPE_STMT), static_cast<dvoid*>(&cols),
0, static_cast<ub4>(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<dvoid*>(stmtp_),
static_cast<ub4>(OCI_HTYPE_STMT), static_cast<dvoid*>(&cols),
0, static_cast<ub4>(OCI_ATTR_PARAM_COUNT), session_.errhp_);

if (res != OCI_SUCCESS)
{
throw_oracle_soci_error(res, session_.errhp_);
}
}

return cols;
Expand Down

0 comments on commit d8673a1

Please sign in to comment.