PL/SQLランダム値の生成

[sql]
set serveroutput on
DECLARE

CURSOR ids is
select customer_id
from customer_mst;

customers ids%ROWTYPE;
rnd NUMBER(2);
BEGIN
open corp2_ids;
LOOP
FETCH ids INTO customers;
–50~95の整数ランダム値を返す
rnd := trunc(DBMS_RANDOM.VALUE(50,95), 0);
DBMS_OUTPUT.PUT_LINE(rnd);
update customer_mst
set score = rnd
where customer_id = customers.customer_id;

EXIT WHEN ids%NOTFOUND;
END LOOP;
commit;
close ids;
END;
/
[/sql]

This entry was posted in Oracle, 技術情報. Bookmark the permalink.

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です