存储过程与存储函数
一、语法
create or replace PROCEDURE PROCEDURE_name
as
begin
---
end;
一、上面是基本的语法,下面写一个不带参数的存储过程
create or replace PROCEDURE getbrryCount
AS
brryCount INT;
BEGIN
SELECT COUNT(*) INTO brryCount FROM zy_brry;
DBMS_OUTPUT.PUT_LINE('zy_brry表的共有记录数:'||brryCount);
END ;
二、存储过程的调用,方法有两种1.exec的调用方法 2.plsql语法的调用
1.exec getbrryCount();
2.begin
getbrryCount();
end;
三、带参数的存储过程
create or replace PROCEDURE risezhye(id in number)
AS
--定义参数
newzhye ms_brzh.zhye%type;
BEGIN
SELECT zhye into newzhye from ms_brzh where brid=id ;
update ms_brzh set zhye=zhye+10 where brid=id;
DBMS_OUTPUT.PUT_LINE('新的zhye为:'||newzhye);
END ;
--执行 一下
BEGIN
risezhye(3196703);
END;