我已經在一個package
內跟蹤和它給我一個錯誤:ORA-14551:不能在查詢內部進行DML操作
ORA-14551: cannot perform a DML operation inside a query
代碼是:
DECLARE
CURSOR F IS
SELECT ROLE_ID
FROM ROLE
WHERE GROUP = 3
ORDER BY GROUP ASC;
BEGIN
FOR R IN F LOOP
DELETE FROM my_gtt_1;
COMMIT;
INSERT INTO my_gtt_1
(USER, role, code, status)
(SELECT
trim(r.user), r.role, r.code, MAX(status_id)
FROM
table1 r,
tabl2 c
WHERE
r.role = R.role
AND r.code IS NOT NULL
AND c.group = 3
GROUP BY
r.user, r.role, r.code);
SELECT c.role,
c.subgroup,
c.subgroup_desc,
v_meb_cnt
INTO record_type
FROM ROLE c
WHERE c.group = '3' and R.role = '19'
GROUP BY c.role,c.subgroup,c.subgroup_desc;
PIPE ROW (record_type);
END LOOP;
END;
我打電話包像這樣在我的程序之一...:
OPEN cv_1 for SELECT * FROM TABLE(my_package.my_func);
我怎樣才能避免這種ORA-14551
呃ROR?
僅供參考我沒有粘貼循環內的整個代碼。基本上在循環內部,我在GTT中輸入東西,從GTT中刪除東西,然後從GTT中選擇東西並將其附加到遊標上。
查看代碼以及它使用GTT的方式,看起來您可以在單個操作中插入/選擇結果,以確定填充'record_type'。 我還會調用'record_type'類似'role_record' - 更好地保留類型的_type。 – JulesLt 2010-07-19 13:06:10