note 32948 added to function.ora-do
| From: | ecingala at caramail dot com | Date: | Wed, 11 Jun 2003 15:20:21 +0000 |
| Subject: | note 32948 added to function.ora-do | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-50193@lists.php.net to get a copy of this message | ||
/*
AIM OF THIS SCRIPT :
YOU SOMETIME HAVE TO ADD DATAS TO MANY TABLES.
THE PROBLEME IS THAT THE QUERIES ARE INTERDEPENDENT ( if one fails, you must rollback everything!).
SO INSTEAD OF HAVING PLENTY OF IF...ELSEIF...ELSE...,
HERE IS AN EXMPLE TO SHOW HOW TO ORGANIZE THE CODE.
WE OPEN MANY CURSORS...
THE CONNECTION IS 'COMMITED' ONLY IF EVERYTHING IS OK, OR ELSE IT IS
'ROLLBACKED'
*/
function reportError($code,$message ="")
{ print ("$message\n");
print ("Code Error: " . ora_errorcode($code) . "\n");
print ("Message Error: " . ora_error($code) . "\n");
}
/* ****************
TO ADAPT THIS TO YOUR ORACLE-DATABASE , CHANGE :
- THE ora_connection String using your username, your DataBase Name, and your Password.
- The queries : $query1, $query2, $query3 according to your Database.
**************** */
//connexion.php se connecte à la base.
$ora_conn = ora_logon("username@hostbasename","password");
$query1 = " INSERT into ... ";
$query2 = " INSERT into ... ";
$query3 = " UPDATE into ... ";
/** ***************
DON'T CHANGE ANYTHING BELOW
**************** */
/*
On se retrouve donc avec 3 requêtes a effectuer.
$query1, $query2, $query3.
Dans chaque cas, il faut effectuer 3 etapes :
- la creation du curseur,
- le 'parsage' de la requete avec le curseur,
- l'execution de la requete proprement dite.
On decide de creer les curseurs et d'effectuer le parsage en premier.
note : un ELSE IF est implicite car on sort du script par un Exit en cas d'echec a chaque etape
note : a ELSE IF is implicit because at each step, we get out of the script with an Exit
THE FOLLOWING POST IS THE CODE OF THIS */
----
Manual Page -- http://www.php.net/manual/en/function.ora-do.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32948
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32948&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32948&report=yes