0

I have the following code...

$interactionid = '123';
$interactioncode = "ECWL";
$oldDOL = $_GET['oldDOL'];

$newDOL = $_GET['newDOL'];


    include("ORCLconfig.php");
    $addWSclaim = oci_parse($conn, "UPDATE claims SET DATE_OF_LOSS='$newDOL' WHERE NUMBER='32122'");
                  oci_execute($addWSclaim, OCI_COMMIT_ON_SUCCESS);


    $addtointeractionMAKE = oci_parse($conn, "INSERT INTO interaction_items VALUES (null, '$interactionid', '$interactioncode', '$oldDOL', '$newDOL', localtimestamp)");
                            oci_execute($addtointeractionMAKE, OCI_COMMIT_ON_SUCCESS);

oldDOL and newDOL are dates which arrive in the format DD-MMM-YY which is inline with the DATE_OF_LOSS column in the claims table.

However only the second statement seems to be working as there is no change on the claims table nor are there any errors shown.

I'm using an Oracle database and if I do the update statement in the SQL console it works fine.

Knowing me it will be something remarkably simple which i've somehow overlooked but any help would be appreciated :)

12
  • 1
    1) SQL Injection 2) Your INSERT syntax is wrong (unless this is Oracle voodoo that you don't have to specify field names after the table) Commented Dec 7, 2012 at 11:47
  • firstly, I suggest you use oci_bind(_by_name) for your varialbes in the queries/inserts. Its clearer and safer than instring variables. The one oci_execute that is not working gives you a true or false back? if it is false what is in oci_error()? Commented Dec 7, 2012 at 11:48
  • @jampez77 What is value returned by first oci_execute? If it is false then check what is returned by oci_error. Commented Dec 7, 2012 at 11:52
  • @Leigh yes it is Oracle voodoo! Commented Dec 7, 2012 at 11:55
  • @onlineapplab.com there is no value returned bby the first oci_execute although i am not that familiar with oci_error as i am new to using oracle..........this is the code im trying to use to display any errors if (!$addWSclaim) { $e = oci_error($conn); // For oci_parse errors pass the connection handle trigger_error(htmlentities($e['message']), E_USER_ERROR); } but its not returning anything Commented Dec 7, 2012 at 11:56

1 Answer 1

1

Try

 $addWSclaim = oci_parse($conn, "UPDATE claims SET DATE_OF_LOSS='$newDOL' WHERE NUMBER='32122'");

 if ($addWSclaim) {
   if (oci_execute($addWSclaim, OCI_COMMIT_ON_SUCCESS)) {
      if (oci_num_rows($addWSclaim) === 0) {
        /* No rows affected */
      }
   } else {

      /*Handle error through oci_error*/
   }
 } else {
   /* Handle parse error */
 }

oci_execute returns TRUE on success or FALSE on failure.

Sign up to request clarification or add additional context in comments.

6 Comments

still nothing im afraid :/
@jampez77 You can check number of affected rows
@jampez77 Do you have any statements executed before this code? According to docs "A transaction begins when the first SQL statement that changes data is executed with oci_execute() using the OCI_NO_AUTO_COMMIT flag. Further data changes made by other statements become part of the same transaction. Data changes made in a transaction are temporary until the transaction is committed or rolled back. Other users of the database will not see the changes until they are committed."
Affected rows comes back with 0 every time and no these are the only two statements in my script
@jampez77 In such case I would check your WHERE clause in the UPDATE statement. Try making a SELECT to see if anything will be returned.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.