?php
/* このスクリプトは HTML フォームからコールされる前提で作成
* されており、$user, $passwor, $table, $where, $commitsize
* がフォームから渡されることを前提にしています。
* このスクリプトは、ROWID を用いて選択された行を削除し、
* $commitsize 行毎にコミットします。
* (ロールバックがないので、注意して使用してください。)
*/
$conn = OCILogon($user, $password);
$stmt = OCIParse($conn,"select rowid from $table $where");
$rowid = OCINewDescriptor($conn,OCI_D_ROWID);
OCIDefineByName($stmt,"ROWID",$rowid);
OCIExecute($stmt);
while ( OCIFetch($stmt) ) {
$nrows = OCIRowCount($stmt);
$delete = OCIParse($conn,"delete from $table where ROWID =
:rid");
OCIBindByName($delete,":rid", amp;$rowid,-1,OCI_B_ROWID);
OCIExecute($delete);
print "$nrows\n";
if ( ($nrows % $commitsize) == 0 ) {
OCICommit($conn);
}
}
$nrows = OCIRowCount($stmt);
print "$nrows deleted...\n";
OCIFreeStatement($stmt);
OCILogoff($conn);
?
|