我有一个函数会返回一个类型为 my_table%ROWTYPE
的记录,在调用者中,我可以检查返回的记录是否为空,但是 PL/SQL 提示 if 语句
PLS-00306: wrong number or types of arguments in call to 'IS NOT NULL'
这是我的代码:
v_record my_table%ROWTYPE;
v_row_id my_table.row_id%TYPE := 123456;
begin
v_record := myfunction(v_row_id)
if (v_record is not null) then
-- do something
end if;
end;
function myfunction(p_row_id in my_table.row_id%TYPE) return my_table%ROWTYPE is
v_record_out my_table%ROWTYPE := null;
begin
select * into v_record_out from my_table
where row_id = p_row_id;
return v_record_out;
end myfunction;
谢谢。
最佳答案
据我所知,这是不可能的。检查 PRIMARY KEY
或 NOT NULL
列应该足够了。
您可以查看v_record.row_id IS NULL
.
你的函数会抛出 NO_DATA_FOUND
但是,当没有找到记录时异常(exception)。
关于plsql - 检查 plsql 中的记录 IS NOT NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7207894/