本文介绍了检查plsql中的记录IS NOT NULL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个函数可以返回类型为my_table%ROWTYPE的记录,在调用方中,我可以检查返回的记录是否为空,但是PL/SQL会抱怨if语句
I have a function which would return a record with type my_table%ROWTYPE, and in the caller, I could check if the returned record is null, but PL/SQL complains the if-statement that
PLS-00306:"IS NOT NULL"调用中参数的数量或类型错误
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列即可.
As far as I know, it's not possible. Checking the PRIMARY KEY or a NOT NULL column should be sufficient though.
您可以检查v_record.row_id IS NULL.
但是,当找不到记录时,您的函数将抛出NO_DATA_FOUND异常.
Your function would throw a NO_DATA_FOUND exception though, when no record is found.
更多推荐
检查plsql中的记录IS NOT NULL
发布评论