Getting binding position from binding name in OCI

When using OCIStmtPrepare()and is OCIBindByName()there a way to make a binding by name, and then get the position of this binding as int? OCIStmtGetBindInfo()doesn't seem to do this. Thank!

+3
source share
1 answer

This doesn't seem to be an easy way to do this. I tried using undocumented (since I could not find it in the help docs, but it is in the oci.h header) OCI_ATTR_HANDLE_POSITIONusing OCIAttrGet()in the binding descriptor:

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

Unfortunately, this is similar to working with binding descriptors that you have bound by position, but return 0 for any bound by name.

, OCIStmtGetBindInfo(), , () , ( ):

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]);
}

, , -, . :

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

output found 2 ( 2 ), :

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

output found 1 ( 1 ). , OCIBindByName() .

+2

All Articles