原始碼:
DECLARE
CURSOR c1
IS
SELECT *
FROM src_list
FOR UPDATE OF callednum,
businessnum,
startdate,
starttime,
DURATION,
unitnumber,
fee;
v_callednum VARCHAR2 (20);
v_startdate CHAR (8);
v_starttime CHAR (6);
v_duration NUMBER (10);
v_unitnumber NUMBER (7);
v_fee NUMBER (8);
BEGIN
FOR r IN c1
LOOP
SELECT called168
INTO v_callednum
FROM (SELECT called168
FROM called168
ORDER BY DBMS_RANDOM.VALUE)
WHERE ROWNUM = 1;
SELECT '200611' || TO_CHAR (TRUNC (DBMS_RANDOM.VALUE (10, 30)))
INTO v_startdate
FROM DUAL;
SELECT LPAD (TO_CHAR (TRUNC (DBMS_RANDOM.VALUE (9, 20))), 2, '0')
|| LPAD (TO_CHAR (TRUNC (DBMS_RANDOM.VALUE (1, 59))), 2, '0')
|| LPAD (TO_CHAR (TRUNC (DBMS_RANDOM.VALUE (1, 59))), 2, '0')
INTO v_starttime
FROM DUAL;
SELECT TRUNC (DBMS_RANDOM.VALUE (120, 480))
INTO v_duration
FROM DUAL;
SELECT CEIL (v_duration / 60)
INTO v_unitnumber
FROM DUAL;
v_fee := v_unitnumber * 200;
UPDATE src_list
SET callednum = v_callednum,
businessnum = v_callednum,
startdate = v_startdate,
starttime = v_starttime,
DURATION = v_duration,
unitnumber = v_unitnumber,
fee = v_fee
WHERE CURRENT OF c1;
END LOOP;
COMMIT;
END;