1
2 <?php
3 /* This script is designed to be called from a HTML form.
4 * It expects $user, $password, $table, $where, and $commitsize
5 * to be passed in from the form. The script then deletes
6 * the selected rows using the ROWID and commits after each
7 * set of $commitsize rows. (Use with care, there is no rollback)
8 */
9 $conn = OCILogon($user, $password);
10 $stmt = OCIParse($conn,"select rowid from $table $where");
11 $rowid = OCINewDescriptor($conn,OCI_D_ROWID);
12 OCIDefineByName($stmt,"ROWID",&$rowid);
13 OCIExecute($stmt);
14 while ( OCIFetch($stmt) ) {
15 $nrows = OCIRowCount($stmt);
16 $delete = OCIParse($conn,"delete from $table where ROWID = :rid");
17 OCIBindByName($delete,":rid",&$rowid,-1,OCI_B_ROWID);
18 OCIExecute($delete);
19 print "$nrows\n";
20 if ( ($nrows % $commitsize) == 0 ) {
21 OCICommit($conn);
22 }
23 }
24 $nrows = OCIRowCount($stmt);
25 print "$nrows deleted...\n";
26 OCIFreeStatement($stmt);
27 OCILogoff($conn);
28 ?>
29 |