问题描述:

I am upgrading our database layer from OCI for Oracle 7 to OCCI for Oracle 12c. In OCI (7) it was possible to bind a parameter by number, such that in a statement SELECT * FROM TestTable WHERE name = :2 and number = :1 you could bind a value to :1 and a value to :2 no matter the position of :1and :2in the statement.

The statements generated by the higher layers of our old code are often of the form SELECT * FROM TestTable WHERE name = :2 and number = :1, and the values given later to be bound to the parameters are provided in a list in numerical order by the number of the parameter rather than by the position of the parameter.

In OCI 12c it is possible to bind parameters by name as well as by position (but apparently no longer by number), but in OCCI (12c) it seems to only be possible to bind by position. This obviously poses a problem for us, as we only know the name/number of the parameter the value should be bound to.

So, my question is: Is there any way to bind by name or number in OCCI, other than to parse the SQL-statement and map names to positions? Something that makes use of the OCI possibility of binding by name?

相关阅读:
Top