我不知道如何显示游标数据,我创建了一个返回多行的游标,我想查看该行,我不知道如何
SET SERVEROUTPUT ON;
DECLARE CURSOR CurEscal IS
SELECT
ESCALE.NUMVOL, ( to_number ( to_char ( ESCALE.DATEED, 'MI' ) ) - to_number ( to_char ( ESCALE.DATEEA, 'MI' ) ) ) AS "duree par min", AEROPORT.NOMAER
FROM
ESCALE
JOIN AEROPORT ON ESCALE.REFAER = AEROPORT.REFAER
WHERE
NUMVOL IN ( SELECT ESCALE.NUMVOL FROM ESCALE GROUP BY ESCALE.NUMVOL HAVING Count( ESCALE.NUMESC ) >= 1 );
BEGIN
--Open the CurEscal CURSOR
IF NOT (CurEscal%ISOPEN) THEN
OPEN CurEscal;
END IF;
--FETCH
FOR i IN CurEscal LOOP
DBMS_OUTPUT.PUT_LINE('I don't know how I need your help');
END LOOP;
--Close the CurEscal CURSOR
IF CurEscal%ISOPEN THEN
CLOSE CurEscal;
END IF;
END;
/
有人可以帮忙!
答案 0 :(得分:1)
那将是
dbms_output.put_line(i.numvol ||', '|| i."duree par min" ||', '|| i.NOMAER);
但是,如果您使用游标FOR
循环,则一切都会变得更简单,因为您不必声明/打开/获取/关闭游标,例如
BEGIN
FOR i
IN (SELECT escale.numvol,
( TO_NUMBER (TO_CHAR (escale.dateed, 'MI'))
- TO_NUMBER (TO_CHAR (escale.dateea, 'MI')))
AS duree_par_min,
aeroport.nomaer
FROM escale JOIN aeroport ON escale.refaer = aeroport.refaer
WHERE numvol IN ( SELECT escale.numvol
FROM escale
GROUP BY escale.numvol
HAVING COUNT (escale.numesc) >= 1))
LOOP
DBMS_OUTPUT.put_line (
i.numvol || ', ' || i.duree_par_min || ', ' || i.nomaer);
END LOOP;
END;