我在sql developer中运行以下代码时出现以下错误。我找不到这个代码的问题。 概念:游标Base1中的sql重新绕过100行。我想使用这些行中的每一行作为目标cusor内的sql的输入,这进一步返回几行。 我得到的错误是:
遇到符号“(”当遇到下列之一:。进入批量
遇到符号“;”当期待以下之一时:。 (,%来自
在期望以下之一时遇到符号“CLOSE”:end not pragma final instantiable order overriding static 成员构造函数映射
set serveroutput ON
Declare
Type Beg_Ser_Tab1 Is Table Of DUMMY%Rowtype Index By Pls_Integer;
Type Beg_Ser_Tab2 Is Table Of DUMMY%Rowtype INDEX BY PLS_INTEGER;
L_Beg_Ser_Tab Beg_Ser_Tab1;
L_Beg_Ser_Tab_Fin Beg_Ser_Tab2;
result number;
CURSOR Base1 IS
select * from DUMMY c1
where status=976 and for_class_loc_project=1
and not exists
(select * from DUMMY c2
where c2.status=976 and c2.for_class_loc_project=1
and c2.end_series=c1.COLOUMN_X and c2.end_station=c1.beg_station)
and not exists
(select * from mv_station_Series t
where t.status in (SELECT ID FROM list_domain
WHERE LOWER (domainvalue) IN ('active', 'preliminary as-built', 'idle', 'construction'))
and c1.COLOUMN_X=t.id and c1.beg_station=t.beg_station
)
order by c1.id;
CURSOR target(v_id NUMBER) IS
Select *
From DUMMY Where COLOUMN_X in (
Select ID From Station_Series Where
Status = 976
And Discharge_Subsys = (Select Discharge_Subsys From Station_Series Where Id = v_id )
And Line_Loop = (Select Line_Loop From Station_Series Where Id = v_id)) And Status In
(Select Id From List_Domain
Where Lower (Domainvalue) In ('active', 'preliminary as-built', 'idle', 'construction'))
Order By Beg_Station Asc;
BEGIN
OPEN Base1;
FETCH Base1 BULK COLLECT INTO l_beg_ser_tab1;
EXIT WHEN l_beg_ser_tab1.count = 0;
FOR index1 IN 1..l_beg_ser_tab1.count
LOOP
Dbms_Output.Put_Line('For Beg Series '|| L_Beg_Ser_Tab1(Index1));
Open Target(L_Beg_Ser_Tab1.COLOUMN_X);
FETCH target(l_beg_ser_tab1.COLOUMN_X) BULK COLLECT INTO l_beg_ser_tab_fin;
FOR index2 IN 1..l_beg_ser_tab_fin.count
LOOP
DBMS_OUTPUT.PUT_LINE(' '||l_beg_ser_tab_fin(index2));
END LOOP;
CLOSE target;
DBMS_OUTPUT.PUT_LINE('---------------------------------------------------------');
END LOOP;
CLOSE Base1;
END
答案 0 :(得分:2)
我会认为,一旦你有:
Open Target(L_Beg_Ser_Tab1.COLOUMN_X);
您无需在以下位置再次指定参数:
FETCH target(l_beg_ser_tab1.COLOUMN_X) B
此外,隐式游标通常更快,更容易编码。为什么不使用它们?实际上,为什么不对整个逻辑使用单个隐式游标?