Re: more about DBMS_OUTPUT.PUT_LINE not working

From: fumi <fumi_at_tpts5.seed.net.tw>
Date: Tue, 3 Apr 2001 23:24:21 +0800
Message-ID: <9acqu4$neg$1_at_news.seed.net.tw>


<" srcnckpc"_at_hotmail.com> ????? news:3AC30A4C.F10FEFD3_at_hotmail.com...
> Hi:
> As you can see, set serveroutput is turned on. Also the room_id numbers
> in the database start from 99999 to 99991. If I make it ascending, I get
> an error msg.
> THe 'course is' shows up but not v_course in SQL.
>
> Thanks again,
> SRC
>
>
>
> SET SERVEROUTPUT ON SIZE 100000
>
>
>
>
> DECLARE
>
> TYPE rooms_table_type IS TABLE OF rooms%ROWTYPE
> INDEX BY BINARY_INTEGER;
>
> rooms_table rooms_table_type;
>
> v_room_id classes.room_id%TYPE;
> v_dept classes.department%TYPE;
> v_course classes.course%TYPE;
>
>
> BEGIN
>
>
> FOR i IN 99999 .. 99991 LOOP
>
> SELECT *
> INTO rooms_table(i)
> FROM rooms
> WHERE room_id = i;
>
> end loop;
>
> FOR i IN 99999 .. 99991 LOOP
>
> SELECT classes.room_id, classes.department, classes.course
> INTO v_room_id, v_dept, v_course
> FROM classes, rooms
> WHERE classes.room_id = rooms.room_id
> and classes.room_id = i;
>
>
> END LOOP;
>
>
> DBMS_OUTPUT.PUT_LINE('course is'||v_course);
>
>
> END;
> /

The statements in the loop are not been executed, so the value of v_cursor is null.
You should use:

    FOR i IN REVERSE 99991 .. 99999 LOOP Received on Tue Apr 03 2001 - 17:24:21 CEST

Original text of this message