CodePudding user response:
The original poster is which stored procedures in trouble?CodePudding user response:
The create or replace procedure proc_random is
V_FilePath varchar2 (200); - recording file path, random six letters
V_PartId varchar2 (200); - field MMDD format, random four Numbers
V_StaffNo varchar2 (200); - business representatives, from YTCZ060001 - YTCZ060020 randomly generated
V_RecordTime date; - recording time, from the first six months of 20170804 randomly generated
Number: x=0; - cycle
The begin
- loop through 500
While x<=50000 loop
X:=x + 1;
- generate six letters
The select dbms_random. String (' U ', 6) into v_FilePath from dual;
- generate four digital
Select round (dbms_random value (9), 1000999) into v_PartId from dual;
- generate business number
Select 'YTCZ0600' | | to_char (round (dbms_random. Value (1, 20)), 'fm00) into v_StaffNo from dual;
- generate time
The select to_date (trunc (dbms_random. Value (to_number (to_char (to_date (' 20170801 ', 'yyyymmdd'), 'J')),
To_number (to_char (to_date (' 20170201 ', 'yyyymmdd') + 1, 'J')))),
'J') into v_RecordTime/* +
(trunc (dbms_random. Value (9, 17)) * 3600 +
Trunc (dbms_random value (0, 60)) * 60 +
Trunc (dbms_random value (0, 60)))/(24 * 60 * 60) */
The from dual;
- to insert data t_lzinfor table
Insert into t_lzinfor (seriaino, filepath partid, staffno, recordtime)
Values (t_lzinfor_seq nextval, v_FilePath v_PartId, v_StaffNo, v_RecordTime);
commit;
end loop;
End proc_random;
CodePudding user response:
The following SQL is randomly generated 1000 records, other are simple, write their own right,select rownum serialno used to - automatic growth sequence
Dbms_random. String (' $', 6) filepath, take six - random word give
Trunc (dbms_random value (4, 9999)) partid, - random take four digital
'YTCZ0' | | trunc (dbms_random value (20) 60001600) staffno, - from YTCZ060001... YTCZ060020 randomly in the
To_date (trunc (
Dbms_random. Value (
To_char (add_months (to_date (' 20060804 ', 'YYYYMMDD'), and 6), 'J'),
To_char (add_months (to_date (' 20060804 ', 'YYYYMMDD'), and 6), 'J') +
(to_date (' 20060804 ', 'YYYYMMDD') - add_months (to_date (' 20060804 ', 'YYYYMMDD'), and 6))
)
), 'J') - from August 4, 2006 of 6 months, random
The from dual
Connect by level & lt;=1000;
CodePudding user response:
Optimize the random time statementselect rownum serialno used to - automatic growth sequence
Dbms_random. String (' $', 6) filepath, take six - random word give
Trunc (dbms_random value (4, 9999)) partid, - random take four digital
'YTCZ0' | | trunc (dbms_random value (20) 60001600) staffno, - from YTCZ060001... YTCZ060020 randomly in the
To_date (' 20060804 ', 'YYYYMMDD') --
Trunc (dbms_random. Value (0,
To_date (' 20060804 ', 'YYYYMMDD') --
Add_months (to_date (' 20060804 ', 'YYYYMMDD'), and 6))
) - from August 4, 2006 of 6 months, random
The from dual
Connect by level & lt;=1000;