RE: [PHP-WIN] Problem with Oracle
| From: | Asendorf, John | Date: | Wed, 31 Jan 2001 13:38:29 +0000 |
| Subject: | RE: [PHP-WIN] Problem with Oracle | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-5282@lists.php.net to get a copy of this message | ||
Since the list was down yesterday, I figured it out before I got some help
(Thanks Jean-Christophe). I did it a little differently and thought I'd
post it here.
$sql_getID = "SELECT max(CUSTID_NUM) from cfull2.tbl_dl_customers";
$stmt_getID = OCIParse ( $connection , $sql_getID );
OCIExecute ( $stmt_getID );
OCIFetch ( $stmt_getID );
$Max_ID = OCIResult($stmt_getID,1);
OCIFreeStatement ( $stmt_getID );
$Max_ID++;
I was able to echo the result but was unable to put it in to a variable
until I did the above.
---------------------
John Asendorf - jasendorf@lcounty.com
Web Applications Developer
http://www.lcounty.com - NEW FEATURES ADDED DAILY!
Licking County, Ohio, USA
740-349-3631
The benefit to the government of replacing all $1 Federal Reserve notes with
$1 coins would be $522.2 million per year, according to estimates of the
General Accouting Office released on April 7, 2000.
> -----Original Message-----
> From: Jean-Christophe Le Brun [mailto:jean-christophe.lebrun@meteo.fr]
> Sent: Wednesday, January 31, 2001 2:19 AM
> To: Asendorf, John; php-windows@lists.php.net
> Subject: Re: [PHP-WIN] Problem with Oracle
>
>
> Hi !
>
> > I'm trying to run some SQL in Oracle that returns a single value...
> >
> > $sql_getID = "SELECT max(CUSTID_NUM) from cfull2.tbl_dl_customers";
> >
> > how the hell do I get that number into a variable?
> >
> > I've tried a dozen different things, but the documentation
> is so sparse
> and
> > it's all about getting rows of data...
>
> Do this :
>
> $Requete = "SELECT max(CUSTID_NUM) MAX_ID from
> cfull2.tbl_dl_customers";
> OCIDefineByName($Requete, "MAX_ID", &$Max_Id);
> OCIExecute($Requete, OCI_DEFAULT);
> while (OCIFetch($Requete))
> {
> echo $Max_Id;
> }
>
> the While is not necessary here cause your query send only one row...
>
> if (OCIFetch($Requete))
> {
> echo Max_Id;
> }
>
> is better !
>
> JCLB Soft
> Jean-Christophe Le Brun
> jean-christophe.lebrun@meteo.fr
> http://www.multimania.com/jclb
>