您的位置:首页 > 数据库

PL/SQL学习笔记-函数

2009-08-05 19:21 453 查看
先看程序

create or replace function get_content
(v_title in xland.title%type,v_content out xland.content%type)
return number
is
v_state number;
begin
select state,content into v_state,v_content from xland where title = v_title;
return v_state;
end get_content;


参数可分为输入参数和输出参数
函数还有返回值
is和begin之间是定义部分
函数其实与过程类似

看调用过程

declare
xland varchar2(222):= 'xland';
content varchar2(2048);
out_v number;
begin
out_v := get_content(xland,content);
dbms_output.put_line(to_char(out_v));
dbms_output.put_line(content);
end;


定义了三个变量
前两个是函数的参数
后一个是返回值

看输出结果

0
xland is my name


删除一个过程

drop function yourfuncname
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: