Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5997421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:15:42+00:00 2026-05-23T00:15:42+00:00

I am getting inconsistent datatype error message and I am not sure why. I

  • 0

I am getting inconsistent datatype error message and I am not sure why. I need some guidance to figure this out.

I am creating two types as:

My universe table have following columns with column type:


Column Name                          Data Type

PON                                  VARCHAR2(25 BYTE)
RPON                             VARCHAR2(25 BYTE)
SUPPLIER_NAME                    VARCHAR2(255 BYTE)
SUB_SUPPLIER_NAME                    VARCHAR2(255 BYTE)
SOURCE_NO                            VARCHAR2(40 BYTE)
CKR                                  VARCHAR2(200 BYTE)
LEC_ID                           VARCHAR2(200 BYTE)
ICSC                             VARCHAR2(10 BYTE)
ACTL_ST                          VARCHAR2(10 BYTE)
ADW_ST                           VARCHAR2(10 BYTE)
PROJ_ID                          VARCHAR2(100 BYTE)
MOVE_TO_INV_DT                        DATE
IE_DT                                 DATE
DDD_DT                                DATE
EFF_BILL_DT                               DATE
ACTION                           VARCHAR2(10 BYTE)
SERVICE                          VARCHAR2(10 BYTE)
AFP                                  VARCHAR2(10 BYTE)
ACNA                             VARCHAR2(10 BYTE)
SERVICE_NAME                     VARCHAR2(255 BYTE)
UPLOAD_DT                                 DATE
PROGRAM                          VARCHAR2(50 BYTE)
INITIATIVE_ID                        NUMBER
ACOST                                NUMBER
ACOST_IND                            VARCHAR2(25 BYTE)
MAPFILE                          VARCHAR2(100 BYTE)

Row Type

   create or replace
TYPE test_COMP_REPORT_ROW_TYPE AS OBJECT (
  PON   VARCHAR2(25 BYTE),
  RPON  VARCHAR2(25 BYTE),
  VENDOR VARCHAR2(255 BYTE),
  SUB_SUPPLIER VARCHAR2(255 BYTE),
  SOURCE_NO VARCHAR2(40 BYTE),
  ATT_CKT_ID VARCHAR2(200 BYTE),
  LEC_ID VARCHAR2(200 BYTE),
  ICSC VARCHAR2(10 BYTE),
  STATE VARCHAR2(10 BYTE),
  PROJECT_ID VARCHAR2(100 BYTE),
  ACTION VARCHAR2(10 BYTE),
  SERVICE_SPEED VARCHAR2(10 BYTE),
  SERVICE_NAME VARCHAR(255 BYTE),
  INEFFECT_DATE DATE,
  EVENT_DATE DATE, 
  DUE_DATE DATE, 
  ACOST NUMBER
  )

Tab Type

create or replace type test_COMP_REPORT_TAB_TYPE 
           AS TABLE OF test_COMP_REPORT_ROW_TYPE

Here is the Function which is using this type:

create or replace
FUNCTION test_comp_report_func
  (
    start_dt_h IN VARCHAR2 DEFAULT NULL,
    end_dt_h   IN VARCHAR2 DEFAULT NULL,
    year_h     IN VARCHAR2 DEFAULT NULL )
  RETURN test_comp_report_tab_type pipelined
  IS
  e_sql LONG;
  program_v VARCHAR2(10);

v_row test_comp_report_row_type := test_comp_report_row_type(NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL,
                                                             NULL
                                                             );

  TYPE rectyp IS REF CURSOR;
    rrc_rectyp rectyp;
TYPE recordvar IS RECORD
( 
  PON   VARCHAR2(25 BYTE),
  RPON  VARCHAR2(25 BYTE),
  VENDOR VARCHAR2(255 BYTE),
  SUB_SUPPLIER VARCHAR2(255 BYTE),
  SOURCE_NO VARCHAR2(40 BYTE),
  ATT_CKT_ID VARCHAR2(200 BYTE),
  LEC_ID VARCHAR2(200 BYTE),
  ICSC VARCHAR2(10 BYTE),
  STATE VARCHAR2(10 BYTE),
  PROJECT_ID VARCHAR2(100 BYTE),
  ACTION VARCHAR2(10 BYTE),
  SERVICE_SPEED VARCHAR2(10 BYTE),
  SERVICE_NAME VARCHAR(255 BYTE),
  INEFFECT_DATE DATE,
  EVENT_DATE DATE, 
  DUE_DATE DATE, 
  ACOST NUMBER
);
  res_rec recordvar;

BEGIN  

    e_sql := e_sql || 'SELECT 
                      PON,
                      RPON,
                      SUPPLIER_NAME VENDOR, 
                      SUB_SUPPLIER_NAME SUB_SUPPLIER, 
                      SOURCE_NO,
                      CKR,
                      LEC_ID,
                      ICSC, 
                      ACTL_ST,
                      ADW_ST STATE, 
                      PROJ_ID,
                      ACTION,
                      SERVICE SPEED, 
                      AFP,
                      ACNA,
                      SERVICE_NAME,
                      IE_DT, 
                      MOVE_TO_INV_DT EVENTDAT,
                      DDD_DT DUEDATE, 
                      EFF_BILL_DT,
                      ACOST
                    FROM UNIVERSE
                    WHERE to_date(IE_DT) between to_date(nvl(''01/01/2000'', ''01/01/2000''), ''MM/DD/YYYY'') 
                      and to_date(nvl(''12/31/2009'', to_char(trunc(add_months(sysdate, 12),''year'')-1,''MM/DD/YYYY'')), ''MM/DD/YYYY'')
                    AND PROGRAM = ''T45sONNET''
                    AND nvl(trim(ACOST_IND), ''NULL'') not in (''INVALID-2005'')
                    ORDER BY ACTION';

dbms_output.put_line(e_sql);
OPEN rrc_rectyp FOR e_sql;
  LOOP
      FETCH rrc_rectyp INTO res_rec;
      EXIT WHEN rrc_rectyp%NOTFOUND;
      v_row.PON            := res_rec.PON;
      v_row.RPON           := res_rec.RPON;
      v_row.VENDOR         := res_rec.VENDOR;
      v_row.SUB_SUPPLIER   := res_rec.SUB_SUPPLIER;
      v_row.SOURCE_NO      := res_rec.SOURCE_NO;
      v_row.ATT_CKT_ID     := res_rec.ATT_CKT_ID;
      v_row.LEC_ID         := res_rec.LEC_ID;
      v_row.ICSC           := res_rec.ICSC;
      v_row.STATE          := res_rec.STATE;
      v_row.PROJECT_ID     := res_rec.PROJECT_ID;
      v_row.ACTION         := res_rec.ACTION;
      v_row.SERVICE_SPEED  := res_rec.SERVICE_SPEED;
      v_row.SERVICE_NAME   := res_rec.SERVICE_NAME;
      v_row.INEFFECT_DATE  := res_rec.INEFFECT_DATE;
      v_row.EVENT_DATE     := res_rec.EVENT_DATE;
      v_row.DUE_DATE       := res_rec.DUE_DATE;
      v_row.ACOST          := res_rec.ACOST;
      pipe ROW(v_row);
  END LOOP;
  return;

end test_comp_report_func;

I have tried to debug issue but still am not able to find my way out and would appreciate if SO Community can guide.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T00:15:43+00:00Added an answer on May 23, 2026 at 12:15 am

    I first wrote an answer trying to reproduce your error but you’ve changed your question quite a bit so I’m starting again from scratch.

    First a few remarks:

    • By your own account you’re quite new to PL/SQL yet you’re using pretty advanced features: dynamic SQL, pipelined functions, SQL Objects. Let’s try to begin with something simpler at first (I’ll show you how you can work with static SQL, this would be sufficient 99.9% of the time).
    • When you hit a problem you need to decompose your code to see what is working and what is not. That usually means simplifying your code until it is so simple it starts to work, then bring back the complex elements of your code one by one until you hit the problem again.
    • When you provide a test case, try to make it as simple as possible 🙂 It’ll be easier for people to help you, but more importantly in most of the cases, building the test case will help you find the solution yourself since this will force you to decompose your complex code (see previous point). My rule of thumb (FWIW) is that code that is displayed with a scroll bar (either horizontal or vertical) in SO is too big for a test case and needs to be trimmed if possible.

    I ran your code and got the ORA-00932 on the fetch line. When I replace the SQL with static SQL the error is more explicit:

    SQL> CREATE OR REPLACE FUNCTION test_comp_report_func
      2     RETURN test_comp_report_tab_type
      3     PIPELINED IS
      4     TYPE recordvar IS RECORD(
      5        PON           VARCHAR2(25 BYTE),
               (...snip...)
     21        ACOST         NUMBER);
     22     res_rec recordvar;
     23     v_row   test_COMP_REPORT_ROW_TYPE;
     24     CURSOR rrc_rectyp IS
     25        SELECT PON,
                      (...snip...)
     45               ACOST
     46          FROM UNIVERSE;
     48  BEGIN
     49     OPEN rrc_rectyp;
     50     LOOP
     51        FETCH rrc_rectyp
     52           INTO res_rec;
     54        EXIT WHEN rrc_rectyp%NOTFOUND;
     55        /*...*/
     56        PIPE ROW(v_row);
     57     END LOOP;
     58     RETURN;
     59  END test_comp_report_func;
     60  /
    
    Warning: Function created with compilation errors.
    LINE/COL ERROR
    -------- -----------------------------------------------------------------
    51/7     PL/SQL: SQL Statement ignored
    52/15    PLS-00386: type mismatch found at 'RES_REC' between FETCH cursor
             and INTO variables
    

    Here the problem comes from the fact that your select statement doesn’t have the same number of columns as the number of fields in your record. You can use %rowcount to prevent this:

    CREATE OR REPLACE FUNCTION test_comp_report_func
       RETURN test_comp_report_tab_type
       PIPELINED IS
       v_row   test_COMP_REPORT_ROW_TYPE;
       CURSOR rrc_rectyp IS
          SELECT PON, RPON, SUPPLIER_NAME VENDOR, SUB_SUPPLIER_NAME SUB_SUPPLIER,
                 SOURCE_NO, CKR, LEC_ID, ICSC, ACTL_ST, ADW_ST STATE, PROJ_ID,
                 ACTION, SERVICE SPEED, AFP, ACNA, SERVICE_NAME, IE_DT,
                 MOVE_TO_INV_DT EVENTDAT, DDD_DT DUEDATE, EFF_BILL_DT, ACOST
            FROM UNIVERSE;
       res_rec rrc_rectyp%ROWTYPE;
    BEGIN
       OPEN rrc_rectyp;
       LOOP
          FETCH rrc_rectyp
             INTO res_rec;
          EXIT WHEN rrc_rectyp%NOTFOUND;
          v_row.pon := res_rec.pon;
          /*...*/
          PIPE ROW(v_row);
       END LOOP;
       RETURN;
    END test_comp_report_func;
    

    You can even fetch the SQL object directly (with an implicit cursor):

    CREATE OR REPLACE FUNCTION test_comp_report_func
       RETURN test_comp_report_tab_type
       PIPELINED IS
    BEGIN
       FOR res_rec IN (SELECT test_comp_report_row_type(PON, RPON, SUPPLIER_NAME,
                                                         SUB_SUPPLIER_NAME,SOURCE_NO,
                                                         CKR, LEC_ID, ICSC, ACTL_ST,
                                                         PROJ_ID, ACTION, SERVICE,
                                                         SERVICE_NAME, IE_DT, DDD_DT,
                                                         EFF_BILL_DT, ACOST)my_object
                         FROM UNIVERSE) LOOP
          PIPE ROW(res_rec.my_object);
       END LOOP;
       RETURN;
    END test_comp_report_func;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Getting this after solving a Error converting data type nvarchar to datetime error. Using
Getting this error when updating a row via a gridview with a sqldatasource in
I am getting the following error in VisualStudio Inconsistent accessibility: parameter type 'mynamespace.ProgressChangedEvent' is
Ok so I thought it was fixed, but I'm getting totally inconsistent results. I
I getting the following error when I try to connect to my server app
I am getting inconsistent results using multi-touch. I am trying to detect a 2
I'm trying to vectorize a simple function in numpy and getting inconsistent behavior. I
I could use some help. After a few frustrating days of trial and error,
I'm getting inconsistent results depending on whether I get the image directly from the
Getting a NSString as follows: NSString *lastSyncDate = [[items objectAtIndex:0] objectForKey:@LastSyncDate]; This value is:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.