Oracle pl/sql simple for循环游标给出错误

Oracle pl/sql simple for循环游标给出错误,oracle,plsql,syntax-error,Oracle,Plsql,Syntax Error,我收到一条消息说子程序或游标'CUR'引用超出范围。我不明白什么超出了范围。请告知 set serveroutput ON Declare CURSOR cur IS select tt.id from (select * from DUMMY_1 t where t.status=976 and t.series_Value<'7-%' ) tt where no

我收到一条消息说子程序或游标'CUR'引用超出范围。我不明白什么超出了范围。请告知

set serveroutput ON
Declare
    CURSOR cur IS 
            select tt.id 
        from (select * from DUMMY_1 t
            where t.status=976 and t.series_Value<'7-%'  
            ) tt   
        where not exists (select *
                from DUMMY_2 d, DUMMY_1 ss_beg, DUMMY_1 ss_end
                where d.status=976 and d.for_class_loc_project=1
                    and ss_beg.id=d.beg_series
                    and ss_end.id=d.end_Series
                    and ss_beg.discharge_subsys = tt.discharge_subsys
                    and ss_beg.line_loop = tt.line_loop
                    and ((d.beg_series=tt.id and d.beg_Station<=tt.beg_station) or      ss_beg.series_value<tt.series_value)
                    And ((D.End_Series=Tt.Id And D.End_Station> Tt.Beg_Station) Or      Ss_End.Series_Value>Tt.Series_Value) 
                );


Begin
for indx in 1..cur.count
     Loop
            Exit when cur.count = 0;
        DBMS_OUTPUT.PUT_LINE('Hello' || cur(indx));
     End Loop;
END;

最好使用隐式光标,形式如下:

begin
  for my_data in (
    select col1,
           col2
    from   ...
    where  ...)
  loop
    DBMS_Output.Put_Line(my_data.col1)
  end loop;
end;

此处循环游标的语法:

显式游标复杂且缓慢。使用隐式游标可以获得更好的结果。您能演示如何使用隐式游标吗?请
Hello i have modified the query a lilte bit you can use this. Please let me know for any other queries. Thanks

SET serveroutput ON
DECLARE
  CURSOR cur
  IS
    SELECT tt.id
    FROM
      (SELECT * FROM DUMMY_1 t WHERE t.status=976 AND t.series_Value<'7-%'
      ) tt
  WHERE NOT EXISTS
    (SELECT *
    FROM DUMMY_2 d,
      DUMMY_1 ss_beg,
      DUMMY_1 ss_end
    WHERE d.status              =976
    AND d.for_class_loc_project =1
    AND ss_beg.id               =d.beg_series
    AND ss_end.id               =d.end_Series
    AND ss_beg.discharge_subsys = tt.discharge_subsys
    AND ss_beg.line_loop        = tt.line_loop
    AND ((d.beg_series          =tt.id
    AND d.beg_Station          <=tt.beg_station)
    OR ss_beg.series_value      <tt.series_value)
    AND ((D.End_Series          =Tt.Id
    AND D.End_Station           > Tt.Beg_Station)
    OR Ss_End.Series_Value      >Tt.Series_Value)
    );
BEGIN
  FOR indx IN cur
  LOOP
    DBMS_OUTPUT.PUT_LINE('Hello' || indx);
  END LOOP;
END;