检查plsql中的记录IS NOT NULL

编程入门 行业动态 更新时间:2024-10-24 14:19:05
本文介绍了检查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

本文发布于:2023-07-22 10:34:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1186740.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:plsql   NULL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!