Ref Cursor-Help Needed

I am tryin to create a procedure with ref cursor. It is giving error message like
PLS-00201:identifier 'TYPES>CURSOR_TYPE' must be declared.
Any idea how to resolve this error.
CREATE OR REPLACE PROCEDURE "PROC_GET_USERNAME" (
p_user_name IN bmf_users_temp.user_name%TYPE,
p_recordset OUT TYPES.cursor_type --"SYS_REFCURSOR"
AS
BEGIN
OPEN p_recordset FOR
select first_name ||' ' || last_name ||' '|| bmf_user_type ||' '||
bmf_user_role || ' ' ||bmf_user_status from bmf_users_temp ab where
user_name=p_user_name and
bmf_user_status='A';
WHEN NO_DATA_FOUND
THEN
NULL;
END PROC_GET_USERNAME;
/

I guess TYPES is a package in which you have declared cursor_type as a sys_refcursor.
1. Please check the package if it has cursor_type declared as the same spelling.
2. Check if current user have the select rights of the package TYPES.
Regards
G

Similar Messages

  • Ref cursor help in Reports/pl sql

    Hello , i am new to this , please help!
    From oracle forms, we have a table and one of the columns from that table returns rows and the result are like ( select name, messaging_id, listing_id from dynamic_message group_query) ..I am trying to join this table with other tables based on a group type, based on if it returns 'D' or 'S' to other groups in report.
    I am getting the following error when I uncomment the open cursor statemnt
    PLS-00455: cursor 'TEMP_GRP_REC_REFCUR' cannot be used in dynamic
    SQL OPEN statement
    This is what i have so faar:
    create or replace PACKAGE grp IS
    TYPE grp_rec IS RECORD
    (listing_id varchar2(16 ),
    messaging_id varchar2(16 ),
    name varchar2(256 ) ,
    group_number Number);
    TYPE grp_rec_refcur is REF CURSOR RETURN grp_rec;
    function grprefc(P_group_number NUMBER, P_group_type CHAR) return grp_rec_refcur;
    END;
    CREATE OR REPLACE PACKAGE BODY grp IS
    function grprefc(p_group_number Number )
    return grp_rec_refcur
    IS
    temp_grp_rec_refcur grp.grp_rec_refcur;
    v_stmt_str VARCHAR2(2000) := NULL;
    v_cov_name listing.name%TYPE := NULL;
    v_cov_mid listing.messaging_id%TYPE := NULL;
    v_cov_lid listing.listing_id%TYPE := NULL;
    v_grpnum message_group.group_number%TYPE := NULL;
    BEGIN
              v_stmt_str:='SELECT dmgq.resolved_query
              INTO v_stmt_str
              FROM dynamic_message_group_query dmgq
              WHERE dmgq.group_number = p_group_number';
    OPEN temp_grp_rec_refcur FOR v_stmt_str;
         LOOP
         FETCH temp_grp_rec_refcur INTO v_cov_lid , v_cov_mid ,v_cov_name, v_grpnum ;
         EXIT WHEN temp_grp_rec_refcur %NOTFOUND;
         END Loop;
         RETURN temp_grp_rec_refcur;
    END;
    END;
    show errors;
    if there are any examples done by someone in reoprts or if you can help me solve the above, i would higghly appreciate it .
    Thanks and Good Day!

    Maybe something like my second example "Dynamic Table in the Second Query with Oracle Reports"
    - ref cursor or "simple" query Q1, which has a column "group_type", linked to a ref cursor query Q2.
    Ref cursor query Q2 - pseudo code for function:
    CREATE OR REPLACE PACKAGE BODY grp IS
    FUNCTION A_join_B_or_A_join_C_join_D
      (p_group_type CHAR(1), p_group_number NUMBER)
      RETURN dynamic_refcur
    IS
      l_refcur dynamic_refcur;
      l_stmt_str VARCHAR2(2000) := NULL;
    BEGIN
      IF p_group_type = 'S' THEN
        -- join A and B
        OPEN l_refcur FOR
          SELECT ...
            FROM A, B
           WHERE A.x = B.y;
      ELSE -- p_group_type = 'D'
        SELECT resolved_query
          INTO l_stmt_str
          FROM dynamic_message_group_query
         WHERE group_number = p_group_number;
        -- join A, C and D (= dynamically created SELECT)
        OPEN l_refcur FOR
          'SELECT ...
             FROM A, C, (' || l_stmt_str || ') D
            WHERE A.x = C.y
              AND A.z = D.t';
      END IF;
      RETURN l_refcur;
    END;
    END; Regards,
    Zlatko

  • Cursor help needed

    Hi All,
    I have a set of tables Orig_tab1 ... Orig_tab30 and tmp_tab1... tmp_tab30, I have migrating the data to sqlserver from oracle 10g, by creating the tmp_tabs for 30 Orig_tabs
    and changing the data type of date,number to char in tmp_tabs tables coz number and date were having issue in migration.
    Now I as I have migrated them, need to perform a quality check on data ( esply date and number) by taking max and min of all date columns and sum of number columns
    compareing the Orig_tabs tables with tmp_tabs table and finally comparing it with sqlserver results.
    SQL server part is ok, i'll take care of it. I need some help in writing sp/function/Anonymous block,
    1. what do you suggest for this, would be good to write.
    2. Thinking of one cursor for table nested with another cursor for colums, then creating one table which holds all these min max and sum of number values for both Org and tmp tables
    I do not have any tools like toad etc, need to work on sqlprompt only, which is taking time for me.
    Any Idea or help in this regard would be helpful.
    Regards,
    aak

    When you post a question it's a good idea to provide:
    a) your database version
    b) an example of your table structures
    c) an example of your data
    d) an example of your expected output
    e) the logic behind the process you want
    f) ensure you enclose code and data inside {noformat}{noformat} tags so that it retains formatting on the forum.
    As your post currently stands, I don't think many people will have much idea how to help you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Cursor help need

    Hi frds
    can i open a cursor in elsif part
    My code is as below
    IF INSERTINEG THEN
    INSERT ---
    ELSIF
    OPEN C1; (I am getting error here PLS-00103: Encountered the symbol "C1" when expecting one of the following:
    . ( * @ % & = - + < / > at in is mod remainder not rem then)
    LOOP
    FETCH
    end loop;
    Regards;

    its not very much clear, is it trigger ??
    where is your end if, could you post for complete syntax
    if t = 1 then
       blah blah ;
    else
         open c1;
          loop
          end loop;
           close c1;
      end if;
    /*removed elsif as mike pointed typo mistake*/Message was edited by:
    Nicloei W

  • Open ref cursor in a procedure

    Hi
    I have a procedure which has 3 input parameters and 1 REF CURSOR type OUT parameter.
      In the body of the procedure a select query is dynamically being created, and just before the end of the procedure the REF CURSOR is opened for SELECT(dynamic) query
    For Ex: Create or replace procedure proc_name(a in number,b in number,c in number,RETVAL OUT REF CURSOR) as
    decalre
      strQry varchar2(3000);
    begin
       -- strQry is select query built dynamically
    OPEN RETVAL for strQry;
    end proc_name;
    This procedure is being called by a java application. My question is what the open cursor statement is doing in the procedure?
    Any ideas? Thanks!
    greddy

    Hi,
    As i know, for example if we want to generate a report for some particular records in our project.consider we are using java as front end and oracle as backend. ok. In that case we need to bring the data from backend to front end ,for that in backend (oracle) we can write procedure to perform this task using ref cursors.
    Note: ref cursor will provide the most efficient way in bringing the records from back end to front end.
    Create or replace procedure proc_name(a in number,b in number,c in number,RETVAL OUT REF CURSOR) as
    decalre
    strQry varchar2(3000);
    begin
    -- strQry is select query built dynamically
    --if we are using dynamic query, we can filter out the records using id or name or date
    once we did, we need to pass the values to calling enviroment, since we declared the ref cursor as out parameter, we can use the ref cursor to pass the values to calling enviroment. Since we are using ref cursor we need to open the cursor for that dynamic query.
    OPEN RETVAL for strQry;
    end proc_name;
    hope this information is some what helpful. if you got any details regarding this please post it..
    thanks.

  • Ref cursor to object  and return to ref cursor

    how i will call object type from refcursor and return value to ref cursor .

    I need a help. please help me.
    takes oracle object types as input/output.
    PROCEDURE createserviceorder(
    P_serviceorder IN serviceorder,
    P_serviceid in out p_sm_type.serviceid,
    P_serviceorderid out p_sm_type.serviceorderid,
    Returnstatus out callstatus);
    The serviceorder, callstatus are oracle object types.
    The wrapper procedure for this API would be something like the example with pseudo code below
    PROCEDURE createserviceorderwrapper(
    P_serviceorder IN REFCURSOR,
    P_serviceid in out p_sm_type.serviceid,
    P_serviceorderid out p_sm_type.serviceorderid,
    Returnstatus out REFCURSOR)
    Map from ref cursor P_serviceorder to oracle object for serviceorder;
    Map from other data types to local variables;
    Call createserviceorder (pass the parameters here and get output….);
    Map output callstatus to its equivalent REF CURSOR variable;
    Return callstatus (and other out parameters if any )as REF CURSORS;
    }

  • Sys_refcursor & ref cursor

    hi ,
    oracle 10.2.0.1.0
    whats the implementation difference between sys_refcursor and ref cursor ? when should one use these ? apart from knowing the fact that sys_refcursor is pre-determined weak cursor only and ref cursor could be strong or weak .
    please help .

    Simma wrote:
    Hi,
    These both are the cursor but the REF CURSOR is more restricted one, you can't return as the cursor back as we think.
    For example,
    TYPE Cursor_Ref IS REF CURSOR RETURN temp_table%ROWTYPE;
    Since the Cursor_Ref is defined as the REF CURSOR , we need to use only the colmns / fields only same as temp_table.
    As we have restricted to use temp_table%ROWTYPE;
    but in SYS_REFCURSOR, we are not restricting to any of the ROWTYPE, so it is not more restricted,
    we can return as we want.
    Edited by: Simma on Jan 11, 2011 9:22 PMYou can just writeTYPE Cursor_Ref IS REF CURSOR;
    v_cur Cursor_Ref;and this is the same asv_cur SYS_REFCURSOR;

  • Urgent help needed on oracle queueing

    Hi
    we have created AQ tables and queues but are facing with the following errors
    Thu Aug 30 17:25:31 2007
    Errors in file e:\orant\ora9i\pds\udump\pds_ora_4092.trc:
    ORA-00600: internal error code, arguments: [opidor: call 1], [], [], [], [], [], [], []
    Thu Aug 30 17:44:17 2007
    Errors in file e:\orant\ora9i\pds\udump\pds_ora_4092.trc:
    ORA-00600: internal error code, arguments: [17281], [1001], [0x25EBB628], [], [], [], [], []
    ORA-01001: invalid cursor
    Thu Aug 30 17:44:17 2007
    Errors in file e:\orant\ora9i\pds\udump\pds_ora_4092.trc:
    ORA-00600: internal error code, arguments: [17281], [1001], [0x25EBB628], [], [], [], [], []
    ORA-01001: invalid cursor
    ORA-00600: internal error code, arguments: [17281], [1001], [0x25EBB628], [], [], [], [], []
    ORA-01001: invalid cursor
    help needed asap
    thanx

    ORA-600 should be reported to Oracle support with trace files and alertlog.
    Well the following note may help you:
    Note: 433389.1
    Hope this Helps
    Regards

  • Procedure to fetch table records using ref cursor

    Hi
    i need to fetch all the records in the table using ref cursor.we need to pass table
    name and the out paramater should be ref cursor.
    CREATE OR REPLACE PROCEDURE gettable(p_table_name IN VARCHAR2,
    p_ref_cursor OUT dept_pack.ref_cursor1)
    IS
    BEGIN
    OPEN p_ref_cursor FOR SELECT * FROM p_table_name;
    END gettable;
    is that a start ? then after this i have to execute this procedure to fetch the data from table. i am getting error that table doesnot exist but my idea was to pass p_table_name as IN parameter.
    Thnks in Advance

    here is the example
    SQL> CREATE OR REPLACE PROCEDURE TEST( t_name IN VARCHAR2
      2                                  , p_cursor OUT SYS_REFCURSOR)
      3  IS
      4  BEGIN
      5    OPEN p_cursor FOR
      6    'SELECT * FROM '|| t_name ;
      7  END TEST;
      8  /
    Procedure created.
    Elapsed: 00:00:00.02
    SQL>  var o refcursor;
    SQL> var tname varchar2(10);
    SQL> execute test('EMP',:o);
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.00
    SQL> print :o;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM        DNO
          7369 SMITH      CLERK           7902 17-DEC-80      800.2                    20
          7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       5000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          7934 MILLER     CLERK           7782 23-JAN-82       1300                    10
    14 rows selected.
    Elapsed: 00:00:00.01
    SQL>  execute test('DEPT',:o);
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.02
    SQL>  print :o;
        DEPTNO DNAME          LOC
            90 LOGISTIC
            10 ACCOUNTING     NEW YORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    Elapsed: 00:00:00.01

  • Help needed in Ref cursor

    Hi,
    I am new to Ref Cursor concepts and I am trying a small block but its throwing error. Pls help me.
    PACKAGE SPEC:
    CREATE OR REPLACE PACKAGE PKG_JOBINFO AS
    PROCEDURE JOBINFO ( v_job_id IN number, p_cursor OUT PKG_JOBINFO.RESULT_REF_CURSOR);
    TYPE RESULT_REF_CURSOR IS REF CURSOR;
    END PKG_JOBINFO;
    PACKAGE BODY:
    CREATE OR REPLACE package body PKG_JOBINFO
    AS
    PROCEDURE JOBINFO ( v_job_id IN number,
    p_cursor OUT PKG_JOBINFO.RESULT_REF_CURSOR)
    AS
    BEGIN
    OPEN p_cursor FOR
    SELECT JOB_ID,
    JOB_NAME,
    TABLE_NAME
    FROM JOB_INFO
    WHERE JOB_ID=V_JOB_ID;
    EXCEPTION
    WHEN OTHERS THEN
    raise;
    END;
    END;
    While compiling the package i am not getting any errors. I am getting errors only while executing
    SQL> exec PKG_JOBINFO.JOBINFO ('23');
    BEGIN PKG_JOBINFO.JOBINFO ('23'); END;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00306: wrong number or types of arguments in call to 'JOBINFO'
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    Please help me to resolve this error.
    Thanks.

    user497267 wrote:
    Thanks its working. So if we are using ref cursor we have to execute like this only.To add...
    The actual issue you were experiencing was not because you were using ref cursors specifically, but because you had an OUT parameter in your procedure.
    When you have an OUT parameter, you need to ensure that you pass in a variable to that parameter of the procedure in order that the procedure can populate it. In your case you were only passing in the first parameter, but you weren't passing in a variable to capture the OUTput.
    What Alex showed was that by declaring a variable of the same datatype (ref cursor in your case) and passing that in as the second parameter, that variable was populated with the ref cursor information from inside the procedure. Once that variable was populated, after the procedure call, the data from that ref cursor can be obtained (using SQL*Plus' print command in Alex's example).

  • Need Help: Using Ref Cursor in ProC to call a function within a Package

    I'm calling a function within a package that is returning a REF CURSOR.
    As per the Oracle Pro*C Programmer's Guide, I did the following:
    1) declared my cursor with a: EXEC SQL BEGIN DECLARE SECTION and declared the cursor as: SQL_CURSOR my_cursor;
    2) I allocated the cursor as: EXEC SQL ALLOCATE :my_cursor;
    3) Via a EXEC SQL.....END-EXEC begin block
    I called the package function and assign the return value to my cursor
    e.g. my_cursor := package.function(:host1, :host2);
    Now, the only difference between my code and the example given in the Pro*C Programmer's Guide is that the example calls a PROCEDURE within a package that passes back the REF CURSOR as an OUT host variable.
    Whereas, since I am calling a function, the function ASSIGNS the return REF CURSOR in the return value.
    If I say my_cursor := package.function(:host1, :host2); I get a message stating, "PLS-00201: identifier MY_CURSOR" must be declared"
    If I say :my_cursor := package.function(:host1, :host2); I get a message stating, "ORA-01480: trailing null missing from STR bind value"
    I just want to call a package function and assign the return value to a REF CURSOR variable. There must be a way of doing this. I can do this easily in standard PL/SQL. How can this be done in Pro*C ???
    Thanks for any help.

    Folks, I figured it out. For those who may face this problem in the future you may want to take note for future reference.
    Oracle does not allow you to assign the return value of a REF CURSOR from a FUNCTION ( not Procedure - - there is a difference) directly to a host variable. This is the case even if that host variable is declared a CURSOR variable.
    The trick is as follows: Declare the REF CURSOR within the PL/SQL BEGIN Block, using the TYPE statement, that will contain the call to the package function. On the call, you then assign the return REF CURSOR value that the function is returning to your REF CURSOR variable declared in the DECLARE section of the EXEC SQL .... END-EXEC PL/SQL Block.
    THEN, assign the REF CURSOR variable that was populated from the function call to your HOST cursor varaible. Then fetch this HOST Cursor variable into your Host record structure variable. Then you can deference individual fields as need be within your C or C++ code.
    I hope this will help someone facing a deadline crunch. Happy computing !

  • Need Urgent Help Reports 6i :  Ref Cursor

    Hi,
    I am creating required SQL for report in my Java program. I want to pass this SQL stmt to my Oracle Report.
    For that , I am storing the SQL stmt in Oracle table and then I want to use that stmt with few additions to fetch data . Is there any good method other than Ref Cursor to do this? Somehow Ref cursor is not working in Reports 6i. Or may be I don't know how to use it.
    Any help will be appreciated !!
    VMJ

    Lexical parameters seem to be much more appropriate tool for this task. You can create entire query as single lexical parameter, and script it in the After Parameter Form trigger any way you need. Just make sure to supply some dummy query as initial value for the lexical parameter, so that the report could create proper data structure.

  • Need help about ref cursor using like table

    Hi Guys...
    I am devloping package function And i need help about cursor
    One of my function return sys_refcursor. And the return cursor need to be
    join another table in database . I don't have to fetch all rows in cursor
    All i need to join ref cursor and another table in sql clause
    like below
    select a.aa , b.cc form ( ref_cursor ) A, table B
    where A.dd = B.dd
    I appeciate it in advance

    My understanding is that you have a function that returns a refcursor and is called by a java app.
    Because this is a commonly used bit of code, you also want to reuse this cursor in other bits of sql and so you want to include it like table in a bit of sql and join that refcursor to other tables.
    It's not as easy as you might hope but you can probably achieve this with pipelined functions.
    Is it a direction that code should be going down? yes, eventually. I like the idea of pulling commonly used bits of code into a SQL statement especially into the WITH section, provided it could be used efficiently by the CBO.
    Is it worth the effort given what you have to do currently to implement it? possibly not.
    what else could you do? construct the sql statement independently of the thing that used it and reuse that sql statement rather than the refcursor it returns?
    Message was edited by:
    dombrooks

  • Need help with Ref Cursor

    Dear All,
    Version : '11.2.0.2.0'
    I have a procedure which gets called from a screen ( on .Net) if use pushes a particular button.
    The procedure takes 15 minutes to complete.
    My requirement is to intimate the front end(.Net) as soon as the procedures gets called successfully without waiting for its completion as it is going to take 15 mins.
    The reason being, the front end will popup a message saying that " The process is going to take long time, A mail will be sent to u after its completion"  once it has been intimated that the procedure has been called successfully.
    Could you please suggest can i return a cursor to front end without even manipulating the data.
    i hope my question is understandable.

    9876564 wrote:
    Dear All,
    Version : '11.2.0.2.0'
    I have a procedure which gets called from a screen ( on .Net) if use pushes a particular button.
    The procedure takes 15 minutes to complete.
    My requirement is to intimate the front end(.Net) as soon as the procedures gets called successfully without waiting for its completion as it is going to take 15 mins.
    The reason being, the front end will popup a message saying that " The process is going to take long time, A mail will be sent to u after its completion"  once it has been intimated that the procedure has been called successfully.
    Could you please suggest can i return a cursor to front end without even manipulating the data.
    i hope my question is understandable.
    It seems to me that your problem is not an Oracle one, but a user interface one.
    I'm assuming the slowness of the procedure is due to how long it's taking to query the data, and if you can't speed that up then, to have the procedure return a ref cursor, the connection between the front end and the procedure must be maintained (the process on Oracle must belong to a session, and the front end needs to be connected to that session).
    So, you can't have Oracle go off and start a seperate process and then pass back the ref cursor when it's finished, because even though you can spawn off seperate processes such as using DBMS_JOB or DBMS_SCHEDULER, they will run in their own 'session' and the calling code won't keep a hold on any of those sessions... they're effectively stand-alone and seperate.
    What you'll have to do is likely get your .net application to spawn off a child process to the main app, that presents the message saying it'll take some time, does the call to Oracle and waits for Oracle to return the resultant ref cursor, which it can then pass back to the main application etc.  Due to .net allowing for multi-tasking, that is where the split processing should take place.

  • Help on CAST function, defining TYPE TABLE and using a REF cursor

    Hi,
    I have written a procedure (lookup) inside a package (lookup_pkg) as shown below.
    Procedure has an output variable of type PL/SQL TABLE which is defined in the package.
    I want to write a wrapper procedure lookupref to the procedure lookup to return a ref cursor.
    CREATE OR REPLACE PACKAGE lookup_pkg AS
    TYPE t_lookup_refcur IS REF CURSOR;
    CURSOR c_lookup IS
         Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1;
    TYPE t_lookup IS TABLE OF c_lookup%ROWTYPE;
    Procedure lookup(id Number, o_lookup OUT t_lookup);
    End lookup_pkg;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this procedure, I am getting invalid datatype Oracle error and
    cursor points the datatype t_lookup in the CAST function.
    1. Can anyone tell me what is wrong in this. Can I convert a PL/SQL collection (pl/sql table in this case) to PL/SQL datatype table or does it need to be a SQL datatype only (which is created as a type in database).
    Also, to resolve this error, I have created a SQL type and table type instead of PL/SQL table in the package as shown below.
    create or replace type t_lookuprec as object
                   (Select columns1,2,3,....100
                   FROM A, B, C, D, E
                   WHERE ROWNUM < 1);
    create or replace type t_lookup_tab AS table of t_lookuprec;
    CREATE OR REPLACE PACKAGE BODY lookup_pkg As
    Procedure lookup(id Number, o_lookup OUT t_lookup) IS
    BEGIN
    END lookup;
    Procedure lookupref(id Number, o_lookupref OUT t_lookup_refcur) IS
    o_lookup t_lookup;
    BEGIN
    lookup(id, o_lookup t_lookup);
    OPEN t_lookup_refcur FOR
    SELECT *
         FROM TABLE(CAST(o_lookup AS t_lookup_tab));
    Exception
    End lookupref;
    END lookup_pkg;
    When I compile this package, I am getting "PL/SQL: ORA-22800: invalid user-defined type" Oracle error and
    points the datatype t_lookup_tab in the CAST function.
    2. Can anyone tell me what is wrong. Can I create a type with a select statement and create a table type using type created earlier?
    I have checked the all_types view and found that
    value for Incomplete column for these two types are YES.
    3. What does that mean?
    Any suggestions and help is appreciated.
    Thanks
    Srinivas

    create or replace type t_lookuprec as object
    (Select columns1,2,3,....100
    FROM A, B, C, D, E
    WHERE ROWNUM < 1);You are correct that you need to use CREATE TYPE to use the type in SQL.
    However unless I am mistaken you appear to have invented your own syntax for CREATE TYPE, suggest you refer to Oracle documentation.

Maybe you are looking for