benphp Posted August 15, 2012 Share Posted August 15, 2012 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? Quote Link to comment https://forums.phpfreaks.com/topic/267125-warning-oci_free_statement-3-is-not-a-valid-oci8-statement-resource/ Share on other sites More sharing options...
jazzman1 Posted August 15, 2012 Share Posted August 15, 2012 What is your database ? Quote Link to comment https://forums.phpfreaks.com/topic/267125-warning-oci_free_statement-3-is-not-a-valid-oci8-statement-resource/#findComment-1369621 Share on other sites More sharing options...
benphp Posted August 15, 2012 Author Share Posted August 15, 2012 Oracle. According to http://php.net/manual/en/function.oci-parse.php, I could instead just set $stmt = null; but I still don't know why I'm getting that error. Quote Link to comment https://forums.phpfreaks.com/topic/267125-warning-oci_free_statement-3-is-not-a-valid-oci8-statement-resource/#findComment-1369622 Share on other sites More sharing options...
scootstah Posted August 15, 2012 Share Posted August 15, 2012 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. Quote Link to comment https://forums.phpfreaks.com/topic/267125-warning-oci_free_statement-3-is-not-a-valid-oci8-statement-resource/#findComment-1369623 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.