PL/SQL 游标错误,错误 ORA-06550

PL/SQL error with cursor, ERROR ORA-06550

我正在学习 PL/SQL 并且我正在尝试创建一个过程,但是我遇到了光标问题,我不知道它是什么,如果你能帮助我的代码我将不胜感激。

看看我的代码

DECLARE
TYPE T_CURSOR IS REF CURSOR;
V_CURSOR T_CURSOR;
V_STATION STATION_DATA%ROWTYPE;
BEGIN
  OPEN V_CURSOR FOR SELECT * FROM STATION_DATA;
   FETCH V_CURSOR INTO V_STATION;
    EXIT WHEN V_CURSOR%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE(
    'STATION NUMBER = '||V_STATION.STATION_NUMBER||
    'REPORT CODE = '||V_STATION.REPORT_CODE||
    'YEAR = '||V_STATION.YEAR||
    'MONTH = '||V_STATION.MONTH||
    'DAY = ' ||V_STATION.DAY||
    'DEW POINT = '||V_STATION.DEW_POINT||
    'STATION PRESSURE = '||V_STATION.STATION_PRESSURE||
    'VISIBILITY = '||V_STATION.VISIBILITY||
    'WIND SPEED = '||V_STATION.WIND_SPEED||
    'PRECIPATION = '||V_STATION.PRECIPATION||
    'TEMPERATURE = '||V_STATION.TEMPERATURE||
    'SNOW DEPTH = '||V_STATION.SNOW_DEPTH||
    'FOG = '||V_STATION.FOG||
    'RAIN = '||V_STATION.RAIN||
    'HAIL = '||V_STATION.HAIL||
    'THUNDER = '||V_STATION.THUNDER||
    'TORNADO = '||V_STATION.TORNADO
    );
    END LOOP    ;
  CLOSE V_CURSOR ;
 END ;
/ 

您的代码缺少 LOOP 语句以及一些不需要的代码。

你需要这样的东西(见内联评论):

DECLARE
--    TYPE T_CURSOR IS REF CURSOR; -- YOU DON'T NEED THIS
    V_CURSOR    SYS_REFCURSOR; -- USE SYS_REFCURSOR
    V_STATION   STATION_DATA%ROWTYPE;
BEGIN
    OPEN V_CURSOR FOR SELECT *
                        FROM STATION_DATA;
    LOOP -- ADDED THIS
        FETCH V_CURSOR INTO V_STATION;
        EXIT WHEN V_CURSOR%NOTFOUND;
        DBMS_OUTPUT.PUT_LINE(
                'STATION NUMBER = '||V_STATION.STATION_NUMBER||
                'REPORT CODE = '||V_STATION.REPORT_CODE||
                'YEAR = '||V_STATION.YEAR||
                'MONTH = '||V_STATION.MONTH||
                'DAY = ' ||V_STATION.DAY||
                'DEW POINT = '||V_STATION.DEW_POINT||
                'STATION PRESSURE = '||V_STATION.STATION_PRESSURE||
                'VISIBILITY = '||V_STATION.VISIBILITY||
                'WIND SPEED = '||V_STATION.WIND_SPEED||
                'PRECIPATION = '||V_STATION.PRECIPATION||
                'TEMPERATURE = '||V_STATION.TEMPERATURE||
                'SNOW DEPTH = '||V_STATION.SNOW_DEPTH||
                'FOG = '||V_STATION.FOG||
                'RAIN = '||V_STATION.RAIN||
                'HAIL = '||V_STATION.HAIL||
                'THUNDER = '||V_STATION.THUNDER||
                'TORNADO = '||V_STATION.TORNADO
                );
    END LOOP;
    CLOSE V_CURSOR;
END;
/