Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2004
    Posts
    153

    Unanswered: Bull Collect : ORA-00932: inconsistent datatypes:

    Hi All,

    I am encountering an error with 'inconsistent datatypes' while storing data into a pl/sql table.

    Below is my code.

    It would be nice if any one can put some light on this?

    create type jd_type as object
    (ch_key number(10),
    ch_cd varchar2(20));


    create type td_tab as table of jd_type;


    declare
    lv_tab td_tab;
    jd_ref SYS_REFCURSOR;
    begin
    open jd_ref for 'select distinct channel_key,channel_cd from cmn_tmp_channel_setup';
    fetch jd_ref bulk collect into lv_tab;
    end;


    Thanks with Regards,
    JD

  2. #2
    Join Date
    Mar 2007
    Posts
    623
    Hi,

    the error is quite self-descriptive, is not it?

    The cursor returns two columns - CHANNEL_KEY and CHANNEL_CD
    It is fetched into one variable - collection of JD_TYPE

    Either fetch it to two collections of correspondent column types, or return one value having JD_TYPE type from the query, something like
    Code:
    open jd_ref for
      select distinct jd_type( channel_key,channel_cd )
      from cmn_tmp_channel_setup;
    Note that I removed the quotes from the cursor query as there is no need to call it dynamically - it may and should be called statically in this case.

    Or, why not simply
    Code:
    select distinct jd_type( channel_key,channel_cd )
      bulk collect into lv_tab
    from cmn_tmp_channel_setup;
    (here you do not have to close the cursor which you forgot in your example)

  3. #3
    Join Date
    Jan 2004
    Posts
    153
    Hi flyboj,

    Thanks for your explanation. It works fine.

    Regards,
    JD

Posting Permissions

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