Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8878681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:46:18+00:00 2026-06-14T19:46:18+00:00

I need to know how to obtain the statement type of a prepared statement

  • 0

I need to know how to obtain the statement type of a prepared statement handle in OCI.

The dilemna is as follows. The fourth argument of OCIStmtExecute() – iters – cannot be 0 if the statement is not a SELECT, but it must be 0 if the statement is a SELECT (and defines cannot be done ahead of time). From the OCI 10g documentation for OCIStmtExecute:

For non-SELECT statements, the number of times this statement is
executed is equal to iters – rowoff.

For SELECT statements, if iters is nonzero, then defines must have
been done for the statement handle. The execution fetches iters rows
into these predefined buffers and prefetches more rows depending upon
the prefetch row count. If you do not know how many rows the SELECT
statement will retrieve, set iters to zero.

This function returns an error if iters=0 for non-SELECT statements.

For a statement such as SELECT * ..., it is impossible to know what the columns even are before obtaining the describe information from the statement handle, which is only available after OCIStmtExecute() is called. (So, it’s not possible to do defines on the statement handle ahead of time.) Therefore, I must pass 0 for iters if the (unknown) statement type is SELECT. But if the (unknown) statement type is not SELECT, OCI returns an error if iters is 0 (just as the documentation says).

The documented way to obtain the type of statement (SELECT or not) is by querying an attribute of the statement handle, as follows:

ub2 statementType = 0;
OCIAttrGet(mystmt, OCI_HTYPE_STMT, (dvoid*)(&statementType), NULL, OCI_ATTR_SQLFNCODE, myerrhp);

Unfortunately, this function always returns 0 for statementType until after OCIStmtExecute() is called.

I am in a catch-22 situation. I must call OCIAttrGet() before I call OCIStmtExecute() to obtain the type of statement in order to set iters properly. However, I must call OCIStmtExecute() before OCIAttrGet() will succeed.

I have tried calling OCIStmtExecute() twice, the first time passing OCI_DESCRIBE_ONLY for the final parameter (mode). Unfortunately, OCIStmtExecute() still gives the error related to iters in this case.

(Please note: the statement handle mystmt has been properly prepared ahead of time, successfully, with a call to OCIStmtPrepare2(), and the error handle myerrhp has also been properly allocated.)

What do I do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T19:46:19+00:00Added an answer on June 14, 2026 at 7:46 pm

    Use the OCI_ATTR_STMT_TYPE instead: It is available right after OCIStmtPrepare and can be used to crudely determine the type of statement (ie. also if this is a “select” statement).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to know if it is possible to obtain the current execution node?
Simply enough, I need to know how to obtain the current URL that the
Need to know this so that i could send DTMF and that is going
Need to know which event triggered after text selection done in Apple iPad. It
I need to know how to change background of expanded list item when it
I need to know how to exclude files/folders from php generated zip. Here is
I need to know on a continuous basis when my UIScrollView is scrolling or
I need to know a couple of things, concerning IRC servers that I couldnt
I need to know how many instances of my process are running on a
I need to know which iOS device is currently running app (saying more exactly

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.