如下返回表类型的函数
create table fn_record_test(pi_num number)
return tb_test%rowtype
as
cursor cur_test is select * from tb_test where id=pi_num;
l_rec tb_test%rowtype;
begin
open cur_test ;
fetch cur_test into l_rec ;
close cur_test ;
return l_rec ;
end;调用函数
declare
l_rec tb_test%rowtype;
begin
l_rec := fn_record_test(15);
if 请问这里如何判断l_rec变量是否存在记录呢? then
dbms_out.put_line('ok');
end if;
end;
create table fn_record_test(pi_num number)
return tb_test%rowtype
as
cursor cur_test is select * from tb_test where id=pi_num;
l_rec tb_test%rowtype;
begin
open cur_test ;
fetch cur_test into l_rec ;
close cur_test ;
return l_rec ;
end;调用函数
declare
l_rec tb_test%rowtype;
begin
l_rec := fn_record_test(15);
if 请问这里如何判断l_rec变量是否存在记录呢? then
dbms_out.put_line('ok');
end if;
end;
是 function吧???if l_rec.id=15 then貌似你那里只能返回第一条记录。
sqlcode和sqlerror在项目中规范。
if l_rec.id=15 then
dbms_out.put_line('ok');
end if;
2. 调运函数的块中, 用ROWTYPE中的ID 是否为空来判断
3. 异常的处理 不规范,这样
4. 处理流程 可以优化