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 5993063
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:37:18+00:00 2026-05-22T23:37:18+00:00

When using OCIStmtPrepare() and OCIBindByName() , is there a way to do the bind

  • 0

When using OCIStmtPrepare() and OCIBindByName(), is there a way to do the bind by name, then get the position of that bind as an int? OCIStmtGetBindInfo() doesn’t seem to do it. Thanks!

  • 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-05-22T23:37:19+00:00Added an answer on May 22, 2026 at 11:37 pm

    There doesn’t appear to be an easy way to do it. I tried using the undocumented (as in I couldn’t find it in the help docs but it is in the oci.h header) OCI_ATTR_HANDLE_POSITION using OCIAttrGet() on the bind handle:

    ub4 bpos = 0;
    OCIBind *bindp;
    OCIAttrGet(bindp, OCI_HTYPE_BIND, &bpos, 0, OCI_ATTR_HANDLE_POSITION, errhp);
    

    Unfortunately, that seems to work for bind handles that you bound positionally, but return 0 for any you bound by name.

    So it seems like you would have to use the OCIStmtGetBindInfo() call to have it fill an array of bind variable names then iterate through it to find the position(s) for each named bind, either by comparing the bind name to the values in the bind variable names array (the values of which will be uppercased):

    sb4 found = 0;
    text* bvns[100];
    ub1 bvnls[100];
    text* invs[100];
    ub1 invls[100];
    ub1 dupls[100];
    OCIBind* bhnds[100];
    OCIStmtGetBindInfo(stmthp, errhp, (ub4)100, (ub4)1, &found, bvns, bvnls, invs, invls, dupls, bhnds);
    for (unsigned int col = 0; col < found; col++)
    {
        printf("%p is bound to name: %s", bhnds[col], bvns[col]);
    }
    

    One interesting thing to note about multiple placeholders in a statement is that it behaves differently if your statement is an anonymous block or not. That is:

    insert into foo (bar, baz) values (:bar, :bar)
    

    Will fill your found output variable with 2 (and the arrays with info for 2 binds), whereas:

    begin insert into foo (bar, baz) values (:bar, :bar); end;
    

    Will fill your found output variable with 1 (and the arrays with info for 1 bind).
    Nonetheless, a single call to OCIBindByName() will bind both in either case.

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

Sidebar

Related Questions

Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# and System.Data.SqlClient, is there a way to retrieve a list of parameters
Using jQuery, how do I get the value from a textbox and then load
Using Java Reflection, is it possible to get the name of a local variable?
Using online interfaces to a version control system is a nice way to have
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using C#, I need a class called User that has a username, password, active
Using android 2.3.3, I have a background Service which has a socket connection. There's
Using the HTML5 File API I can get the Binary String representation of a
Using NSDateComponents I know how to get the day component, but this gives me

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.