<?php /* Exemple ociBindByPos par thies@thieso.net (980221) Insère 3 lignes dans emp, et utilise ROWID pour mettre à jour les lignes, juste après l'insertion. */
$conn = OCILogon("scott","tiger");
$stmt = OCIParse($conn,"insert into emp (empno, ename) ". "values (:empno,:ename) ". "returning ROWID into :rid");
$data = array(1111 => "Larry", 2222 => "Bill", 3333 => "Jim");
$rowid = OCINewDescriptor($conn,OCI_D_ROWID);
OCIBindByName($stmt,":empno",&$empno,32); OCIBindByName($stmt,":ename",&$ename,32); OCIBindByName($stmt,":rid",&$rowid,-1,OCI_B_ROWID);
$update = OCIParse($conn,"update emp set sal = :sal where ROWID = :rid"); OCIBindByName($update,":rid",&$rowid,-1,OCI_B_ROWID); OCIBindByName($
)) { OCIExecute($stmt); OCIExecute($update); }
$rowid->free();
OCIFreeStatement($update); OCIFreeStatement($stmt);
$stmt = OCIParse($conn,"select * from emp where empno in (1111,2222,3333)"); OCIExecute($stmt); while (OCIFetchInto($stmt,&$arr,OCI_ASSOC)) { var_dump($arr); } OCIFreeStatement($stmt);
/* Effacement des lignes inutiles dans la table emp */ $stmt = OCIParse($conn,"delete from emp where empno in (1111,2222,3333)"); OCIExecute($stmt); OCIFreeStatement($stmt);
OCILogoff($conn); ?>
|