Results 1 to 4 of 4

Thread: Data Displaying

  1. #1
    Join Date
    May 2004
    Posts
    12

    Unhappy Unanswered: Data Displaying

    Hello there I'm trying to figure out how to get this code below to display of all the data fields for a single room.



    clear screen
    prompt
    accept RoomNumber format A4 prompt 'Please enter room number:'
    clear screen
    declare v_pcode RoomNumber%type := '&RoomNumber';
    Guest.RoomNumber Roomnumber%rowtype;
    begin
    for Guest.RoomNumber in (select Guest,
    decode(,'A','RoomType', 'B', 'RoomType', 'C', 'RoomType', 'D', 'RoomType') booking,
    DateOfArrival,
    DateOfDeparture,
    NumberOfAdults,
    NumberOfChildren,
    NameOfBillPayer,
    AddressOfBillPayer
    From Guest
    where RoomNumber = v_pcode)
    loop
    dbms_output.put_line(' Room Number : '||Guest);
    dbms_output.new_line;
    dbms_output.put(' Room Type : '||RoomType.booking);
    dbms_output.put_line(' ['||RoomType.booking||']');
    dbms_output.new_line;
    dbms_output.put_line(' Room Type : '||RoomType.booking);
    dbms_output.new_line;
    dbms_output.new_line;
    end if;
    end loop;

    exception
    when no_data_found then
    dbms_output.put_line('Sorry - Wrong Room Number '||v_pcode||' not found');
    when others then
    dbms_output.put_line ('System error detected');

    end;
    Any ideas? It keeps coming up with a number rather than displaying the proper data.

    THX Guys.
    Last edited by omega; 05-27-04 at 01:08.

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Sounds like it is waiting for you to enter the / to actually run the code!
    Code:
    SQL> begin
      2    dbms_output.put_line('hello');
      3  end;
      4  
      5  
      6  
      7  
      8  
      9  
     10  
     11  
     12  /
    hello
    
    PL/SQL procedure successfully completed.
    The line numbers 4, 5, 6, ... kept on coming every time I pressed the Enter key until I entered a / to submit the code.

  3. #3
    Join Date
    May 2004
    Posts
    12
    Hi again I've changed the code to what it is below and I ended up creating a new Table for it.

    SET SERVEROUTPUT ON FORMAT WRAPPED
    SET VERIFY OFF
    SET FEEDBACK OFF

    prompt
    prompt
    accept required_Accomondation format A4 prompt "Please enter room number : "
    prompt
    DECLARE v_GRoomNumber Accomondation.RoomNumber%type := '&required_Accomondation';
    Accomondation_row Accomondation%rowtype;

    BEGIN
    for GuestRooms_row in (select RoomNumber, RoomType,
    decode(RoomType,'S','Single','D','Double','F','Fam ily','B','Bridal') category,
    DailyRate,
    Facilities
    from Accomondation
    where RoomNumber = v_GRoomNumber)
    loop
    dbms_output.put_line('RoomNumber : '||Accomondation_row.RoomNumber);
    dbms_output.new_line;
    dbms_output.put_line('RoomType: '||Accomondation_row.RoomType);
    dbms_output.new_line;
    dbms_output.put('Group Roomtype : '||Accomondation_row.RoomType);

    dbms_output.new_line;
    dbms_output.put_line('Daily Rate ($) : '||Accomondation_row.DailyRate);
    dbms_output.new_line;
    dbms_output.put_line('Facilities: '||Accomondation_row.facilities);
    dbms_output.new_line;

    end loop;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    dbms_output.put_line('Sorry - No record'||v_GRoomNumber||' not found');

    WHEN OTHERS THEN
    dbms_output.put_line ('System error detected');


    END;
    /
    SET FEEDBACK ON
    SET VERIFY ON
    SET SERVEROUTPUT OFF

    The accomondation details for Room A1 is

    insert into Accomondation values('A1','S','50','Ground Floor')


    Now all its doing is this


    Please enter room number : A1

    RoomNumber :

    RoomType:

    Group Roomtype :
    Daily Rate ($) :

    Facilities:

    RoomNumber :

    RoomType:

    Group Roomtype :
    Daily Rate ($) :

    Facilities:

    Thx for any help.

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    It works just like you wrote it ... there's no error at all. However, perhaps you'd be much happier if you revise your code:
    Accomondation_row Accomondation%rowtype;

    BEGIN
    for GuestRooms_row in (select ...

    ...
    dbms_output.put_line(Accomondation_row.RoomNumber);


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •