我正在使用批量收集从大量地址字段中收集值(缩短以使代码更小),并且我想将该变量传递到包中的不同过程中,然后引用这些列。程序的类型是什么?我已经很好地设置了批量收集部分,它只是在消耗它(过程 create_location(part) 而不必再次重写和重新定义所有变量,我遇到了麻烦。或者我可以不这样做吗?
procedure create_adrx(
v_sub_id in number
) AS
TYPE adrx_info_rectype is RECORD(
ADRX1 VARCHAR(1000)
, ADRX2 VARCHAR2(1000)
, CITY VARCHAR2(200)
, COUNTY VARCHAR2(50)
, STATE VARCHAR2(40)
, ZIP VARCHAR2(50)
, SITE_NAME VARCHAR2(30)
, GEO_LAT NUMBER
, GEO_LONG NUMBER
);
TYPE adrx_info_tbl is TABLE OF adrx_info_rectype;
adrx_info adrx_info_tbl;
v_location_id_result NUMBER;
v_party_site_id_result NUMBER;
v_account_number_result NUMBER;
BEGIN
SELECT
NVL(sl.ADDRESS1, asi.ADDRESS1) as ADRX1
, NVL(sl.ADDRESS2, asi.ADDRESS2) as ADRX2
, NVL(sl.CITY, asi.CITY) as CITY
, NVL(sl.COUNTY, asi.COUNTY) as COUNTY
, NVL(sl.STATE, asi.STATE) as STATE
, NVL(sl.ZIP, asi.ZIP) as ZIP
, NVL(sl.SITE_NAME, esi.ALT_SITE_NAME) as SITE_NAME
, NVL(sl.LATITUDE, asi.LATITUDE) as GEO_LAT
, NVL(sl.LONGITUDE, asi.LONGITUDE) as GEO_LONG
BULK COLLECT INTO
adrx_info
FROM
TBL_SUBS ts
LEFT JOIN TBL_SUB_LEVEL sl on sl.sub_id = ts.sub_id
LEFT JOIN TBL_ALT_SUB_LEVEL asl on asl.sub_id = ts.sub_id
LEFT JOIN TBL_ALT_SITE_INFO asi on asi.ALT_SITE_ID = asl.ALT_SITE_ID
LEFT JOIN TBL_ALT_EXT_SITE_INFO esi on esi.ALT_EXT_SITE_ID = asi.ALT_EXT_SITE_ID and esi.CUST_ID = ts.CUST_ID
WHERE
ts.sub_id = v_sub_id;
-- CREATE LOCATION
create_location(adrx_info);
procedure create_location(
adrx_info in TABLE (??)
) as
BEGIN
run statements using adrx_info.ADRX1, adrx_info.STATE, etc...
END;