|
在Oracle SQL Developer 11g中,我试图生成一个随机日期,将其分配给变量,然后插入表中。将日期生成+分配给可变代码(效果很好):
) N! E# N" D. NDECLARE 6 ]: S1 ~8 r) S1 }8 v! D# s: H
Launch_date DATE;3 K% W- f0 {4 C( z$ y- _
BEGIN
# P$ `9 g) \% n/ ` Launch_date:=TO_DATE(TRUNC(
) R9 s: T5 @1 @ DBMS_RANDOM.value(
" _0 w' p; t j* ?- U2 p! z6 n TO_CHAR(date '2000-01-01','J')7 f7 [$ x0 o, H/ ^, L6 }) `1 r
,TO_CHAR(date '2015-01-01','J')
8 I. H# t$ g# B )),'J');
8 H+ e, p% H3 K; Q END;
" K. H1 L3 Q8 Y1 M. r7 S2 T% Q. ]
尝试将其插入到表中时,出现以下错误消息:4 Y8 V9 L$ b8 c
Error starting at line : 214 in command -( T; H0 J! a/ ~2 r1 P1 ]6 r
EXECUTE INSERT_DATA(15)* k% a6 o6 A: w1 C
Error report -- @' B+ X- @$ y% P' ~9 ~6 w( o
ORA-01841: (full) year must be between -4713 and +9999, and not be 0
9 d0 U6 M C% {- ~ORA-06512: at "KALVAITYTE_INGRIDA.INSERT_DATA", line 43
0 V9 \ J$ p$ y9 K) rORA-06512: at line 1' Q$ b- R6 a) P; X, J& X$ n
01841. 00000 - "(full) year must be between -4713 and +9999, and not be 0"
' o, I6 [3 }& w+ T. V; N, @*Cause: Illegal year entered
* k% D, T: y4 ] h* p& o$ c# k*Action: Input year in the specified range
/ ]% ?0 F* T7 H* g
i/ H- G# u9 ^7 K6 H' {- R这是完整的代码:
7 j1 P+ U. {& k4 ]) \/ VDROP TABLE ACCEPT_RESULT;
+ ?# Q- ~0 {' }" m4 k- BDROP TABLE DOCUMENTS;
/ d# X n# L6 u: A4 F6 Q) ?, X1 _DROP TABLE STUDENT;
* S8 |9 ^& x- o( ]DROP TABLE NEW_TABLE;7 V; H0 p7 |$ @' e
DROP SEQUENCE S_ACCEPT;
7 i9 r. y% \' F- BDROP SEQUENCE S_DOC;& r6 F0 l [+ J5 z
DROP SEQUENCE S_STUD;. ^3 N c0 M; D Y, i
CREATE TABLE STUDENT( F, E0 t4 }2 K ]
(ID_STUDENT NUMBER PRIMARY KEY,
) e- @7 B6 f) x0 {F_NAME VARCHAR2(20),
3 T0 i. X3 t ?0 ~" xL_NAME VARCHAR2(20),! e" @2 h% w. ^2 f. Q, c7 P
BORN_DATE DATE ' a" R% N+ ^; G: w& V
);
2 q! p8 C* X0 {; S$ A$ j0 ^4 W+ K, Z7 u, vCREATE TABLE DOCUMENTS
- r6 ?" m1 r6 w5 [. J6 B(
i) p$ X9 U8 NDOC_ID NUMBER PRIMARY KEY, P7 e. e; x- Y1 s0 g4 B+ a: B
ENTERED DATE,
- N# S) _/ h" B* DFINISHED DATE,
7 W9 B% j, ^! t5 b; MID_STUDENT NUMBER REFERENCES STUDENT(ID_STUDENT)
3 X* O+ A9 d! \9 s4 y+ O/ ~& g3 R );2 m2 | }6 v' }+ `0 l6 N$ \, [
CREATE TABLE ACCEPT_RESULT2 g" I7 R8 n) h/ h0 G- {
(DETAIL_ID NUMBER PRIMARY KEY,7 `" e$ L$ v4 @& T$ ^
UNIVERSITY_NAME VARCHAR2(50),
0 ^' c9 S! @; h( E3 [: yFACULTY_NAME VARCHAR2(30),: Y6 E+ c$ H5 A) P+ d
DOC_ID NUMBER REFERENCES DOCUMENTS(DOC_ID)% c6 V8 ?# Q" H8 K
);
$ z- A9 O( T7 t2 k7 B- V1 a; MCREATE TABLE NEW_TABLE% W! X% N: Q; y1 T
(, K$ F) _/ F- B6 w6 ^& n. j9 o2 X
F_NAME VARCHAR2(20),
3 a! f3 ]' X: s I/ B" CL_NAME VARCHAR2(20),' g0 n9 K# W2 e
UNIVERSITY VARCHAR2(50),- ^) M5 I/ l3 i( Y/ k9 ~; _. W
FACULTY_NAME VARCHAR2(30)
3 A" w( C7 U$ H5 Y. _' g$ O);$ u w% `3 ^ ~9 ]" u
INSERT INTO NEW_TABLE VALUES ('AGN?', 'AGNAIT?', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');* ` j$ S' m8 \" I& y" `' M4 \3 l
INSERT INTO NEW_TABLE VALUES ('INGRIDA', 'INGRIDAIT?', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');; \& a, r% P/ t3 t+ E+ n; V
INSERT INTO NEW_TABLE VALUES ('ANTANAS', 'ANTANAITIS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');. L+ N1 v s" \4 Q
INSERT INTO NEW_TABLE VALUES ('BRONIUS', 'BRONEVI?IUS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');) W) o) q, K" ^3 y7 ?' I2 L1 }
INSERT INTO NEW_TABLE VALUES ('LIEPA', 'LIEPAIT?', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
2 o- I% g( y+ }" H& _+ B' f- N6 vINSERT INTO NEW_TABLE VALUES ('AGN?', 'TAUTAVI?IūT?', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
3 D# ]+ V4 D) p; F: i6 TINSERT INTO NEW_TABLE VALUES ('ILONA', '?ILAIT?', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');! a) P& [- |/ ^) J5 }- x
INSERT INTO NEW_TABLE VALUES ('AKVIL?', 'GEDRIMAIT?', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');6 o6 Q9 H* g6 W% k5 [1 g9 T# j5 }
INSERT INTO NEW_TABLE VALUES ('ANDRIUS', 'STONKUS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
+ }* N8 j/ e1 e' f, ~INSERT INTO NEW_TABLE VALUES ('GRETA', 'GRETAIT?', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');% f: m% H4 @, N: V8 f$ {3 l8 e% R
INSERT INTO NEW_TABLE VALUES ('KASPARAS', 'NACIUS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');! n; L( m6 |' M/ q% o
INSERT INTO NEW_TABLE VALUES ('ROKAS', 'DARGEVI?IUS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
; w" g0 k2 K$ y ~8 W: j+ e! NINSERT INTO NEW_TABLE VALUES ('JUSTINAS', 'ENGELAITIS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');( s' u3 v/ O+ ^
INSERT INTO NEW_TABLE VALUES ('VALIUS', 'DUMBRAUSKAS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
6 J6 t& M- |$ kINSERT INTO NEW_TABLE VALUES ('EDGARAS', 'GVOZDAS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
4 m( q' z! _0 y; R0 f: z" Z0 FINSERT INTO NEW_TABLE VALUES ('ANTANAS', 'JASAITIS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
3 R; `/ e" s$ g$ ]0 N0 ZINSERT INTO NEW_TABLE VALUES ('LINAS', 'STARKUTIS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
. l4 B3 ^: p* s% f# L+ JINSERT INTO NEW_TABLE VALUES ('AURIMAS', 'GEDMINTAS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
% D7 M" S& _ A: |8 g0 U9 v% {) WINSERT INTO NEW_TABLE VALUES ('LINAS', 'LINAITIS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
+ H5 h, ?" @8 ~; x- I1 eINSERT INTO NEW_TABLE VALUES ('LINAS', 'LINELIS', 'KLAIP?DA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
6 i' s g3 t( C6 D" AINSERT INTO NEW_TABLE VALUES ('KRūMAS', 'TADAS', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
. Y) P! V' }* V0 @0 V( oINSERT INTO NEW_TABLE VALUES ('M?lynas', 'Tadas', 'KLAIP?DA UNIVERSITY', 'SOCIAL');7 u! A& r" z7 r7 L3 I
INSERT INTO NEW_TABLE VALUES ('Raudonas', 'Tomas', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
1 I8 k, \" R7 S5 x, F" gINSERT INTO NEW_TABLE VALUES ('?alias', 'Karolis', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
& y# o2 f" z J7 \INSERT INTO NEW_TABLE VALUES ('Geltonas', 'Robertas', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
5 S4 G( L/ T2 A' Z/ q& JINSERT INTO NEW_TABLE VALUES ('Oran?inis', 'Rokas', 'KLAIP?DA UNIVERSITY', 'SOCIAL');! Q' k4 T7 o3 r% e1 i( {0 x4 X
INSERT INTO NEW_TABLE VALUES ('Juodas', 'Justinas', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
1 W# t0 s4 x$ L% P4 e1 J& oINSERT INTO NEW_TABLE VALUES ('Pilkas', 'Ignas', 'KLAIP?DA UNIVERSITY', 'SOCIAL');, H. A3 }, @& G& A6 X& o' u; r
INSERT INTO NEW_TABLE VALUES ('Dariauskas', 'Darius', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
4 G) j3 C8 M+ U: h+ z2 j7 ~INSERT INTO NEW_TABLE VALUES ('Kairys', 'Jurgis', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
a* Q/ K! Z4 l) b4 XINSERT INTO NEW_TABLE VALUES ('De?inyt?', 'Rūta', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
- }4 e! L/ j. S+ Y( N4 LINSERT INTO NEW_TABLE VALUES ('Vy?niauskas', 'Petras', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
) d: u3 e' F3 t+ Z$ [/ F/ oINSERT INTO NEW_TABLE VALUES ('Siemait?', 'Aurelija', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
# X4 y+ k& C; B6 N) M7 a- eINSERT INTO NEW_TABLE VALUES ('Girtauskait?', 'Ieva', 'KLAIP?DA UNIVERSITY', 'SOCIAL');+ O/ T( T" K9 S
INSERT INTO NEW_TABLE VALUES ('Piemenaitis', 'Audrius', 'KLAIP?DA UNIVERSITY', 'SOCIAL');- p* P2 \" q$ N; H. R% t; u9 s
INSERT INTO NEW_TABLE VALUES ('Grybas', 'Karolis', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
9 ~! j. L$ q1 Z4 P9 G+ f& \; {, wINSERT INTO NEW_TABLE VALUES ('Ekranavi?ius', 'Tomas', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
$ }0 W2 H5 R3 E# h6 vINSERT INTO NEW_TABLE VALUES ('Klavauskas', 'Antanas', 'KLAIP?DA UNIVERSITY', 'SOCIAL');0 Y5 L1 j3 @; P" Y6 e: o
INSERT INTO NEW_TABLE VALUES ('?iurkyt?', 'Sandra', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
3 n5 I; f) Y9 pINSERT INTO NEW_TABLE VALUES ('Kaleimauskas', 'Domas', 'KLAIP?DA UNIVERSITY', 'SOCIAL');
4 }; T% `) j* WINSERT INTO NEW_TABLE VALUES ('Blaivevi?ius', 'Haroldas', 'KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
2 `9 r+ E+ O* f7 D$ C2 e1 gINSERT INTO NEW_TABLE VALUES ('Pelyt?', ' Au?ra','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');: u$ p" I! ^" n [* n$ B* h
INSERT INTO NEW_TABLE VALUES ('Me?kait?', ' Viktorija','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');1 m( G" n9 Q2 X; m0 R/ J2 P
INSERT INTO NEW_TABLE VALUES ('Vilkas', ' K?stas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');8 Y+ Z& Y$ `) t7 V" E$ R0 K+ m
INSERT INTO NEW_TABLE VALUES ('Krūmas', ' Arūnas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
$ ?" P2 K& e1 q6 Y8 m/ U+ M/ zINSERT INTO NEW_TABLE VALUES ('Medis', ' Artūras','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
+ S4 \; Q Q4 s; c" ?& SINSERT INTO NEW_TABLE VALUES ('Obuolait?', 'Ingrida','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');* o' P0 P) [1 n% }( F* T( c( t
INSERT INTO NEW_TABLE VALUES ('Gaidauskien?', 'Egl?','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');6 m/ K: q$ I2 Q3 G1 a& p" Q# |
INSERT INTO NEW_TABLE VALUES ('?uvien?', 'Monika','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');4 m/ B' \6 Y; R
INSERT INTO NEW_TABLE VALUES ('Morkavi?ius', 'Tadas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');( q0 m7 V( {$ {4 F" C2 ~
INSERT INTO NEW_TABLE VALUES ('De?ryt?', 'Kornelija','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');3 U; a' W' V" J) u6 G8 @
INSERT INTO NEW_TABLE VALUES ('Sūris', 'Aurimas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE'); D! A; x# w6 P* i1 z2 h, r
INSERT INTO NEW_TABLE VALUES ('Bandel?', 'Greta','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');! c& x& _3 i* h# k" y
INSERT INTO NEW_TABLE VALUES ('Rūkavi?ius', 'Edgaras','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');! z- Y4 j6 T5 Y6 R6 a, @( N* \
INSERT INTO NEW_TABLE VALUES ('Kreivauskas', 'Mantas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
+ W8 ^- ]1 c5 H1 ?! z, NINSERT INTO NEW_TABLE VALUES ('Aklait?', 'Diana','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
+ X5 `( v6 S9 ]INSERT INTO NEW_TABLE VALUES ('Nekalbys', 'Rytis','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');: K4 C6 g6 ~% X4 X; h# q
INSERT INTO NEW_TABLE VALUES ('Telefonas', 'Deividas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
3 t u6 Y0 m! m/ c0 {6 FINSERT INTO NEW_TABLE VALUES ('Lentait?', 'Gabija','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');2 c( X4 D, b: t, J( r1 Q1 q
INSERT INTO NEW_TABLE VALUES ('Viniauskas', 'Hermanas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
2 q7 w/ I. v. [% p& w4 UINSERT INTO NEW_TABLE VALUES ('MALKA', 'TOMAS','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');6 b8 x) y& n' l, ~# k2 _" z
1 i1 c6 s0 W8 i+ Q; S3 Y. x+ L3 _CREATE SEQUENCE S_STUD;& k. @2 R8 H# Q9 `* [/ A
CREATE SEQUENCE S_DOC;$ O/ N( H5 L% g3 _, o9 M+ O' [2 G" a, r
CREATE SEQUENCE S_ACCEPT;* M" @: Q( h# K$ |7 ?* ^* w7 \
( B! W3 S$ e% d8 q, LCREATE OR REPLACE PROCEDURE INSERT_DATA(HOW_MANY_RECORDS NUMBER) IS
$ t, {" X8 e$ j# Y8 eBEGIN
( ~2 i9 M9 g2 c' p- a o/*
1 G. I O {' t& Q) f1 TABLE STUDENT* _/ w% Q" Q, V, }& L
*/
7 w. x0 G: |' H6 L+ [. F3 zFOR I IN 1..HOW_MANY_RECORDS LOOP8 ^7 _& l& }8 c7 C: i8 \$ x. I
DECLARE
7 G' @8 W% B7 [) t, f, gF_NAME_VALUE VARCHAR2(20);
- J8 g; c# [$ T: L3 a4 uBEGIN
( y% A7 w9 ^/ b; n: r. }SELECT F_NAME INTO F_NAME_VALUE . g. i/ }) W) G+ n/ r
FROM7 A- T5 k9 ?0 h7 X1 c7 [
(SELECT F_NAME FROM NEW_TABLE
2 P, X+ X" q# h" fORDER BY dbms_random.value)) h' p, s, _# | X
WHERE rownum = 1;
X' k! z- |" f2 O2 `: K! p" F. R& [END;3 `5 K, j7 x: t5 |0 t* M3 T
DECLARE 2 T/ O3 h4 Z7 c, q' n# c
L_NAME_VALUE VARCHAR2(20);" }, r" T2 @$ [( N ^. d- Y
BEGIN- d) I; `4 k0 N! x
SELECT L_NAME INTO L_NAME_VALUE
8 r5 B2 Y4 O9 |, O3 R) uFROM
5 h; i3 x, {' b) D. Z8 b5 U/ G(SELECT L_NAME FROM NEW_TABLE2 y; X |5 G4 k; |
ORDER BY dbms_random.value)
* U& q7 g Z& E$ F/ e- F1 MWHERE rownum = 1;" t& x# Z: @& r
END;# q; V# t- e5 Q! l, H
DECLARE 3 G+ b* G z: I; d4 } x( ^
BORN_DATE_VALUE DATE;
- I% f7 E6 z& [% A$ }BEGIN" X. y7 h$ ]8 Q# s
BORN_DATE_VALUE :=TO_DATE(TRUNC(7 I: ?" e, i5 a3 B
DBMS_RANDOM.value(
0 y( _' [3 w- sTO_CHAR(date '1870-01-01','J')1 l3 b# M+ c; R2 L/ p
,TO_CHAR(date '1995-01-01','J')3 D! m/ A2 I1 \; ?) N3 h
)),'J');
* l3 X. }: F' Q& DEND;
6 y [. F8 u- U# X
8 b f& |2 M) W0 ?! W. dINSERT INTO STUDENT(ID_STUDENT,F_NAME,L_NAME,BORN_DATE)6 ~ L: G0 E E) [; d4 n
VALUES (S_STUD.NEXTVAL,F_NAME_VALUE,L_NAME_VALUE, BORN_DATE_VALUE);8 N0 A5 ^8 k. R
-------------------------------------------------------------------- R2 u" c! _ w
/*
0 D" d, h8 Q. R6 V2 TABLE DOCUMENTS/ B3 t+ E' b' [ ]9 f; h# N+ h
*/) A# H. q/ [4 {( h {9 F- I
DECLARE
8 S2 z7 x: X4 X/ U; ]ENTERED_DATE_VALUE DATE;7 ?+ U# s' w9 {" l. b( m4 T, O
BEGIN
0 ?6 g) a: T7 WENTERED_DATE_VALUE :=TO_DATE(TRUNC(
- h! c, Z" x! A% O8 {6 tDBMS_RANDOM.value(
) ~3 S$ P, t! W& S( qTO_CHAR(date '1870-01-01','J')
0 c5 a; B7 p2 q' y% Z" X& m6 o,TO_CHAR(date '1995-01-01','J')
% W0 |5 u9 L9 Z/ |7 M)),'J');
8 \. u3 K. T/ g; K4 }. \. ]/ g) LEND;
8 u, ^ C2 N/ R, y! h- ~6 |! W2 v4 kDECLARE 6 w6 s3 J8 ^, k, v' P
FINISHED_DATE_VALUE DATE;
. K- X) j* X$ r6 j- a. a+ T; F( D6 QBEGIN
& i$ g; T+ G8 j' H: S4 c) `FINISHED_DATE_VALUE :=TO_DATE(TRUNC(# c' t1 @6 j0 [) `
DBMS_RANDOM.value(8 {* R& a) e9 B, m9 V/ `
TO_CHAR(date '1870-01-01','J')
" J7 B2 n- N& I( [: C m,TO_CHAR(date '1995-01-01','J')
# R( {- a: e6 W* v$ [)),'J');
/ G2 B( S* p% @) h% y! g$ AEND;
; i1 G% y, k9 }INSERT INTO DOCUMENTS(DOC_ID,ENTERED, FINISHED, ID_STUDENT)
3 G* K/ O# f% CVALUES(S_DOC.NEXTVAL,ENTERED_DATE_VALUE, FINISHED_DATE_VALUE, S_STUD.CURRVAL);
& [( N, u* j) F6 P6 B, V------------------------------------------------------------------
3 ^4 j, u+ X: Y8 l7 s1 t/*
& H* _; [# d$ C" X% U. f5 q; Q3 TABLE ACCEPTANCE
) a+ E2 q7 A% M t S5 \1 ?*/
2 _3 q" q3 j8 \9 @8 J% g k1 d! g2 Y0 ?
DECLARE $ E2 x# J# d7 X _0 M S
UNIVERSITY_NAME_VALUE VARCHAR2(50);
/ p7 Z* e `1 j1 FBEGIN % w2 J! J7 b7 N3 u
SELECT UNIVERSITY INTO UNIVERSITY_NAME_VALUE
1 A8 t$ w4 S8 \( M: t& w5 t. d2 oFROM
' n! h- M3 ^. @& X$ V(SELECT UNIVERSITY FROM NEW_TABLE
- i ^9 _, O% E! T- W. SORDER BY dbms_random.value)
; J3 U! V9 i' x# wWHERE rownum = 1;
5 R) s: T6 { f+ s- Y/ O# {- ]2 DEND;
4 N0 M+ O! {8 h2 i$ P) lDECLARE
2 `* y8 v2 m8 z& Q3 WFACULTY_NAME_VALUE VARCHAR2(30);
% f$ \, k, B ^6 ^6 i( x2 \BEGIN
9 ?8 ?( m! `' G: O+ t4 p4 S8 lSELECT FACULTY_NAME INTO FACULTY_NAME_VALUE) Q. I; j! X2 ~/ i' c, ?
FROM
/ Z7 B. y1 \5 k) y& d& {; l(SELECT FACULTY_NAME FROM NEW_TABLE
4 ~, Y7 A* Q2 N9 p3 j% ]ORDER BY dbms_random.value)
8 L, G' o( c9 j* q4 w6 s+ bWHERE rownum = 1; 0 B% K6 Q3 j, f+ a5 y
END;
" m9 ~% S% Y# j* h/ P
/ e3 W6 G; S8 |" M) _; r! VINSERT INTO ACCEPT_RESULT(DETAIL_ID,UNIVERSITY_NAME,FACULTY_NAME,DOC_ID)7 x6 v& X& B. P" t
VALUES (S_ACCEPT.NEXTVAL,UNIVERSITY_NAME_VALUE, FACULTY_NAME_VALUE, S_DOC.CURRVAL);
" d( K3 T" `! g1 h/ QEND LOOP;
) n) x* y* g7 n$ G _* G2 c* D' n* B; t8 Q
END;
# f2 M* @: ?5 y4 n- V/$ N, l4 @; Q5 P% e
EXECUTE INSERT_DATA(15);
9 ]* L! A- I P' T& l. N/ l( }; b# \; d& k; o
我在这里想念什么?2 i, O# I( b$ ?+ J' x
2 s. j# b8 b( `4 p& x. v解决方案:$ D6 k2 _* d; `% K6 l9 w1 } H
: B9 {6 w- e- z' j+ q! h
. p, d% ^: r0 l k; j- B F" h; E
我解决了!我的问题是变量不在其块外:
; z$ t1 T) [2 s1 ?8 ^DECLARE
- d8 l- {6 U* ]& V) K+ g...
* V3 F* z+ y2 F% }( W: F4 ?; [BEGIN
5 X3 f1 v& E G B' b. LEND;
# l: E+ V6 q7 i3 _7 E因此,我不得不声明将要插入到一个表中的所有变量,并在同一块中进行插入。这是完整的工作代码:
: w( n; o# t1 YDROP TABLE ACCEPT_RESULT;
* U( U# {, f3 y! ^ Q) r2 W! {DROP TABLE DOCUMENTS;. |( s3 L. M4 s0 }& ]8 C8 J+ ]
DROP TABLE STUDENT;
8 e7 A0 C' c! h3 ]DROP TABLE NEW_TABLE;
9 ~$ b3 ?0 w1 \3 R( A$ p: ^+ F, BDROP SEQUENCE S_ACCEPT;
+ P4 q7 u% @. s) EDROP SEQUENCE S_DOC;- N5 {% v6 [8 f
DROP SEQUENCE S_STUD;7 l; k8 U' G7 e
8 h H) s& ^$ @( [ L3 i- T3 v n, UCREATE TABLE STUDENT
; L/ f$ i4 c. Q( j- E(ID_STUDENT NUMBER PRIMARY KEY,
, ~ c, v1 a& V0 iF_NAME VARCHAR2(20),* Y, o0 _: h+ h) E$ }# ?$ w% ]
L_NAME VARCHAR2(20), D5 [; P4 ~/ Q+ _( X
BORN_DATE DATE" {$ C. M' K5 p6 o
);
' R2 [3 M+ u* K, O" V( e& ~+ I* e" J ?5 ]5 k3 L: f* ]
CREATE TABLE DOCUMENTS
6 T, q3 E2 `# m7 m2 E0 r(7 f0 |1 \; y3 D5 {) A/ x' @
DOC_ID NUMBER PRIMARY KEY,
& I- p1 Z ?1 U2 `1 cENTERED DATE,
9 ^* c2 R& v1 @0 [FINISHED DATE,. b. a3 ^' x7 N; U F8 h$ P
ID_STUDENT NUMBER REFERENCES STUDENT(ID_STUDENT)
- W$ c1 }# W$ n9 A' e* m' H);
& Y; D1 n; ~+ W& s& h, @0 [; p' g7 q! o; u7 T$ J1 W3 E
CREATE TABLE ACCEPT_RESULT! E0 m/ i k6 t
(DETAIL_ID NUMBER PRIMARY KEY,7 v% U8 h+ \; ^
UNIVERSITY_NAME VARCHAR2(50),3 D, [5 m0 F7 X( `) y1 L t' c1 d- a
FACULTY_NAME VARCHAR2(30),
, G' A$ |5 M2 e- l: O# bDOC_ID NUMBER REFERENCES DOCUMENTS(DOC_ID)
& b" _# B( H# `1 C; d$ P& g8 C);9 w2 Y2 s3 n, E, |" M4 G. ?: }
% o: [3 R1 A# l; ^5 D/ [
CREATE TABLE NEW_TABLE- B7 _/ ] h0 Z) f! \" o( j
(
0 J; E2 _% i( f5 m! ~F_NAME VARCHAR2(20),
/ H" U- i) { mL_NAME VARCHAR2(20),, |8 c) x! Q" o" v; c6 v
UNIVERSITY VARCHAR2(50),
7 ~4 l9 b5 h% _2 D3 lFACULTY_NAME VARCHAR2(30)
$ a1 o& K7 f5 T3 @, \9 E);( ^, w, }0 f4 Y1 \
8 Q, t9 i- L! tINSERT INTO NEW_TABLE VALUES ('AGNE', 'AGNAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
# g9 B7 U0 }6 w' U# o+ aINSERT INTO NEW_TABLE VALUES ('INGRIDA', 'INGRIDAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');# M: i& T( |; g# ]
INSERT INTO NEW_TABLE VALUES ('ANTANAS', 'ANTANAITIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');9 ^% T5 f9 ~2 s/ x/ [/ ]. h
INSERT INTO NEW_TABLE VALUES ('BRONIUS', 'BRONEVICIUS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');8 f _" ~3 p* M) g7 r' }
INSERT INTO NEW_TABLE VALUES ('LIEPA', 'LIEPAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');* q$ b1 O! \" ^$ \/ U# J: W
INSERT INTO NEW_TABLE VALUES ('AGNE', 'TAUTAVICIUTE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');& e; ^7 T! Z! x) |- h
INSERT INTO NEW_TABLE VALUES ('ILONA', 'SILAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY'); J1 T" K2 Z, t6 \
INSERT INTO NEW_TABLE VALUES ('AKVILE', 'GEDRIMAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
7 N0 k" q+ F. D1 M/ U* zINSERT INTO NEW_TABLE VALUES ('ANDRIUS', 'STONKUS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
$ C* R- q- N4 v3 JINSERT INTO NEW_TABLE VALUES ('GRETA', 'GRETAITE', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');; ], R9 ~3 C) o, {+ U
INSERT INTO NEW_TABLE VALUES ('KASPARAS', 'NACIUS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
0 V- N6 t- ^) T7 w! n' u6 ]INSERT INTO NEW_TABLE VALUES ('ROKAS', 'DARGEVICIUS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
6 y. r$ W( j& `; [; d# P' B; [8 b6 cINSERT INTO NEW_TABLE VALUES ('JUSTINAS', 'ENGELAITIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');" A# K# d2 B. e# k9 X
INSERT INTO NEW_TABLE VALUES ('VALIUS', 'DUMBRAUSKAS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');, b4 M+ e6 \# G/ l/ n
INSERT INTO NEW_TABLE VALUES ('EDGARAS', 'GVOZDAS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
; D& U C/ o. v# P3 xINSERT INTO NEW_TABLE VALUES ('ANTANAS', 'JASAITIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');1 ~$ D. Z' z- |# H9 t: Q% V
INSERT INTO NEW_TABLE VALUES ('LINAS', 'STARKUTIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
, Z) ^9 v3 k5 P, NINSERT INTO NEW_TABLE VALUES ('AURIMAS', 'GEDMINTAS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');4 S- y: n e$ H1 i a+ k) O
INSERT INTO NEW_TABLE VALUES ('LINAS', 'LINAITIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');
0 s' ^' G' V% [5 i" WINSERT INTO NEW_TABLE VALUES ('LINAS', 'LINELIS', 'KLAIPEDA STATE UNIVERSITY OF APPLIED SCIENCES', 'TECHNOLOGY');/ A( A- A; A5 M2 k) o2 _
INSERT INTO NEW_TABLE VALUES ('KRUMAS', 'TADAS', 'KLAIPEDA UNIVERSITY', 'SOCIAL');3 g7 B: y" X4 I/ @: o, U! _/ l5 K3 {
INSERT INTO NEW_TABLE VALUES ('MElynas', 'Tadas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
2 x r' C; I4 B. lINSERT INTO NEW_TABLE VALUES ('Raudonas', 'Tomas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');' M- }# K8 n! d8 T
INSERT INTO NEW_TABLE VALUES ('Zalias', 'Karolis', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
0 e" N' m, u& o `) Q2 {INSERT INTO NEW_TABLE VALUES ('Geltonas', 'Robertas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
& `" ]* X# S9 E( ]* M0 bINSERT INTO NEW_TABLE VALUES ('OranZinis', 'Rokas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
1 ^( v' b7 m% j; PINSERT INTO NEW_TABLE VALUES ('Juodas', 'Justinas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
4 b4 B1 g8 s( O& XINSERT INTO NEW_TABLE VALUES ('Pilkas', 'Ignas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
2 s( S5 H/ S: s- d5 g3 iINSERT INTO NEW_TABLE VALUES ('Dariauskas', 'Darius', 'KLAIPEDA UNIVERSITY', 'SOCIAL');& z$ V E/ w8 O2 r" b& G
INSERT INTO NEW_TABLE VALUES ('Kairys', 'Jurgis', 'KLAIPEDA UNIVERSITY', 'SOCIAL');; Q" [$ D. k- a- B
INSERT INTO NEW_TABLE VALUES ('DeSinytE', 'Ruta', 'KLAIPEDA UNIVERSITY', 'SOCIAL');. o' }3 m# s$ m4 K- a4 i: L7 h
INSERT INTO NEW_TABLE VALUES ('VySniauskas', 'Petras', 'KLAIPEDA UNIVERSITY', 'SOCIAL'); ]7 Y/ K5 e+ r
INSERT INTO NEW_TABLE VALUES ('SiemaitE', 'Aurelija', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
# t- h; O3 E2 |2 t. S& D- CINSERT INTO NEW_TABLE VALUES ('GirtauskaitE', 'Ieva', 'KLAIPEDA UNIVERSITY', 'SOCIAL');8 N2 H9 {& |" s) Z" |
INSERT INTO NEW_TABLE VALUES ('Piemenaitis', 'Audrius', 'KLAIPEDA UNIVERSITY', 'SOCIAL');" M' ?9 l9 ?1 a. z' m
INSERT INTO NEW_TABLE VALUES ('Grybas', 'Karolis', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
7 [7 k3 S$ n" }9 \9 HINSERT INTO NEW_TABLE VALUES ('EkranaviCius', 'Tomas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
9 p% [! A1 y3 e% gINSERT INTO NEW_TABLE VALUES ('Klavauskas', 'Antanas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');) l7 m# Z$ Z8 c( N& j2 s* B; n5 s# p
INSERT INTO NEW_TABLE VALUES ('ZiurkytE', 'Sandra', 'KLAIPEDA UNIVERSITY', 'SOCIAL');
- f$ V9 c7 R8 F! b" YINSERT INTO NEW_TABLE VALUES ('Kaleimauskas', 'Domas', 'KLAIPEDA UNIVERSITY', 'SOCIAL');: T0 | t0 |/ e. b8 g
INSERT INTO NEW_TABLE VALUES ('BlaiveviCius', 'Haroldas', 'KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');7 p( K5 @8 ?; z
INSERT INTO NEW_TABLE VALUES ('PelytE', ' AuSra','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');# c) Z" ^) o: N9 D" l
INSERT INTO NEW_TABLE VALUES ('MeSkaitE', ' Viktorija','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
x- h; `& K) h2 r3 O. E6 KINSERT INTO NEW_TABLE VALUES ('Vilkas', ' K臋stas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
' j5 F2 i$ g! U2 RINSERT INTO NEW_TABLE VALUES ('KrUmas', ' ArUnas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');; h( R7 `1 @. {" q
INSERT INTO NEW_TABLE VALUES ('Medis', ' ArtUras','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');! W. s# f0 }" h# x
INSERT INTO NEW_TABLE VALUES ('ObuolaitE', 'Ingrida','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');2 m; a! \% g/ X2 N5 z3 h/ A
INSERT INTO NEW_TABLE VALUES ('GaidauskienE', 'EglE','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');9 [. J4 \. y) G
INSERT INTO NEW_TABLE VALUES ('ZuvienE', 'Monika','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');" m+ i4 L8 \ o8 h, S
INSERT INTO NEW_TABLE VALUES ('MorkaviCius', 'Tadas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
+ w4 x; v; Y* X7 Q/ a6 [3 ]INSERT INTO NEW_TABLE VALUES ('DeSrytE', 'Kornelija','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
7 h: d* C( X: D- |' R& a$ ]INSERT INTO NEW_TABLE VALUES ('SUris', 'Aurimas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
) r, g7 x: D5 v1 `0 m. AINSERT INTO NEW_TABLE VALUES ('BandelE', 'Greta','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');& N- W+ B- i: m
INSERT INTO NEW_TABLE VALUES ('RUkaviCius', 'Edgaras','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');6 i1 v1 Z- b8 ]- Q: C) ?
INSERT INTO NEW_TABLE VALUES ('Kreivauskas', 'Mantas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
5 W+ z) C! M0 \ T% fINSERT INTO NEW_TABLE VALUES ('AklaitE', 'Diana','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
7 u Q! L5 v/ Y8 h, [5 RINSERT INTO NEW_TABLE VALUES ('Nekalbys', 'Rytis','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
. ~1 [$ P) x9 c2 G( g0 xINSERT INTO NEW_TABLE VALUES ('Telefonas', 'Deividas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
- Y2 _; ]. Y6 ^- @. PINSERT INTO NEW_TABLE VALUES ('LentaitE', 'Gabija','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
U2 M2 e9 Y3 ^ @, m; UINSERT INTO NEW_TABLE VALUES ('Viniauskas', 'Hermanas','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');
( }+ `" L& ~3 ?' cINSERT INTO NEW_TABLE VALUES ('MALKA', 'TOMAS','KAUNAS UNIVERSITY OF TECHNOLOGY', 'MEDICINE');! K) f9 J: M) M5 O2 A
: A$ ^- B' Y* ?/ { q9 a
' Y. e) Y0 |! Q+ BCREATE SEQUENCE S_STUD;
8 f* L# K# R4 \8 ^1 j. eCREATE SEQUENCE S_DOC;! y4 D+ d$ t O. Q9 m! r% k$ e
CREATE SEQUENCE S_ACCEPT;: p3 a& A) b" K0 x/ a7 b
- U: k6 [# i! k$ J
) m' [8 r1 T# ^0 `CREATE OR REPLACE PROCEDURE INSERT_DATA(HOW_MANY_RECORDS NUMBER) IS3 v2 H @, y/ o! o% T5 k& K
BEGIN* H! l) k& @5 E8 m! n! L9 D* S
0 L8 n+ }9 W! w) l1 q5 O
/*
/ j3 Y' s' |) S9 j1 TABLE STUDENT
2 P; d" h6 \* z/ Z. k*/
t! m. B- Y+ n1 z5 E1 x. U0 v7 y! O2 A/ r
FOR I IN 1..HOW_MANY_RECORDS LOOP
* ~8 r) [, [% G4 L! X% C5 X8 Y7 o. I; `6 @5 h7 @% W$ [1 X
DECLARE
: T/ e$ L0 O: q- G1 C' W* t7 MF_NAME_VALUE VARCHAR2(20);
) p+ S1 E0 |# g! v$ Z; s4 k0 FL_NAME_VALUE VARCHAR2(20);; @* R# g! j6 n; ^1 ~
BORN_DATE_VALUE DATE;
. ?4 g4 D1 O- E- z0 R" i2 n! PBEGIN
# v9 v9 G: }% @/ a) ~) E$ QSELECT F_NAME INTO F_NAME_VALUE) [# X% o" u J& P l3 A8 ^- n
FROM, h2 ?2 p5 U/ q* M
(SELECT F_NAME FROM NEW_TABLE c; \, q, x- U) @* v a
ORDER BY dbms_random.value)1 R9 f( J }% u7 l u
WHERE rownum = 1;( \8 ]; f$ b5 n
SELECT L_NAME INTO L_NAME_VALUE+ o) z9 @3 U' E9 m
FROM& Z' y4 M/ N; k& l
(SELECT L_NAME FROM NEW_TABLE+ w# P }& B* Y5 N8 K
ORDER BY dbms_random.value)
! Z$ e2 b0 ~) o, a3 {& cWHERE rownum = 1;
- i. H5 } x; O" M3 ~BORN_DATE_VALUE := TO_DATE(TRUNC(
9 a( T q, @8 t7 V) TDBMS_RANDOM.value(& `+ c% I! W. P& _' T: p# x
TO_CHAR(date '1870-01-01','J')* ~, s) r" @2 ?9 P
,TO_CHAR(date '1995-01-01','J')
% v/ ~; w- [) d: P( R. N8 R$ H)),'J');7 e9 J; r7 e0 F4 d9 m7 u
INSERT INTO STUDENT(ID_STUDENT,F_NAME,L_NAME,BORN_DATE), l) }: A* ~ R7 X6 O
VALUES (S_STUD.NEXTVAL,F_NAME_VALUE,L_NAME_VALUE,BORN_DATE_VALUE);# ? F u3 R5 ^+ P ?5 p" F" ~
END; ) h( C7 O5 e O0 Z
-------------------------------------------------------------------' c8 V/ _# [0 Q# G( A- W# p
/*" N6 ^: a* H0 y) \9 m
2 TABLE DOCUMENTS
9 H! l+ Y9 m) v: j3 Y0 s: d' E*/9 W c7 `0 B) C2 v8 U* k5 K6 o
DECLARE
# D5 F) r% V: M8 I1 jENTERED_DATE_VALUE DATE;. [( {& X5 b4 p/ Y
FINISHED_DATE_VALUE DATE;; n1 w) {* Z3 u! D! c
BEGIN8 D2 E+ s/ \$ }% Y% j+ K. z
ENTERED_DATE_VALUE :=TO_DATE(TRUNC(
6 n! o' V' W% mDBMS_RANDOM.value(
3 T; A8 G7 v) Z( p# ~3 c- n2 }TO_CHAR(date '1870-01-01','J')
5 \3 C4 X, i# ],TO_CHAR(date '1995-01-01','J')
, q0 H0 s- C+ T/ n S ])),'J');
f1 ~, l0 l/ M% @9 A3 nFINISHED_DATE_VALUE :=TO_DATE(TRUNC(
) _( F# l0 k. F2 KDBMS_RANDOM.value(# j t) ~* q: z0 N
TO_CHAR(date '1870-01-01','J')
$ q. x! l0 U! x3 y,TO_CHAR(date '1995-01-01','J')
2 ~# S o% I: O( q' n)),'J');
. Y8 z, K$ c2 t% T0 c' R" mINSERT INTO DOCUMENTS(DOC_ID,ENTERED, FINISHED, ID_STUDENT)
3 Z( I6 B4 \- z( wVALUES(S_DOC.NEXTVAL,ENTERED_DATE_VALUE, FINISHED_DATE_VALUE, S_STUD.CURRVAL);
. o3 c1 m: D$ p" U/ ~. [END; - F# ~* k* v$ C& E% N8 [
------------------------------------------------------------------
" K7 w8 u- |. e$ v) }! I/ n; k/*/ _( u* B/ e* s
3 TABLE ACCEPTANCE) i* Y. e) ^$ f; ]- s
*/
% S" W, @; E# i9 e- T0 k8 xDECLARE
! o. i& |0 x$ x1 p ZUNIVERSITY_NAME_VALUE VARCHAR2(50);
2 {% y* ^2 x- I5 |4 K XFACULTY_NAME_VALUE VARCHAR2(30);1 E! w& h0 R$ u8 ]& c u
BEGIN 9 p2 b' y1 M, J" O5 a0 T3 j
SELECT UNIVERSITY INTO UNIVERSITY_NAME_VALUE" q- r' M; J3 |
FROM, T9 e, f* z* C; b
(SELECT UNIVERSITY FROM NEW_TABLE
: t5 b# L' N4 N8 @; bORDER BY dbms_random.value)
1 w5 c0 p7 g9 w- q% Q+ S$ L @WHERE rownum = 1;
2 {* [! e# @8 p# N E3 r0 ^SELECT FACULTY_NAME INTO FACULTY_NAME_VALUE7 K* n; ~" E3 m8 H( {
FROM
6 K+ J$ M" Q; l* I$ K(SELECT FACULTY_NAME FROM NEW_TABLE; E8 B5 f7 z- n; m! v
ORDER BY dbms_random.value)1 o, b; V2 t* i# Y0 j0 {. a( V
WHERE rownum = 1;
" ]+ l6 v' K% J$ bINSERT INTO ACCEPT_RESULT(DETAIL_ID,UNIVERSITY_NAME,FACULTY_NAME,DOC_ID)% E) F; B. S7 ?
VALUES (S_ACCEPT.NEXTVAL,UNIVERSITY_NAME_VALUE, FACULTY_NAME_VALUE, S_DOC.CURRVAL);
, H( r: Z! ]7 ]: j( jEND;
' j: V2 e$ G# w2 y' \8 @1 Y6 AEND LOOP;
3 H4 t0 X G! H2 Z1 sEND;) V2 z; ] p" d0 F$ a& W/ E5 R
/. J; T5 t, P% ]) m! u$ y6 _
EXECUTE INSERT_DATA(15); |
|