DECLARE
i NUMBER;
a student.sname%TYPE;--引用型變量
b student%ROWTYPE;--記錄型變量
BEGIN
i := 101;
--SELECT student.sname INTO a FROM student WHERE student.sno = i;
--dbms_output.put_line(a);
SELECT * INTO b FROM student WHERE student.sno = i;
dbms_output.put_line(b.ssex);
END;
遊标
/*ISOPEN
NOTFOUND
FOUND
ROWCOUNT*/
DECLARE
stu student%ROWTYPE;
CURSOR stus IS SELECT * FROM student;
BEGIN
OPEN stus;
LOOP
FETCH stus
INTO stu;
EXIT WHEN stus%NOTFOUND;
dbms_output.put_line(stu.sname);
END LOOP;
CLOSE stus;
END;