Re: Oracle connection, tired eyes
| From: | Andy Hoffman | Date: | Fri, 20 Oct 2000 14:24:15 +0000 |
| Subject: | Re: Oracle connection, tired eyes | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-3413@lists.php.net to get a copy of this message | ||
"Asendorf, John" wrote:
> $sql = "select page from cfull2.resolution where page like 400";
> $stmt = OCIParse($conn,$sql);
> $ora_result = OCIExecute($stmt);
>
> while (OCIFetch($ora_result)) { //line 42
> $page = OCIresult ($ora_result, "page");
> echo "$page <br />";
> }
>
> Anyone?
OK, you have to understand that Oracle callse are NOT completely analagous to
ODBC or mySQL... in other dbs, when you execute the statement, the return value
is what you'd term a "recordset"... however, OCI doesn't work that way...
When you call ociparse(), the returned result of that call is what would be
termed your statement handle, and it is this statement handle which will
contain the results of the execution, NOT the result of the function call
itself :)
Thus to accomplish what you want, try this...
<?php
$sql = "select page from cfull2.resolution where page like 400";
$stmt = OCIParse($conn,$sql);
// $stmt now contains a statement handle which is ready to execute (prepped)
OCIExecute($stmt, OCI_DEFAULT);
// $stmt now contains a statement handle which POINTS to a recordset
// OCI_DEFAULT denotes default cursor type
while (OCIFetchInto($stmt, $row, OCI_ASSOC)) {
// FetchInto fetches directly into a record array and
// OCI_ASSOC makes that array associative by the field names
$page = $row[page];
echo "$page <br />";
}
?>
--
Andy Hoffman
Web Developer
Bristol-Myers Squibb
email: andy.hoffman@bms.com