Sql Server 存储过程报错 为不是函数的对象 'account' 提供了参数。
create procedure bank_pro @ids varchar(10)
as
declare
@bid varchar(10),
@bname varchar(20),
@baddr varchar(30),
@bcity varchar(30),
@sums money,
@counts int,
@SQL varchar(500)
declare @curs cursor
--select @sums = sum(a_balance) from account where a_bank_num = @ids;
--select @counts=count(a_bank_num) from account where a_bank_num=@ids
set @curs=cursor scroll dynamic
for
select b.b_id,b.b_name,b.b_address,b.b_city,sum(a.a_balance),count(a.a_id)
from bank b left join account a on b.b_id=a.a_bank_num
where b.b_id = @ids
group by b.b_id,b.b_name,b.b_address,b.b_city
open @curs
fetch next from @curs into @bid,@bname,@baddr,@bcity,@sums,@counts
while(@@fetch_status=0)
begin
print '编号 '+'名称 '+'地址 '+'城市 '+'总金额 '+'账户数 '
print @bid+@bname+@baddr+@bcity+convert(varchar(20),@sums)+' '+convert(varchar(20),@counts)
fetch next from @curs into @bid,@bname,@baddr,@bcity,@sums,@counts
if(@sums<1000000)
begin
set @SQL='insert into account() values(''1010'',''天天'',''60000'',''2012-11-23'','''+@ids+''')'
print('该银行总金额少于一百万')
print(@SQL+'已执行')
exec(@SQL)
end
if(@counts=0)
-- else if(@counts=0)
begin
print('该银行不存在用户')
set @SQL='delete from bank with b_id='''+@ids+''''
print(@SQL+'已执行')
print('该银行已被删除')
exec(@SQL)
end
end;
繁星淼淼
相关分类