回答

收藏

Oracle 11g-运行PL / SQL游标

技术问答 技术问答 203 人阅读 | 0 人回复 | 2023-09-12

我试图在Oracle 11g上运行此代码,这给了我下面的错误。我似乎无法正确处理。
! Z; l6 N' N9 m' wDECLARE
% s$ r5 ~5 {  @0 c- S    CURSOR bookcursor IS+ \5 H# U& m: Q/ m/ b" ?$ a
    SELECT btName, BookCopy.Isbn, pubName, dateDestroyed
1 R5 v2 g4 w$ }5 F6 J$ {) W" s      FROM booktitle bt
* j0 B9 e6 T7 P4 g$ f      JOIN publisher p0 d$ [$ L/ P1 W
        ON bt.pubId = p.pubId
3 f9 N$ t  x) X! S3 }      JOIN bookcopy bc4 P( b* |  m$ _, h. d' E- s* O
        ON bt.Isbn = bc.Isbn 8 _" j, K: G3 |: G
     WHERE datedestroyed IS NULL% ]  c0 Z* W/ `
    ;
9 ?; e7 L% a9 y' H0 U0 y* K    bookcursorrec bookcursor%ROWTYPE;
, o4 M9 z" q& w7 a" WBEGIN! m( @  h) `7 g, D; J" b, c* x
    OPEN bookcursor;5 ^5 P: V9 _2 p! U
    LOOP
# f" {. x; s  l2 Q: }        FETCH bookcursor INTO bookcursorrer;( B& ], s2 [% X  i, R4 `( [/ P
        EXIT WHEN bookcursor%NOTFOUND;+ [  @0 D3 U- o& w) ?) G& \
        dbms_output.put_line( 'ISBN: ' ||bookcursorrec.isbn
8 e. _  m7 P$ s( C# L                              || ' - Book Name: ' || bookcursorrec.btname* P/ x# \* G8 k! }. }" u" q0 R4 e
                              || ' - Publisher: ' || bookcursorrec.pubname );
0 E8 _1 T9 B- N( d3 v/ X+ c# t    END LOOP;
* t; X+ @5 E0 m+ r+ K2 J, s. `+ e    CLOSE bookcursor;
" {3 v7 ]2 J9 s! TEND;% ^) p& t0 u& ]* g  M$ \6 A9 c

* K8 z' q' A1 d# @ERROR at line 3:$ R4 I0 H$ q/ Z0 u4 f) H
ORA-06550: line 3, column 20:
$ x. e5 s% L* G' ?5 @. C; HPL/SQL: ORA-00904: "BOOKCOPY"."ISBN": invalid identifier% Q2 x4 z6 `* k* N; G! G, z" b3 A4 U
ORA-06550: line 3, column 5:
3 y( a+ x6 A: |, S) GPL/SQL: SQL Statement ignored8 r- h6 u% c( G# w$ W; a& V
ORA-06550: line 2, column 12:$ o% P* u% N' }3 \! P* V# f
PLS-00341: declaration of cursor 'BOOKCURSOR' is incomplete or malformed; r6 R) _) |6 ]1 O
ORA-06550: line 11, column 19:9 R/ M* u; A  R
PL/SQL: Item ignored; ?% w' W  s1 g$ Z) A# V# Y
ORA-06550: line 15, column 31:
! z4 t' A" ?* V% B  B' RPLS-00201: identifier 'BOOKCURSORRER' must be declared7 ?# ]6 V. m# Z
ORA-06550: line 15, column 9:- r' K$ w- ?9 b7 l; _8 D
PL/SQL: SQL Statement ignored# ^* B' Q- w( D& S/ w
ORA-06550: line 17, column 42:% {& d+ X  p3 j4 ~  b
PLS-00320: the declaration of the type of this expression is incomplete or
+ x8 n4 X5 I0 v, A! {* l4 }malformed
& M% R( @/ }: j/ g- ~7 PORA-06550: line 17, column 9:' ~% ^8 H6 A, J% _6 |
PL/SQL: Statement ignored' M5 ]# y+ @) R% D
您能指出我出什么问题吗?我似乎无法理解什么地方出了问题2 @% A8 U- d/ g
谢谢,布莱恩
6 r  Q% L8 L6 V( E$ ]# Z' t                / M9 _0 m6 L$ O! K
解决方案:
分享到:
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则