<?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($update,":sal",&$sal,32); $sal = 10000; while (list($empno,$ename) = each($data)) { 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); ?>
|