【问题标题】: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 */

两个问题:

  1. 如何在存储过程中检查参数是否可以为空?

  2. 如何找到 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);
      ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-15
      • 1970-01-01
      • 2011-05-17
      • 1970-01-01
      • 2017-05-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多