oracle函数怎么调用 有哪些方法?比如这有个函数 但是我不会调用?
create or replace function fun_test return t_test%rowtype is
l_test t_test%rowtype;
cursor c_test is select * from t_test;
begin
open c_test;
fetch c_test into l_test;
while c_test%found loop
dbms_output.put_line('name:'||l_test.name||'id:'||l_test.id);
fetch c_test into l_test;
return l_test;
end loop;
close c_test;
end ;
create or replace function fun_test return t_test%rowtype is
l_test t_test%rowtype;
cursor c_test is select * from t_test;
begin
open c_test;
fetch c_test into l_test;
while c_test%found loop
dbms_output.put_line('name:'||l_test.name||'id:'||l_test.id);
fetch c_test into l_test;
return l_test;
end loop;
close c_test;
end ;
begin
t:=fun_test;
end;
print t;
过程是以一个独立语句的形式调用。
在pl/sql块中调用fun_test如下:
DECLARE
t_row t_test%ROWTYPE;
BEGIN
t_row := fun_test; --作为赋值语句的右值表达式
dbms_output.put_line('name:' || t_row.name || 'id:' || t_row.id);
END;
/