当前位置:Gxlcms > 数据库问题 > 数据库存储过程

数据库存储过程

时间:2021-07-01 10:21:17 帮助过:12人阅读

1.创建存储过程

create procedure 过程名称 ([参数1,参数2,...])

as

<pl/sql>;

create procedure transfer(inAccount INT, outAccount INT, amount FLOAT)
as declare
    totalDeposit FLOAT;
begin
    select total into totalDeposit from account where accountnum=outAccount;
    if totalDeposit is null then
        rollback;
        return;
    end if;
    if totalDeposit < amount then
        rollback;
        return;
    end if;
    update account set total=total-amount where accountnum=outAccount;
    update account set total=total+amount where accountnum=inAccount;
    commit;
end;

2.重命名存储过程

alter procedure 过程名称1 rename to 过程名称2;

3.执行存储过程

call/perform procedure 过程名称 ([参数1,参数2,...]);

4.删除存储过程

drop procedure 过程名称();

数据库存储过程

标签:tran   bsp   alter   float   turn   com   into   lte   for   

人气教程排行