0
表的話,我想生成插入產生隨機的話從一個表插入到另一個表(PLSQL)
create table words
(word varchar(100));
insert into words values ('Main street');
insert into words values ('Patrick Street');
insert into words values ('Red Street');
insert into words values ('Green street');
insert into words values ('Blue street');
insert into words values ('Yellow street');
insert into words values ('Silver street');
insert into words values ('Gold street');
insert into words values ('Brown street');
PLSQL代碼
declare
randTemp number(10);
tempCounty VARCHAR(20);
streetaddress VARCHAR(100);
Begin
For i in 1..9
Loop
randTemp := dbms_random.value(1,5);
SELECT c.countyname INTO tempCounty FROM county C WHERE c.countyid = randTemp;
SELECT w.word INTO streetaddress FROM words w ORDER BY dbms_random.random limit 1;
Insert into BRANCH values(i,streetaddress,tempCounty,randTemp);
End loop;
Commit;
End;
/
一切正常,除了這個select語句
SELECT w.word INTO streetaddress FROM words w ORDER BY dbms_random.random limit 1;
我得到這個錯誤
ORA-06550:行10,列75: PL/SQL:ORA-00933:SQL命令不能正確地結束
我覺得限制可能是問題... ???
雅這工作。感謝那:-) – Dtoon
LIMIT在12c被引入,顯然。 –