Oracle SQL illegal year

Oracle SQL illegal year,第1张

Oracle SQL illegal year

我解决了!我的问题是变量不在其块外:

DECLARE...BEGINEND;

因此,我不得不声明将要插入到一个表中的所有变量,并在同一块中进行插入。这是完整的工作代码:

DROp TABLE ACCEPT_RESULT;DROP TABLE documentS;DROP TABLE STUDENT;DROP TABLE NEW_TABLE;DROP SEQUENCE S_ACCEPT;DROP SEQUENCE S_DOC;DROP SEQUENCE S_STUD;CREATE TABLE STUDENT(ID_STUDENT NUMBER PRIMARY KEY,F_NAME VARCHAr2(20),L_NAME VARCHAr2(20),BORN_DATE DATE);CREATE TABLE documentS(DOC_ID NUMBER PRIMARY KEY,ENTERED DATE,FINISHED DATE,ID_STUDENT NUMBER REFERENCES STUDENT(ID_STUDENT));CREATE TABLE ACCEPT_RESULT(DETAIL_ID NUMBER PRIMARY KEY,UNIVERSITY_NAME VARCHAr2(50),FACULTY_NAME VARCHAr2(30),DOC_ID NUMBER REFERENCES documentS(DOC_ID));CREATE TABLE NEW_TABLE(F_NAME VARCHAr2(20),L_NAME VARCHAr2(20),UNIVERSITY VARCHAr2(50),FACULTY_NAME VARCHAr2(30));INSERT INTO NEW_TABLE VALUES ('AGNE', 'AGNAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('INGRIDA', 'INGRIDAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('ANTANAS', 'ANTANAITIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('BRONIUS', 'BRONEVICIUS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('LIEPA', 'LIEPAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('AGNE', 'TAUTAVICIUTE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('ILONA', 'SILAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('AKVILE', 'GEDRIMAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('ANDRIUS', 'STONKUS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('GRETA', 'GRETAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('KASPARAS', 'NACIUS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('ROKAS', 'DARGEVICIUS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('JUSTINAS', 'ENGELAITIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('VALIUS', 'DUMBRAUSKAS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('EDGARAS', 'GVOZDAS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('ANTANAS', 'JASAITIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('LINAS', 'STARKUTIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('AURIMAS', 'GEDMINTAS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('LINAS', 'LINAITIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('LINAS', 'LINELIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');INSERT INTO NEW_TABLE VALUES ('KRUMAS', 'TADAS', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('MElynas', 'Tadas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Raudonas', 'Tomas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Zalias', 'Karolis', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Geltonas', 'Robertas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('OranZinis', 'Rokas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Juodas', 'Justinas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Pilkas', 'Ignas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Dariauskas', 'Darius', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Kairys', 'Jurgis', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('DeSinytE', 'Ruta', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('VySniauskas', 'Petras', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('SiemaitE', 'Aurelija', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('GirtauskaitE', 'Ieva', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Piemenaitis', 'Audrius', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Grybas', 'Karolis', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('EkranaviCius', 'Tomas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Klavauskas', 'Antanas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('ZiurkytE', 'Sandra', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('Kaleimauskas', 'Domas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');INSERT INTO NEW_TABLE VALUES ('BlaiveviCius',   'Haroldas', 'KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('PelytE', '   AuSra','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('MeSkaitE', ' Viktorija','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('Vilkas', '   K臋stas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('KrUmas', '   ArUnas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('Medis', '    ArtUras','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('ObuolaitE', 'Ingrida','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('GaidauskienE', 'EglE','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('ZuvienE', 'Monika','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('MorkaviCius', 'Tadas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('DeSrytE', 'Kornelija','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('SUris', 'Aurimas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('BandelE', 'Greta','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('RUkaviCius', 'Edgaras','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('Kreivauskas', 'Mantas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('AklaitE', 'Diana','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('Nekalbys', 'Rytis','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('Telefonas', 'Deividas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('LentaitE', 'Gabija','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('Viniauskas', 'Hermanas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');INSERT INTO NEW_TABLE VALUES ('MALKA', 'TOMAS','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');CREATE SEQUENCE S_STUD;CREATE SEQUENCE S_DOC;CREATE SEQUENCE S_ACCEPT;CREATE OR REPLACE PROCEDURE INSERT_DATA(HOW_MANY_RECORDS NUMBER) ISBEGINFOR I IN 1..HOW_MANY_RECORDS LOOPDECLAREF_NAME_VALUE VARCHAr2(20);L_NAME_VALUE VARCHAr2(20);BORN_DATE_VALUE DATE;BEGINSELECT F_NAME INTO F_NAME_VALUEFROM(SELECt F_NAME FROM NEW_TABLEORDER BY dbms_random.value)WHERe rownum = 1;SELECt L_NAME INTO L_NAME_VALUEFROM(SELECt L_NAME FROM NEW_TABLEORDER BY dbms_random.value)WHERe rownum = 1;BORN_DATE_VALUE := TO_DATE(TRUNC(DBMS_RANDOM.value(TO_CHAr(date '1870-01-01','J'),TO_CHAr(date '1995-01-01','J'))),'J');INSERT INTO STUDENT(ID_STUDENT,F_NAME,L_NAME,BORN_DATE)VALUES (S_STUD.NEXTVAL,F_NAME_VALUE,L_NAME_VALUE,BORN_DATE_VALUE);END; -------------------------------------------------------------------DECLAREENTERED_DATE_VALUE DATE;FINISHED_DATE_VALUE DATE;BEGINENTERED_DATE_VALUE :=TO_DATE(TRUNC(DBMS_RANDOM.value(TO_CHAr(date '1870-01-01','J'),TO_CHAr(date '1995-01-01','J'))),'J');FINISHED_DATE_VALUE :=TO_DATE(TRUNC(DBMS_RANDOM.value(TO_CHAr(date '1870-01-01','J'),TO_CHAr(date '1995-01-01','J'))),'J');INSERT INTO documentS(DOC_ID,ENTERED, FINISHED, ID_STUDENT)VALUES(S_DOC.NEXTVAL,ENTERED_DATE_VALUE, FINISHED_DATE_VALUE, S_STUD.CURRVAL);END; ------------------------------------------------------------------DECLAREUNIVERSITY_NAME_VALUE VARCHAr2(50);FACULTY_NAME_VALUE VARCHAr2(30);BEGIN    SELECt UNIVERSITY INTO UNIVERSITY_NAME_VALUEFROM(SELECt UNIVERSITY FROM NEW_TABLEORDER BY dbms_random.value)WHERe rownum = 1;SELECt FACULTY_NAME INTO FACULTY_NAME_VALUEFROM(SELECt FACULTY_NAME FROM NEW_TABLEORDER BY dbms_random.value)WHERe rownum = 1;INSERT INTO ACCEPT_RESULT(DETAIL_ID,UNIVERSITY_NAME,FACULTY_NAME,DOC_ID)VALUES (S_ACCEPT.NEXTVAL,UNIVERSITY_NAME_VALUE, FACULTY_NAME_VALUE, S_DOC.CURRVAL);END;END LOOP;END;/EXECUTE INSERT_DATA(15);


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5649692.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存