Re: OCIDefineByName/OCIBindByName help?

From: Date: Mon, 13 Aug 2001 23:33:58 +0000
Subject: Re: OCIDefineByName/OCIBindByName help?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-11317@lists.php.net to get a copy of this message
Quoting Barry Prentiss <thebear@antispam.stanford.edu>: > Hi, > Can anyone help me to understand the OCIBindByName/OCIDefineByName > functionality when used with the Oracle 'returning' clause? These two > functions are seriously under-documented at PHP.net. > I need the sequence-generated ID created during an insert for further > manipulation. > I tried sequence-name.currval but got an error. > Here's some code that doesn't work: > > $sql = "insert into mdfaq values (null,'$Question','$Answer') > returning > ID into :ID"; > $stmt = ociParse($conn,$sql); > OCIBindByName($stmt,":ID",&$faq_ID,-1); You don't need to pass by reference and you should be able to ommit the length parameter. You should probably bind $Question and $Answer as well. That way your queries will be more efficient and you dont have to worry about escaping quotes. Also your SQL should be "INSERT INTO mdfaq VALUES (sequence.nextval, '$Question', '$Answer') returning ID into :id" ID should be the column name of your primary key column. ocidefinebyname is useful for pulling columns out of Oracle so you don't need to make calls to ociresult() all the time. I actually don't see much benefit over using fetchstatement() Cheers, Graeme Cheers, Graeme

« previous php.db (#11317) next »