我对 Oracle 比较陌生,我使用 sql server 多年。我一直试图让光标循环工作。我在函数中找到了一个示例,但为了测试,我还不想创建函数。
我希望这种语法会起作用,我做错了什么?我正在使用 PL/SQL 开发人员
declare
c_actual REFCURSOR;
v_crkt_nb log_step_circuit.crkt_nb%TYPE;
v_string VARCHAR2(50);
v_string := '';
open c_actual for
SELECT
u.LGN_ID_NM
FROM work_folder f,
trouble_call t,
doc_log_step d,
impacted_device i,
user_assignment a,
user_role r,
oms_user u,
service_location s
WHERE t.impct_dev_k = i.impct_dev_k
and i.doc_log_stp_k = d.doc_log_stp_k
and d.work_fldr_k = f.work_fldr_k
and s.locatn_k = t.locatn_k
and f.work_fldr_k = a.work_fldr_k
and a.user_role_k = r.user_role_k
and FOLDER_PKG.TroubleCallCount(f.work_fldr_k) = 1
and r.lgn_id_nm = u.lgn_id_nm
AND t.oms_tcall_k = 563815
and f.work_fldr_k in
(select work_fldr_k
from work_folder
WHERE work_folder.fldr_stts_c in ('NEW', 'IN PROGRESS'))
AND ROLE_C = 'TRBLSHTR' and a.unasn_d is null;
LOOP
FETCH c_actual INTO v_crkt_nb;
EXIT WHEN c_actual%NOTFOUND;
v_string := substr(v_string || v_crkt_nb || ' ',1, 50);
END LOOP;
v_string := trim(v_string);
CLOSE c_actual;