帐户(编号,姓名,余额,建立日期,储蓄所编号) 
储蓄所(编号,名称,地址,人数,所属城市)
借贷(帐户,借贷类型,金额,日期)
根据上面基本表的信息定义一个存储过程,完成下面功能:
入口参数:储蓄所编号
1 显示储蓄所信息
2 如果没有帐户,删除该储蓄所记录
3 如果帐户余额总额低于100万元,开一个新帐户,。要求用一个存储过程做,我用的是sqlserver2000做的
create procedure my_procs (@num int)asif (@num not in (select 储蓄所编号 from 帐户))begin delete from 储蓄所 where 储蓄所.编号=@num
 print '该储蓄所里没有帐户存在已经被删除'
end
else 
begin
select * from 储蓄所 
where 储蓄所.编号=@num
enddeclare @i int
select @i=1while exists(select 余额 from 帐户 where 储蓄所编号 = @num and 余额 <1000000)
begin 
insert into 帐户(姓名,余额,建立日期,储蓄所编号) values('ss','200','2005-5-5',3)
set @i = @i + 1
if(@i>select count(*) from 帐户 where 储蓄所编号 = @num and 余额 <1000000 )
break
else
continue
end
return
提示select语句有错误,就是红色那句附近 大家帮我看看,错哪了啊,

解决方案 »

  1.   

    create procedure my_procs (@num int) 
    as 
    set nocount on 
    if not exists(select 1 from 帐户 where 编号=@num ) 
    begin 
    delete from 储蓄所 where 储蓄所.编号=@num 
    print '该储蓄所里没有帐户存在已经被删除' 
    end 
    else 
    begin 
    select * from 储蓄所 
    where 储蓄所.编号=@num 
    end declare @i int 
    select @i=1 if  exists(select 余额 from 帐户 where 储蓄所编号 = @num and 余额 <1000000) 
    begin 
    insert into 帐户(姓名,余额,建立日期,储蓄所编号) 
    values('ss','200','2005-5-5',3) 
    end
    else 
    begin
    --显示用户信息
     select * from 帐户
    end return
      

  2.   

    break 
    else 
    continue 
    end 
    数据库中没有这种表示方法,
    只有EXIT WHEN<退出条件>;
    和IF<退出条件>THEN 
    EXIT;
    END IF;
    这两种退出循环的形式。