0


たとえば 、クエリを使用して同じプロシージャ内のプロシージャ パラメーターにアクセスする方法: この手順を参照してください。

procedure game(left in tab.left%type,right in tab.right%type,...)  
is  
--some local variables  
begin  
merge into tgt_table
using subquery --(here is what i need to use the parameters)  
on some condition  
when matched then  
update the tgt table  
when not matched then  
insert the table;  
end game; 

上記の手順とマージステートメントでは、パラメーター値をテーブル参照として使用し、それらの値を使用して、指定された条件に基づいてテーブルを更新または挿入するようなクエリが必要です。

お願い助けて。前もって感謝します

4

2 に答える 2

1

パラメータが使用するテーブルを定義している場合は、動的 SQL を使用する必要があります。次のようなものです。

procedure game(left in tab.left%type,right in tab.right%type,...)  
is  
    --some local variables  
    l_sql long;
begin  
    l_sql := 'merge into tgt_table'
             || ' using ' || left
             || ' on some condition'  
             || ' when matched then'  
             || ' update ' || right
             || ' when not matched then'  
             || ' insert the table';  
    execute immediate l_sql;
end game;

ただし、使用するテーブルに応じて条件句、更新句、および挿入句をすべて変更する必要があるため、やるべきことはまだたくさんあります。私は、この調達が実際に特に役立つとは確信していません。

于 2009-03-02T11:49:58.910 に答える