On Thu, Apr 05, 2001 at 12:47:37PM -0400, Joe Brown wrote:
> Don't have a whole lot of practice with the OCIBindByName function, but I
> seem to be having success within a recursive select statement.
> 
> I'm not useing the & operator in my implementation.  Don't know if that's a
> good or a bad thing (yet), but it seems to be functioning properly.
> 
> The third parameter you have -1.  I think you want to set it to a legitimate
> max field length value.  -1 is used for LOBs, ROWID and FILENAME parameters,
> not run of the mill number and varchar2 fields.
> 
> perhaps:
> OCIBindByName($parsed,":id",$id,32);  //may work better?

    this is a working sample:

    <?php
 
        $data = array("larry","bill","steve");
 
        $db = OCILogon("scott","tiger");
        $stmt = OCIParse($db,"insert into names values (myid.nextval,:name) returning 
id into :id");
        OCIBindByName($stmt,":ID",$id,32);
        OCIBindByName($stmt,":NAME",$name,32);
 
        while (list(,$name) = each($data)) {
            OCIExecute($stmt);
            echo "$name got id:$id\n";
        }
    ?>

    re,
    tc
> 
> ""Paul Fernandez"" <[EMAIL PROTECTED]> wrote in message
> 9ai699$n70$[EMAIL PROTECTED]">news:9ai699$n70$[EMAIL PROTECTED]...
> > Hello,
> >
> > The goal here is to insert a single row, then get a numerical value "id"
> > (generated by the insert trigger) to use in another insert statement.
> >
> > I get, "ORA-01008: not all variables bound" when running this script:
> >
> > <?
> > $query = "insert into table (col1, col2) values ($val1,$val2) returning id
> > into :id";
> > $parsed = OCIParse($connection,$query);
> >
> > OCIBindByName($parsed,":id",&$id,-1);
> >
> > // execute first insert
> > $cursor = OCIExecute($parsed);
> >
> > // construct and execute 2nd insert
> > $query2="insert into table2(id,etc) values (:id, $etc)";
> > $parsed2 = OCIParse($connection,$query2);
> > $cursor2 = OCIExecute($parsed2);
> > ?>
> >
> > It seems so simple.  What am I doing wrong?
> >
> > Paul Fernandez
> >
> >
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > To contact the list administrators, e-mail: [EMAIL PROTECTED]
> >
> 
> 
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
> 

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to