1
2 <?php
3 /* このスクリプトは HTML フォームからコールされる前提で作成
4 * されており、$user, $passwor, $table, $where, $commitsize
5 * がフォームから渡されることを前提にしています。
6 * このスクリプトは、ROWID を用いて選択された行を削除し、
7 * $commitsize 行毎にコミットします。
8 * (ロールバックがないので、注意して使用してください。)
9 */
10 $conn = OCILogon($user, $password);
11 $stmt = OCIParse($conn,"select rowid from $table $where");
12 $rowid = OCINewDescriptor($conn,OCI_D_ROWID);
13 OCIDefineByName($stmt,"ROWID",&$rowid);
14 OCIExecute($stmt);
15 while ( OCIFetch($stmt) ) {
16 $nrows = OCIRowCount($stmt);
17 $delete = OCIParse($conn,"delete from $table where ROWID = :rid");
18 OCIBindByName($delete,":rid",&$rowid,-1,OCI_B_ROWID);
19 OCIExecute($delete);
20 print "$nrows\n";
21 if ( ($nrows % $commitsize) == 0 ) {
22 OCICommit($conn);
23 }
24 }
25 $nrows = OCIRowCount($stmt);
26 print "$nrows deleted...\n";
27 OCIFreeStatement($stmt);
28 OCILogoff($conn);
29 ?>
30 |