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;