如果光标中没有任何记录,我有以下过程是循环中断。即使光标没有任何记录,我也想继续迭代。
我的程序是
CREATE OR REPLACE PROCEDURE "MAPSADMIN"."FORECAST_MAINTENANCE_SCH" (
in_carrierCode VARCHAR2,
in_WindowPeriodStr VARCHAR2,
out_forecastRecords OUT types.cursortype
)
IS
vtailAndCheckCur types.cursortype;
vForecastRecsCursor types.cursortype;
vtailNo VARCHAR2(10);
vmaintCheckType VARCHAR2(10);
vforcastRecords forecastObjectsList := forecastObjectsList();
forcastRec forecastObjectsList := forecastObjectsList();
BEGIN
dbms_output.enable(null);
OPEN vtailAndCheckCur FOR
select td.tail_number,mpm.maint_check_type
from tail_details td, maint_plan_tail_map mptm, maint_plan_master mpm
where td.tail_number = mptm.tail_number
and mpm.maint_plan_code = mptm.maint_plan_code
and mpm.carrier_code = in_carrierCode
UNION
select td.tail_number,mpm.maint_check_type
from tail_details td, maint_plan_subfleet_map mptm, maint_plan_master mpm
where td.subfleet_code = mptm.subfleet_code
and mpm.maint_plan_code = mptm.maint_plan_code
and mpm.carrier_code = in_carrierCode;
LOOP
FETCH vtailAndCheckCur INTO vtailNo, vmaintCheckType;
dbms_output.put_line( vtailNo||' '||vmaintCheckType );
FORECAST_OBJS_LIST(vtailNo,vmaintCheckType,in_WindowPeriodStr,vForecastRecsCursor);
LOOP
forcastRec.EXTEND;
forcastRec(forcastRec.COUNT) := FORECASTOBJECT(null,null,null,null,null,null,null,null,null,null);
dbms_output.put_line( 'test');
FETCH vForecastRecsCursor INTO
forcastRec(forcastRec.COUNT).maintNextPlanCode,
forcastRec(forcastRec.COUNT).tailNumber,
forcastRec(forcastRec.COUNT).maintNextCheckType,
forcastRec(forcastRec.COUNT).maintNextCycleCheckLabel,
forcastRec(forcastRec.COUNT).maintNextStartDate,
forcastRec(forcastRec.COUNT).maintNextEndDate,
forcastRec(forcastRec.COUNT).maintNextDueDate,
forcastRec(forcastRec.COUNT).maintNextCalendarDays,
forcastRec(forcastRec.COUNT).maintForecastFactor,
forcastRec(forcastRec.COUNT).maintCheckColor;
dbms_output.put_line( forcastRec(forcastRec.COUNT).maintNextPlanCode);
EXIT WHEN vForecastRecsCursor%NOTFOUND;
END LOOP;
EXIT WHEN vtailAndCheckCur%NOTFOUND;
END LOOP;
CLOSE vtailAndCheckCur;
OPEN out_forecastRecords FOR
SELECT tailNumber,maintNextCheckType,maintNextPlanCode,maintNextCycleCheckLabel,maintNextStartDate,
maintNextEndDate,maintNextDueDate,maintNextCalendarDays,maintForecastFactor,maintCheckColor
FROM TABLE(CAST(forcastRec AS forecastObjectsList));
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line(DBMS_UTILITY.FORMAT_ERROR_STACK);
END FORECAST_MAINTENANCE_SCH;
/
在这里,如果 vForecastRecsCursor 返回没有 0 条记录,我得到ORA-01001: invalid cursor。任何人请通过忽略错误来解释如何进一步迭代。
提前致谢