带游标的plsql过程

问题描述 投票:0回答:1

enter image description here

对于使用ORACLE PLsql的firsrt部分步骤2:对于作者姓氏所写的每本书,将其书中的所有ISBN更改为第二个程序参数?

如何获取和更改该书的ISBN?

set serveroutput on
create or replace procedure changeISBN(Last_Name varchar(100),ISBN int)
no_book exception;
no_author exception;
cursor c1 is 
select *  from book where book.idAuthor= Auhtor.idAuthor and Author.LastName =Last_Name;
if 
oracle plsql procedure cursors
1个回答
0
投票

我想您需要在下面-

create or replace procedure changeISBN(P_Last_Name varchar2
                                      ,P_ISBN number
                                      ,P_message out varchar2)
Begin
    UPDATE book
    SET ISBN = P_ISBN
    WHERE EXISTS (SELECT 1
                  FROM Auhtor
                  WHERE LastName = P_Last_Name
                  AND book.idAuthor= Auhtor.idAuthor);
    P_message := 'Successfully Updated';
EXCEPTION
     when others then
             P_message := 'Update Failure';
END;
© www.soinside.com 2019 - 2024. All rights reserved.