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?

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.