【问题标题】:Check UDT Table For Nullability In Oracle Procedure在 Oracle 过程中检查 UDT 表的可空性
【发布时间】:2015-11-24 04:51:23
【问题描述】:
type NumberTable is table of number index by binary_integer;
create procedure TestNumberTable
(
p_NumTable IN NumberTable Default Cast(Null as NumberTable)
)
as
/* code body */
两个问题:
如何在存储过程中检查参数是否可以为空?
如何找到 count(*) [即存储过程中参数的行数?
【问题讨论】:
标签:
oracle
user-defined-types
【解决方案1】:
您不能使用“二进制整数索引”创建 UDT,您可以这样做:
create type NumberTable is table of number;
Q1:“可空性”是指“是否为空”?如果是这样,这将起作用:
create procedure TestNumberTable
( p_NumTable IN NumberTable Default null)
as
if p_NumTable is null then
...
Q2:计数:
create procedure TestNumberTable
( p_NumTable IN NumberTable Default null)
as
dbms_output.put_line ('count is '||p_NumTable.count);
...