数据库存储过程

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 过程名称();

posted @ 2017-07-23 15:05  by-lhc  阅读(231)  评论(0)    收藏  举报