Home » SQL & PL/SQL » SQL & PL/SQL » PLS-00382: expression is of wrong type (XP)
PLS-00382: expression is of wrong type [message #339807] Fri, 08 August 2008 10:26 Go to next message
jean204
Messages: 1
Registered: August 2008
Junior Member
I am getting a message that states the expression is of wrong type. What am I doing wrong?

DECLARE
TYPE ROOMS_RECORD IS RECORD
(ROOM_ID NUMBER(5),
BUILDING VARCHAR2(15),
ROOM_NUMBER NUMBER(4));
ROOM ROOMS_RECORD;
FUNCTION GET_ROW
(ROOM_NUMBER_IN NUMBER)
RETURN ROOMS_RECORD IS
CURSOR C1(ROOM_NUMBER_CURSOR NUMBER) IS
SELECT *
FROM ROOMS
WHERE ROOM_NUMBER = ROOM_NUMBER_CURSOR;
BEGIN
FOR R IN C1 (ROOM_NUMBER_IN) LOOP
RETURN R;
END LOOP;
END GET_ROW;
BEGIN
ROOM := GET_ROW(150);
DBMS_OUTPUT.PUT_LINE ('ROOM_ID :'|| ROOM.ROOM_ID);
DBMS_OUTPUT.PUT_LINE ('BUILDING : '|| ROOM.BUILDING);
DBMS_OUTPUT.PUT_LINE ('ROOM_NUMBER :'|| ROOM.ROOM_NUMBER);
END;
/
RETURN R;
*
ERROR at line 16:
ORA-06550: line 16, column 8:
PLS-00382: expression is of wrong type
ORA-06550: line 16, column 1:
PL/SQL: Statement ignored

Re: PLS-00382: expression is of wrong type [message #339808 is a reply to message #339807] Fri, 08 August 2008 10:34 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
http://www.orafaq.com/forum/t/88153/0/
Please read & follow posting guidelines as stated in URL above

/*Notice: Formatted SQL is not the same as input*/

DECLARE
  TYPE Rooms_Record IS RECORD(Room_Id NUMBER(5),
                               Building VARCHAR2(15),
                               Room_Number NUMBER(4));
   Room  ROOMS_RECORD;
   FUNCTION Get_Row
        (Room_Number_In  NUMBER)
   RETURN ROOMS_RECORD
   IS
     CURSOR c1(Room_Number_CurSor NUMBER) IS 
       SELECT *
       FROM   Rooms
       WHERE  Room_Number = Room_Number_CurSor;
   BEGIN
     FOR r IN c1(Room_Number_In) LOOP
       RETURN r;
     END LOOP;
   END Get_Row;
BEGIN
  Room := Get_Row(150);
  
  dbms_Output.Put_Line('ROOM_ID :'
                       ||Room.Room_Id);
  
  dbms_Output.Put_Line('BUILDING : '
                       ||Room.Building);
  
  dbms_Output.Put_Line('ROOM_NUMBER :'
                       ||Room.Room_Number);
END;
/


What is "r"????????????????????/

[Updated on: Fri, 08 August 2008 10:50] by Moderator

Report message to a moderator

Re: PLS-00382: expression is of wrong type [message #339810 is a reply to message #339808] Fri, 08 August 2008 11:26 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
More what is "RETURN r;"?

R is a rowtype and is not a Rooms_Record.

Regards
Michel

[Updated on: Fri, 08 August 2008 11:27]

Report message to a moderator

Previous Topic: doubt in DBMS_JOB
Next Topic: 4 Week rolling average.. is this possible?
Goto Forum:
  


Current Time: Sat Dec 10 15:03:18 CST 2016

Total time taken to generate the page: 0.12891 seconds