首页 > 数据库技术 > 详细

数据库存储过程

时间:2017-07-23 16:00:43      阅读:230      评论:0      收藏:0      [点我收藏+]

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

数据库存储过程

原文:http://www.cnblogs.com/by-lhc/p/7224711.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!