Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Invalid Datatype error for record type

RotanAug 29 2017 — edited Aug 29 2017

I have a type declared in my package spec

TYPE product_type IS RECORD (     

product_id  NUMBER,     

Product_name      VARCHAR2(50),     

product_stat      VARCHAR2(50),     

product_type      VARCHAR2(50),     

product_uom       NUMBER);

I have a function which returns this type in the package body

FUNCTION product_info_typ(p_att1 IN VARCHAR2,p_att2 IN VARCHAR2)

RETURN product_type IS

  CURSOR c_prod IS

    SELECT product_id,

      Product_name,

           product_stat,

           product_type,

           product_uom

    FROM prod_table

   WHERE attribute1       = p_att1

AND  attribute2       = p_att2 ;

  l_prod_typ     product_type;

BEGIN

   l_prod_typ := NULL;

   OPEN c_prod ;

   FETCH c_prod INTO     l_prod_typ.product_id,

                         l_prod_typ.Product_name,

                         l_prod_typ.product_stat,

                         l_prod_typ.product_type,

                         l_prod_typ.product_uom ;

   CLOSE c_prod ;

  RETURN l_prod_typ;

   END product_info_typ;

I want to call this function in a select query of a cursor. But it throws error ----- ORA-00902: invalid datatype.

Any ideas how to overcome this. What am I doing wrong.

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 26 2017
Added on Aug 29 2017
5 comments
1,509 views