我再解释一下我的程序,@ISDN是书号,@TotalStock是输入总共要录入的书的总量.编号BookID根据总量自动增加用@TotalStock来控制增加的本数.然后再添加@TotalStock条记录.
这是我的存储过程,昨天又写了一段代码,现在语法出错了
显示:在关键字 'insert' 附近有语法错误。希望高手看到后能回复一下,谢谢
create proc Insert_BookStateInfo
@ISDN varchar(10),
@TotalStock integer
as
begin tran
declare @State varchar(10),@BookID varchar(13),@i integer
set @i=1
while (@TotalStock>=@i)
begin
set @State='归还'
set @BookID=left(BookID,10)+(convert(varchar(3),(select max(convert(int,right(BookID,len(BookID)-10)))+1 from BookStateInfo where ISDN='AT-001-000' ))
insert into BookStateInfo(ISDN,BookID,State)
values(@ISDN,@BookID,@State)
set @i=@i+1
end
update BookInfo
set TotalStock=isnull(TotalStock,0)+@TotalStock
from BookInfo as a ,BookStateInfo as b
where a.ISDN=b.ISDN and b.ISDN=@ISDN
commit