0

I've some PHP code writing to an Oracle database via OCI8 library. I have a insert statement which wouldn't execute programmatically- if I print out the statement and run it via SquirrelSQL it would insert the data successfully. I have delete and select statement elsewhere in the code which work perfectly. What can be the issue? And as I said if I print $om_query and run manually it inserts successfully. I'm not getting any other errors.

$om_query = "INSERT INTO DB.TABLE(R1,R2) VALUES(V1,V2)";
$s2 = oci_parse($conn, $om_query);
$qs = oci_execute($s2);
oci_commit ($conn); 

if(!$qs){
    $ma = oci_error();
    $failedqueries .= '<br /><br />MAINQ: ' . $om_query . '<br /><b>OCI_ERROR_MSG: </b>' . $ma['message'];
}

oci_error() doesn't append anything useful.

NJD
  • 1
  • 3
  • Maybe it *doesn't* fail? (wrt "failure check does NOT fire") –  Jun 30 '12 at 05:39
  • Doesn't generate ANY visible error and the error condition doesn't fire. I can see the DB on SquirrelSQL and I can see its not entered (I can see it got entered when I ran the manual query via both Squirrel and the data management part of my application). Deletes work too. – NJD Jun 30 '12 at 05:51
  • 5
    I think you need to check the error immediately, (before the commit). The commit would probably send another query (COMMIT) to the database, causing it to drop the last generated error message. – GordonM Jun 30 '12 at 06:02
  • You say oci_error() doesn't append anything useful. What unuseful things does it append? – Martijn Jul 02 '12 at 06:54
  • 2
    What do you think the `V1` and `V2` represent? They aren't literals; they can't be columns in the table, so what are they? And maybe the answer to your question is "There ain't no such thing as a perfect SQL statement". – Jonathan Leffler Jul 02 '12 at 06:55

1 Answers1

-2

Check that you don't have an open transaction on the affected table. PL may be attempting to delete the inserted record.

In Oracle, you must perform a COMMIT or ROLLBACK operation after modifying data (whether through an insert, update or delete).

Chris Forrence
  • 10,042
  • 11
  • 48
  • 64
  • 1
    Respondo con el fin de que a alguna persona en un futuro le sirva la solución, ya que yo tenia ese problema y tarde mucho en encontrar la solución. – Hellfenix Mar 18 '15 at 18:50
  • 2
    Welcome to the site. You cannot assume readers (and original poster of the question) understand Spanish. The site works in English. See [answer]. Please edit you answer to improve it by the translation. – mins Mar 18 '15 at 19:12