Jump to content

Warning: oci_free_statement(): 3 is not a valid oci8 statement resource


benphp

Recommended Posts

Howdy.

 

Can someone tell me - does the oci_free_statement error out when there are no records?

 

Otherwise, can you tell me why I'd get the "oci_free_statement(): 3 is not a valid" error with this?

 

$connSelect = oci_connect($usr, $pwd, $db);

$sqlSelect =  "SELECT  a.myfield  FROM mytable ";

$stmt=oci_parse($connSelect,$sqlSelect);
oci_execute($stmt, OCI_DEFAULT);

while (($row = oci_fetch_array($stmt, OCI_BOTH))) {
	$myfield =  $row[0];
}

$sqlSelect = null;
$row = null;
oci_free_statement($stmt);
oci_close($connSelect);

 

There are no errors in the SQL, and there are zero records returned. Can't I still free the statement if there are no records? or do I need to add an if statement to free it only when records > 0?

 

SELECT  a.myfield  FROM mytable

 

I'm not super familiar with Oracle, but this doesn't look right. I would think that since there's no alias defined, that query should error.

 

Also, if there is no rows returned, I'm kind of surprised that while (($row = oci_fetch_array($stmt, OCI_BOTH))) { isn't throwing an error too.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.