Проверка таблицы UDT на обнуляемость в процедуре Oracle

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(*) [т.е. количество строк] параметра внутри хранимой процедуры?


person Atif    schedule 29.05.2012    source источник


Ответы (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);
  ...
person Tony Andrews    schedule 29.05.2012