Tham khảo tài liệu 'oracle database 10g the complete reference phần 5', công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 29 An Introduction to PL SQL 523 RADIUS AREA 3 4 5 6 Because the area value for a Radius value of 6 exceeds 100 no further Radius values are processed and the PL SQL block completes. Simple Cursor Loops You can use the attributes of a cursor such as whether or not any rows are left to be fetched as the exit criteria for a loop. In the following example a cursor is executed until no more rows are returned by the query. To determine the status of the cursor the cursor s attributes are checked. Cursors have four attributes you can use in your program FOUND A record can be fetched from the cursor. NOTFOUND No more records can be fetched from the cursor. ISOPEN The cursor has been opened. ROWCOUNT The number of rows fetched from the cursor so far. The FOUND NOTFOUND and ISOPEN cursor attributes are Booleans they are set to either TRUE or FALSE. Because they are Boolean attributes you can evaluate their settings without explicitly matching them to values of TRUE or FALSE. For example the following command will cause an exit to occur when rad_cursor NOTFOUND is TRUE KLầsaii exit when rad_cursor NOTFOUND In the following listing a simple loop is used to process multiple rows from a cursor declare pi constant NUMBER 9 7 area NUMBER 14 2 cursor rad_cursor is select from RADIUS_VALS rad_val rad_cursor ROWTYPE begin open rad_cursor loop fetch rad_cursor into rad_val exit when rad_cursor NOTFOUND area pi power 2 insert into AREAS values area end loop close rad_cursor end 524 Part IV PL SQL The loop section of the PL SQL block uses values from the RADIUS_VALS table as its input. Instead of basing the exit criteria on the Area value the cursor s NOTFOUND attribute is checked. If no more rows are found in the cursor then NOTFOUND will be TRUE and therefore the loop will be exited. The commented version of the loop is shown in the following listing L loop fetch Within the loop fetch a record. rad_cursor into .