Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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) <code>OCI_ATTR_HANDLE_POSITION</code> using <code>OCIAttrGet()</code> on the bind handle:</p> <pre><code>ub4 bpos = 0; OCIBind *bindp; OCIAttrGet(bindp, OCI_HTYPE_BIND, &amp;bpos, 0, OCI_ATTR_HANDLE_POSITION, errhp); </code></pre> <p>Unfortunately, that seems to work for bind handles that you bound positionally, but return 0 for any you bound by name.</p> <p>So it seems like you would have to use the <a href="http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14250/oci15rel003.htm#sthref2656" rel="nofollow"><code>OCIStmtGetBindInfo()</code></a> 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):</p> <pre><code>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, &amp;found, bvns, bvnls, invs, invls, dupls, bhnds); for (unsigned int col = 0; col &lt; found; col++) { printf("%p is bound to name: %s", bhnds[col], bvns[col]); } </code></pre> <p>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: </p> <pre><code>insert into foo (bar, baz) values (:bar, :bar) </code></pre> <p>Will fill your <code>found</code> output variable with 2 (and the arrays with info for 2 binds), whereas:</p> <pre><code>begin insert into foo (bar, baz) values (:bar, :bar); end; </code></pre> <p>Will fill your <code>found</code> output variable with 1 (and the arrays with info for 1 bind). Nonetheless, a single call to <code>OCIBindByName()</code> will bind both in either case.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload