sql没有正确结束三个表的联接

时间:2019-04-15 07:17:59

标签: oracle join plsql database-cursor

由于连接三个表进行查询而导致的SQL错误enter code here,使用游标进行迭代的学生使用通用值来获取保留书

我试图以相反的顺序加入他们

MEMBER PROCEDURE display_check_out(id varchar2)

IS
 cursor  curss 
IS 
select * from memberstable  AS m JOIN  reserv AS r  ON m.member_id= r.membs 

JOIN bookstable AS  b ON r.bookid=b.isbn

 where r.membs= id;

begin

 for curs in curss

loop

DBMS_OUTPUT.PUT_LINE('Student Id: '||curs.m.member_id);


 DBMS_OUTPUT.PUT_LINE('  Name: ' || curs.m.full_name||' Gender: '||curs.m.gender);
 DBMS_OUTPUT.PUT_LINE(' Tel:'||'mobile: '||curs.m.telephone.mobile||'office: '|| curs.m.telephone.office);

` FOR j IN 1..curs.b.COUNT LOOP

 DBMS_OUTPUT.PUT_LINE('-------------------CheckedOutBooks--------------------------');

  DBMS_OUTPUT.PUT_LINE('ISBN: '||curs.b.isbn);

           DBMS_OUTPUT.PUT_LINE('Publication Date: 
'||curs.b.date_of_publication);

           FOR k IN 1..curs.b.authors.COUNT LOOP

           DBMS_OUTPUT.PUT_LINE('Authors: '||curs.b.authors(k));
           END LOOP;
           DBMS_OUTPUT.PUT_LINE('Checked out time: '||curs.checkout);
           END LOOP;
           END LOOP;
           END display_check_out;
           end;
           /

我希望列出用户详细信息并 用户预订的图书清单

1 个答案:

答案 0 :(得分:0)

尝试像这样定义光标:

CURSOR curss
   IS
      SELECT *
        FROM memberstable m
             JOIN reserv r ON m.member_id = r.membs
             JOIN bookstable b ON r.bookid = b.isbn
       WHERE r.membs = id;

似乎最后也不需要END

代替:

END display_check_out;
end;
/

更像这样:

END display_check_out;
/