ODBC PHP / Oracle - UPDATE, INSERT, DELETE

3

I'm in a project using PHP and Oracle. the connection is OK, with this code I can execute all the selects I normally need, which I can not execute are INSERTS , UPDATES and DELETE .

Could anyone tell me why?

<?php
require_once('connection.php');
if($conn)
{
   $Query = "UPDATE PQAQ SET CAMINHO_ARQUIVO = 'PDF' WHERE CODIGO_PROCESSO = 18 AND CAMINHO_ARQUIVO = 'TESTE.PHP'";
   odbc_exec($conn, $Query);
}
?>
    
asked by anonymous 20.12.2016 / 17:19

1 answer

2

Some banks work on two-tier transactions by default. If change (insert / update / delete) is executed it is not put into practice at the time, it is pending until the commit.

There are two ways to resolve this problem. The first is to manually commit the odbc_commit () function.

$Query = "UPDATE PQAQ SET CAMINHO_ARQUIVO = 'PDF' 
          WHERE CODIGO_PROCESSO = 18 AND CAMINHO_ARQUIVO = 'TESTE.PHP'";
odbc_exec($conn, $Query);

if(!odbc_commit($conn)){
    echo 'erro: '. odbc_errormsg($conn);
}

The second is to let odbc work in autocommit by default, the odbc_autocommit () function. does this leaves your call right after the connection is created.

odbc_autocommit($conn, true);
    
20.12.2016 / 17:24