Столбцы SYS_CURSOR не отображаются в ПРОЦЕДУРЕ в SQL
Я пытался извлечь свои столбцы функций в мой SYS_CURSOR в качестве возврата, а затем запустить обновление таблицы, открыв курсор sys. Но на самом деле выдает ошибку
ORA-06504: PL/SQL: Return types of Result Set variables or query do not match
Я не могу найти свою ошибку и получить вывод процедуры.
Я пробовал несколько вещей, но они не помогают. Пожалуйста, предложите
Это моя функция ниже:
FUNCTION FN_GET_HW_PARTS_PARAM (ISYSTEMID IN NUMBER, ISYSPARAM IN VARCHAR2)
RETURN SYS_REFCURSOR
IS
RESULTSET SYS_REFCURSOR;
BEGIN
OPEN RESULTSET FOR
WITH meta
AS (SELECT DISTINCT a.quote_id,
a.system_id,
a.location_id,
a.shipto,
a.product_id,
m.kmat,
m.family
FROM (SELECT DISTINCT *
FROM (SELECT a.quote_id,
a.id system_id,
b.id location_id,
b.fl_number shipto,
a.product_id
FROM quote_systems a
INNER JOIN quote_locations b
ON a.quote_id = b.quote_id
WHERE a.id = ISYSTEMID
UNION ALL
SELECT a.quote_id,
a.system_id,
b.id location_id,
b.fl_number shipto,
c.product_id
FROM QUOTE_CM_MAIN_REMOTE a
INNER JOIN quote_locations b
ON a.quote_id = b.quote_id
AND a.location_id = b.id
INNER JOIN quote_systems c
ON a.system_id = c.id
WHERE c.id = ISYSTEMID)) a
INNER JOIN material_kmat_map m
ON a.product_id = m.product_id
AND m.PAYMENT_OPTION = 'PP'
AND m.TERM = 1
AND m.OFFER_TYPE = 'SA'
AND m.OFFER_ID IN (17, 5)),
ib_data
AS (SELECT a.*, b.description
FROM QUOTE_IB_SNAPSHOT a
LEFT OUTER JOIN vw_material_descriptions b
ON a.material_code = b.matl
WHERE a.QUOTE_ID IN (SELECT QUOTE_ID
FROM QUOTE_SYSTEMS
WHERE ID = ISYSTEMID))
SELECT DISTINCT a.*
FROM (SELECT a.sap_guid sapGuid
FROM QUOTE_IB_HW_MAP_SNAPSHOT a
INNER JOIN meta s
ON a.location_code = s.shipto
AND a.base_kmat = s.kmat
AND a.quote_id = s.quote_id
LEFT OUTER JOIN QUOTE_IB_SNAPSHOT b
ON NVL (b.guid, 'y') = NVL (a.sap_guid, 'x')
AND b.IS_ACTIVE = 1
AND a.QUOTE_ID = b.QUOTE_ID
LEFT OUTER JOIN QUOTE_IB_SNAPSHOT c
ON NVL (c.guid, 'y') = NVL (a.acsbi_guid, 'x')
AND c.IS_ACTIVE = 1
AND a.QUOTE_ID = c.QUOTE_ID
LEFT OUTER JOIN vw_material_descriptions d
ON a.matl = d.matl
LEFT OUTER JOIN contract_lines cl
ON a.contractnumber = cl.contractnumber
AND a.lineitem = cl.lineitem
WHERE a.IS_ACTIVE = 1
AND ( a.SYSTEM_ID IS NULL
OR a.SYSTEM_ID = ISYSTEMID)
AND a.QUOTE_ID IN (SELECT QUOTE_ID
FROM QUOTE_SYSTEMS
WHERE ID = ISYSTEMID)
AND NVL (a.acsbi_guid, 'X') NOT LIKE '%Unknown%'
AND A.IS_CM = 1
AND ( a.matl IS NULL
OR EXISTS
(SELECT 1
FROM material_kmat_map x
WHERE x.matl = a.matl
AND x.product_id = s.product_id))
UNION ALL
SELECT sapGuid
FROM (SELECT DISTINCT a.sap_guid sapGuid
FROM QUOTE_IB_HW_MAP_SNAPSHOT a
INNER JOIN quote_systems sys
ON a.quote_id = sys.quote_id
AND sys.id = ISYSTEMID
INNER JOIN material_kmat_map b
ON sys.product_id = b.product_id
AND b.family = ISYSPARAM
AND b.part_type = 'HW'
AND b.product_id IN (49,
50,
414,
524)
AND B.PAYMENT_OPTION = 'PP'
AND B.TERM = 1
AND B.OFFER_TYPE = 'SA'
AND B.OFFER_ID IN (17, 5)
AND a.acsbi_guid LIKE
'%' || INITCAP (b.family) || '%'
LEFT OUTER JOIN QUOTE_IB_SNAPSHOT c
ON c.guid = a.acsbi_guid
AND c.IS_ACTIVE = 1
AND a.QUOTE_ID = c.QUOTE_ID
LEFT OUTER JOIN vw_material_descriptions d
ON a.matl = d.matl
LEFT OUTER JOIN contract_lines cl
ON a.contractnumber = cl.contractnumber
AND a.lineitem = cl.lineitem
WHERE a.IS_CM = 1
AND a.IS_ACTIVE = 1
AND ( a.SYSTEM_ID IS NULL
OR a.SYSTEM_ID = ISYSTEMID)
AND a.sap_guid IS NULL
AND NVL (a.acsbi_guid, 'X') LIKE '%Unknown%')
GROUP BY sapGuid) a
WHERE EXISTS
(SELECT 1
FROM QUOTE_CM_MAIN_REMOTE cmr
WHERE cmr.system_id = ISYSTEMID)
ORDER BY a.sapGuid;
RETURN RESULTSET;
END;
Я написал простую процедуру как ASSIGN_ALL_RECORDS:
PROCEDURE ASSIGN_IB_ALL_RECORDS (IQUOTEID IN NUMBER,
ISYSTEMID IN NUMBER,
iOPERATION IN VARCHAR2,
ISYSPARAM IN VARCHAR2,
ORESULT IN OUT SYS_REFCURSOR)
AS
l_acsbiGuid QUOTE_IB_HW_MAP_SNAPSHOT%ROWTYPE;
BEGIN
IF iOPERATION = 'DG'
THEN
ORESULT := FN_GET_HW_PARTS_PARAM (ISYSTEMID, ISYSPARAM);
LOOP
FETCH ORESULT INTO l_acsbiGuid;
UPDATE QUOTE_IB_HW_MAP_SNAPSHOT
SET ERROR_RECORD = 1, ASSIGNMENT_STATUS = 'DELETE', STATUS = -1
WHERE QUOTE_ID = IQUOTEID
AND SAP_GUID = l_acsbiGuid.SAP_GUID;
EXIT WHEN ORESULT%NOTFOUND;
COMMIT;
END LOOP;
END IF;
END;
Сейчас я просто запускаю эту процедуру в SQL Developer, например:
variable v_roles SYS_REFCURSOR;
DECLARE
ORESULT SYS_REFCURSOR;
BEGIN
Q_MR_IB_PKG.ASSIGN_IB_ALL_RECORDS (322195,
572416,
'DS',
'SERVER',
ORESULT);
:v_roles := ORESULT;
END;
/
PRINT v_roles
Заранее спасибо!!!