Rollback from oracle php with multiple tables

I am trying to insert a table with some fields

$ecode = 1000; 
$location = 'B'; 
$file_id = 1; 
$accessed_on = '30-NOV-14';

my code

$conn = oci_connect('username', 'passwd', '//server/db');    
if (!$conn) {    
    $e = oci_error();    
    trigger_error(htmlentities($e['message'], ENT_QUOTES), E_USER_ERROR);    
} else {     
}    

$query_Test = "
    insert into example(ECODE,LOCATION,FILE_ID,ACCESSED_ON) 
    values($ecode,'$location',$file_id,'$accessed_on')";   

$parse_Test = oci_parse($conn, $query_Test);    
if(oci_execute($parse_Test)) {
    echo 'Success';        
    $query_Test1 = "
        update example     
        set ACCESSED_ON=03-nov-14,    
        where LOCATION='B'";    

    $parse_Test1 = oci_parse($conn, $query_Test1);    

    if(oci_execute($parse_Test1)){      
        oci_rollback($conn);    
    }    
}

but which does not rollback query_Test when query_Test1 fails. How to do it. someone help.thanks in advance

+4
source share
1 answer

When you write oci_execute ($ test, OCI_DEFUALT); He will work.

because if you have not defined any second parameter, its AUTO COMMIT by defualt Having defined this parameter, its automatic fixing (oci_defualt) or (OCI_NO_AUTO_COMMIT)

And the reason why it does not roll back You cannot roll back if you made (saved) your state.

0
source

Source: https://habr.com/ru/post/1568095/


All Articles