0

これは架空の例です。実際の問題は、連想配列に存在する場合、値に基づいてさまざまな列を更新することです。以下は、ORA-06550 および ORA-01747 をスローします。エラーの修正にご協力ください。

declare
   type MONTH_TYPE is table of varchar2(20) index by binary_integer;

   month_table   MONTH_TYPE;
   mon varchar2(20);
 begin
   month_table(1) := 'Jan';
   month_table(2) := 'Feb';

   select case when month_table.exists(1) then 'found' else 'not found' end into mon from dual;
 end;
4

1 に答える 1

3

existsSQL ステートメントからPL/SQL 関数を呼び出すことはできません。次の必要がある場合は、コレクション内のを参照できます。

declare
   type MONTH_TYPE is table of varchar2(20) index by binary_integer;
   month_table   MONTH_TYPE;
   mon varchar2(20);
 begin
   month_table(1) := 'Jan';
   month_table(2) := 'Feb';
   select case when month_table(1)='Jan' then 'found' else 'not found' end
        into mon from dual;
end;

existsまたは、 PL/SQL内で使用できます:

declare
   type MONTH_TYPE is table of varchar2(20) index by binary_integer;

   month_table   MONTH_TYPE;
   mon varchar2(20);
 begin
   month_table(1) := 'Jan';
   month_table(2) := 'Feb';

   mon := case when month_table.exists(1) then 'found' else 'not found' end;
end;

あなたのコメントから、データベースの種類が進むべき道のように思えます:

SQL> create type MONTH_TYPE is table of varchar2(20);

次に、SQL で次の中から選択できます。

declare
   month_table   MONTH_TYPE := MONTH_TYPE();
   mon varchar2(20);
 begin
   month_table.extend;
   month_table(1) := 'Jan';
   month_table.extend;
   month_table(2) := 'Feb';

   update some_table
   set x = 1
   where month in (select column_value from table(month_table));
end;
于 2013-05-23T17:25:49.580 に答える