MySQL库数据库存储过程
我有一个存储过程,它应该从虚构的图书馆数据库中借书,该过程应该检查该书是否可用,然后检查用户是否超过其限制,然后减少我知道的图书表中所选图书的可用拷贝数,这也不是我在返回一个字符串来判断这个过程是否顺利执行之前,如何布局数据库并创建一个新的贷款。程序如下:MySQL库数据库存储过程,mysql,database,phpmyadmin,Mysql,Database,Phpmyadmin,我有一个存储过程,它应该从虚构的图书馆数据库中借书,该过程应该检查该书是否可用,然后检查用户是否超过其限制,然后减少我知道的图书表中所选图书的可用拷贝数,这也不是我在返回一个字符串来判断这个过程是否顺利执行之前,如何布局数据库并创建一个新的贷款。程序如下: delimiter $$ create procedure BorrowBook(in theBookID int, in theUserID int) begin declare lim int; declare num int; decl
delimiter $$
create procedure BorrowBook(in theBookID int, in theUserID int)
begin
declare lim int;
declare num int;
declare loanNumber int;
declare copyNumber int;
set lim = (select Readers.Limit from Readers where Readers.id = theUserID);
set num = (select Count(*) from Loans where Loans.UserID = theUserID);
set loanNumber = (select Count(*) from Loans) + 1;
set copyNumber = (select NumberAvailable from Book where Book.id = theBookID);
if(copyNumber > 0)
then
if(num<lim)
then
insert into Loans values(loanNumber, theBookID, theUserID, curDate(), 0);
commit;
update Book set Book.NumberAvailable = Book.NumberAvailable - 1 where Book.id = theBookID;
select 'Succesful Update';
else
rollback;
select 'Borrow limit reached';
end if;
else
rollback;
select 'No copies available';
end if;
end $$
它出现了错误
#1312 - PROCEDURE reddurrant_com.BorrowBook can't return a result set in the given context
有人能告诉我为什么它不工作吗?欢呼声可能相关:您是否在多选模式下操作?客户端\u多\u结果处于打开状态:
#1312 - PROCEDURE reddurrant_com.BorrowBook can't return a result set in the given context