I have the following stored procedure:
我有以下存储过程:
Procedure MyProc
(
Output1 OUT VARCHAR2
Output2 OUT VARCHAR2
Output3 OUT VARCHAR2
)
IS
BEGIN
SELECT mt.value
from myTable mt
join all_arguments aa on aa.argument_name=mt.key;
END myProc;
How can I put mt.Value into the corresponding argument (i.e. Output1
, output2
, or output3
?)
如何将mt.Value放入相应的参数(即Output1,output2或output3?)
EDIT: More details needed
编辑:需要更多细节
So, I have my output parameters Output1
, Output2
, and Output3
, and my table contains the following>
所以,我有输出参数Output1,Output2和Output3,我的表包含以下>
CREATE TABLE myTable ( key, value ) AS
SELECT 'Output1', 'Result1' FROM DUAL UNION ALL
SELECT 'Output2', 'Result2' FROM DUAL UNION ALL
SELECT 'Output3', 'Result3' FROM DUAL;
So, at the end, I want to return Result1
in Output1
, Result2
in Output2
, and Result3
in Output3
所以,最后,我想返回Output1中的Result1,Output2中的Result2和Output3中的Result3
The purpose is to have a very flexible procedure, as the number of returned values is huge, can be changed, and I want to add at least lines as possible.
目的是有一个非常灵活的过程,因为返回值的数量很大,可以更改,并且我想尽可能添加至少行。
Right now, when, I add an output, I need to add an output in my list of output parameters (This one cannot be avoid), but I need to add a condition in my list as well, to say
现在,当我添加一个输出时,我需要在输出参数列表中添加一个输出(这个是无法避免的),但我需要在我的列表中添加一个条件,说
IF mt.key='Output4' THEN mt.Value Into Output4
I want to avoid this last declaration.
我想避免这最后的声明。
1 个解决方案
#1
-1
One can use into
:
一个人可以用到:
select mt.value into output1
from myTable mt join
all_arguments aa
on aa.argument_name = mt.key;
#1
-1
One can use into
:
一个人可以用到:
select mt.value into output1
from myTable mt join
all_arguments aa
on aa.argument_name = mt.key;