PL/SQL学习笔记-函数

先看程序

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
posted @ 2009-08-05 19:21  liulun  阅读(738)  评论(0编辑  收藏  举报