Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Bind variables

Re: Bind variables

From: Mathias Waack <M.Waack_at_gmx.de>
Date: Tue, 28 Nov 2006 12:01:40 GMT
Message-ID: <EyVah.191$TO.5659@se2-cb104-9.zrh1.ch.colt.net>


silvia.fama wrote:

> Hi,
> I'd need a support to use bind variables.
>
> In my program I have a lot of tables, everyone with a different column
> number.
>
> I'm going to use bind variables; so every time I create an sql
> statement with a different number of bind variables (all the values to
> associate to the bind variables are loaded into an array);
> e.g.
> I could have
> "select * from tableA where col1 = :1, col2 = :2, col3 = :3"
> or
> "select * from tableA where col1 = :1, col2 = :2, col3 = :3, ..., coln
> =:n"
> n could be 70.
> So I should call OCIBindByPos 70 times (for cycle), before to call the
> OCIStmtExecute.
> Is there a way to use an OCI function to connect all the value in the
> array with the bind variables?

Sure. Just have a look at the OCI interfaces written for various scripting languages like perl or python. Its always the same procedure (with the usual small differences;):

  1. call OCIStmtPrepare
  2. call OCIStmtExecute with OCI_DESCRIBE_ONLY as last parameter
  3. use a loop like this: for (int i=1;;++i) 3a. use OCIParamGet to check if i is a valid column number, otherwise break out of the loop 3b. use OCIAttrGet to obtain size and type of column i 3c. bind this column
  4. execute the statement again

>
> I hope to be able to explain my problem.

Hope I've got it right.

Mathias Received on Tue Nov 28 2006 - 06:01:40 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US