请原谅任何措辞不好的问题,因为我对PL / SQL和Oracle的经验很少。但是,我目前不知道如何将表作为参数传递。目前,此过程输出与指定输入匹配的一个条目。例如,如果交易产品= a,交易区域= c,交易对象区域= b,交易台= d,交易法律实体= e,对冲产品= f且对冲法律实体= g,则返回此唯一组合。但是,我希望能够为每个参数分配多个值并返回所有结果。例如,根据前面的例子,如果我指定对冲法律实体= g或h,那么我希望看到2个条目 - " a,c,b,d,e,f,g& #34; AND" a,c,b,d,e,f,h"。我相信这是通过将我的参数类型更改为varchar2s表而不是单个varchar2来完成的。非常感谢任何见解。
CREATE OR REPLACE PROCEDURE SOX_SCOPING.BM_ENTIRE_TABLE_ARRAY_PARAMS (
trade_product in varchar2
, trade_region in varchar2
, counterparty_region in varchar2
, trade_desk in varchar2
, trade_legal_entity in varchar2
, hedge_product in varchar2
, hedge_legal_entity in varchar2
, out_cursor out sys_refcursor) IS
BEGIN
open out_cursor for
SELECT D.PRODUCTS AS TRADE_PRODUCTS, D.TRADER_REGION, D.REGION, D.DESK AS TRADE_DESK, D.LEGAL_ENTITY AS TRADE_LEGAL_ENTITY,F.PRODUCTS AS HEDGE_PRODUCTS, F.LEGAL_ENTITY AS HEDGE_LEGAL_ENTITY
FROM
(SELECT C.*, BM_LEGAL_ENTITY.LEGAL_ENTITY
FROM
(SELECT B.*, BM_DESK.DESK
FROM
(SELECT *
FROM
(SELECT BM_PRODUCTS.*,BM_TRADER_REGION.REGION AS TRADER_REGION
FROM SOX_SCOPING.BM_PRODUCTS
CROSS JOIN SOX_SCOPING.BM_TRADER_REGION)
CROSS JOIN SOX_SCOPING.BM_COUNTERPARTY_REGION) B
LEFT OUTER JOIN SOX_SCOPING.BM_DESK
ON B.PRODUCTS = BM_DESK.DESK_TO_PRODUCT) C
LEFT OUTER JOIN BM_LEGAL_ENTITY
ON C.DESK = BM_LEGAL_ENTITY.LEGAL_ENTITY_TO_DESK) D
CROSS JOIN (
SELECT E.*,BM_LEGAL_ENTITY.LEGAL_ENTITY
FROM
(SELECT BM_PRODUCTS.*,BM_DESK.DESK
FROM SOX_SCOPING.BM_PRODUCTS
LEFT OUTER JOIN SOX_SCOPING.BM_DESK
ON BM_PRODUCTS.PRODUCTS = BM_DESK.DESK_TO_PRODUCT) E
LEFT OUTER JOIN BM_LEGAL_ENTITY
ON E.DESK = BM_LEGAL_ENTITY.LEGAL_ENTITY_TO_DESK) F
where
d.products in (trade_product)
and D.TRADER_REGION in (trade_region)
and D.REGION in (counterparty_region)
and D.DESK in (trade_desk)
and D.LEGAL_ENTITY in (trade_legal_entity)
and F.PRODUCTS in (hedge_product)
and F.LEGAL_ENTITY in (hedge_legal_entity)
ORDER BY TRADE_PRODUCTS, TRADER_REGION,REGION,TRADE_DESK,HEDGE_PRODUCTS,HEDGE_LEGAL_ENTITY;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
WHEN OTHERS THEN
-- Consider logging the error and then re-raise
RAISE;
END BM_ENTIRE_TABLE_ARRAY_PARAMS;
/
答案 0 :(得分:0)
如果我必须创建一个带有表名变量和OUT参数为SYS_REFCURSOR的过程,这就是我写它的方式。希望您可以根据代码进行调整。
EVP_PKEY*