procedure
Posted cyf18
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了procedure相关的知识,希望对你有一定的参考价值。
定义:
create or replace procedure 名称
(param1 in number, param2 out varchar2)
is
begin
...程序块
end
/
create or replace procedure getApple
(useCode in number, apple out number)
is
begin
select apple into apple from t_user where user_code=userCode;
end;
/
var number userCode;--声明变量
exec :userCode:=121;--变量赋值
exec getApple(:userCode);//调用procedure
多个参数只对某一个赋值:
create or replace procedure addUser
(
useCode in number default user_seq.nextval,
user_name in varchar2 default ‘小明‘,
age in number default 20,
user_birth_day in date default sysdate,
apple in number default 3
)
is
begin
select apple into apple from t_user where user_code=userCode;
end;
/
调用:
exec addUser(3,‘小王’,apple=>8);
查看procedure内容:
select text from user_source where name=‘ADDUSER‘;
以上是关于procedure的主要内容,如果未能解决你的问题,请参考以下文章