* /我正在尝试使用2个显式游标,它会显示这些错误
{:第42行的错误: ORA-06550:第42行第1栏: PLS-00306:调用' PUT_LINE'中的参数数量或类型错误 ORA-06550:第42行第1栏: PL / SQL:忽略语句} * /
声明
v_CITY AIRPORT.CITY%TYPE;
v_ARRIVAL_TIME SCHEDULE.ARRIVAL_TIME%TYPE;
v_fnumber FLIGHT.FNUMBER%TYPE;
v_CITY1 AIRPORT.CITY%TYPE;
v_ARRIVAL_TIME1 SCHEDULE.ARRIVAL_TIME%TYPE;
v_fnumber1 FLIGHT.FNUMBER%TYPE;
/* First cursor */
CURSOR get_tables IS
select airp2.CITY , S. ARRIVAL_TIME,S.fnumber
from schedule S, FLIGHT F, airport airp1, airport airp2
where airp1.apcode = DEPARTURE_APCODE and airp2.apcode = ARRIVAL_APCODE AND ARRIVAL_APCODE ='BWI'and S.FNUMBER= F.FNUMBER AND
TO_CHAR(TRUNC(S.DEPARTURE_TIME)) = date'2017-11-12'
ORDER BY airp1.CITY, ARRIVAL_TIME ;
/* Second cursor */
CURSOR get_columns IS
select DISTINCT airp2.CITY , S. DEPARTURE_TIME,S.fnumber
from schedule S, FLIGHT F, airport airp1,FLIGHT_RESERVATION FL, airport airp2
where airp1.apcode = ORIGIN_APCODE and airp2.apcode = DESTINATION_APCODE AND ORIGIN_APCODE ='BWI'and S.FNUMBER= F.FNUMBER AND
TO_CHAR(TRUNC(S.DEPARTURE_TIME)) = date'2017-11-12'
ORDER BY airp2.CITY, DEPARTURE_TIME ;
BEGIN
-- Open first cursor
OPEN get_tables;
LOOP
FETCH get_tables INTO v_CITY, v_ARRIVAL_TIME, v_fnumber;
-- Open second cursor
OPEN get_columns;
LOOP
FETCH get_columns INTO v_CITY1, v_ARRIVAL_TIME1, v_fnumber1;
DBMS_output.put_line(v_CITY1, v_ARRIVAL_TIME1, v_fnumber1);
CLOSE get_tables;
END LOOP;
CLOSE get_columns;
END LOOP;
END;
答案 0 :(得分:0)
DBMS_OUTPUT.PUT_LINE
只接受一个参数,因此要输出多个值,您必须将它们转换为字符串并将它们连接在一起。将您的PUT_LINE调用更改为
DBMS_output.put_line('CITY1=' || TO_CHAR(v_CITY1) ||
' ARRIVAL_TIME=' || TO_CHAR(v_ARRIVAL_TIME1) ||
' FNUMBER=' || TO_CHAR(v_fnumber1));
祝你好运。