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 6626901
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:56:58+00:00 2026-05-25T21:56:58+00:00

I have the following PLSQL functions that returns following error when returning a large

  • 0

I have the following PLSQL functions that returns following error when returning a large data.

ORA-06502: PL/SQL: numeric or value error: character string buffer too small 

MODIFIED PLSQL FUNCTION

 CREATE OR REPLACE FUNCTION FRDUSER.FRD_TELECOP_DYN_REP_SELECT_OPT (p_select IN VARCHAR2)
   RETURN CLOB
AS
 -- v_temp           CLOB;
  v_out            CLOB; 
  TYPE RefCurTyp   IS REF CURSOR;      
 -- len     BINARY_INTEGER;
  v_cursor         RefCurTyp; 
  c_key            VARCHAR2 (1000);
  c_value          VARCHAR2 (1000);
  separator        VARCHAR2(3);

BEGIN

    OPEN v_cursor FOR p_select;

    -- Fetch rows from result set one at a time:
    separator := '';     

    LOOP      

      FETCH v_cursor INTO c_key,c_value;        
        EXIT WHEN v_cursor%NOTFOUND;

   --      dbms_lob.createtemporary(v_out, TRUE);
  --       dbms_lob.open(v_out, dbms_lob.lob_readwrite);
         v_out := v_out ||  separator || c_key || ',' || c_value;  
  --       dbms_lob.append(v_out,  v_temp);
         separator := ':';  

    END LOOP;

    -- Close cursor:
    CLOSE v_cursor;
    RETURN (v_out);
END;
/

I am executing the function as below,

            SELECT   CASE  
                WHEN OPTIONS_TYPE = 'S' THEN    OPTIONS_VALUES
                WHEN OPTIONS_TYPE = 'D'  THEN TO_CLOB(FRD_TELECOP_DYN_REP_SELECT_OPT (OPTIONS_VALUES))  
                END  
      FROM FRD_REP_FW_REP_TEMPLATES A, FRD_REP_FW_TEMPLATES B
        WHERE A.REP_ID=1123 AND  A.TEMP_ID=B.TEMP_ID  
        ORDER BY A.REP_TEMP_ID ASC

When i ran the above sql query it throw following error
ORA-00932: inconsistent datatypes: expected CHAR got CLOB

The parameter to the sql function(options_values) contains sql query.

  • 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-25T21:56:59+00:00Added an answer on May 25, 2026 at 9:56 pm

    I suspect you’re overcomplicating your logic a bit. You probably just need something like this (assuming that you actually need to dynamically pass the query in to the function)

    SQL> create table clob_test (
      2    key varchar2(100),
      3    val varchar2(100)
      4  );
    
    Table created.
    
    SQL> insert into clob_test
      2    select level, dbms_random.string( 'A', 100 )
      3      from dual
      4   connect by level <= 10000;
    
    10000 rows created.
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  create or replace function return_clob
      2    return clob
      3  as
      4    v_out clob;
      5    v_sql varchar2(1000) := 'select key, val from clob_test';
      6    v_key varchar2(100);
      7    v_val varchar2(100);
      8    v_rc  sys_refcursor;
      9  begin
     10    open v_rc for v_sql;
     11    loop
     12      fetch v_rc into v_key, v_val;
     13      exit when v_rc%notfound;
     14      v_out := v_out || v_key || ', ' || v_val;
     15    end loop;
     16    return v_out;
     17* end;
    SQL> /
    
    Function created.
    
    SQL> select return_clob from dual;
    
    RETURN_CLOB
    --------------------------------------------------------------------------------
    
    1, tzGWFXwKLgrRTGzTGbWMYMjVniIVMmCuGYGYydcrArHPRLExoFAJsZVhhPrRKyERExqRkbLGSebqX
    << more lob data removed>>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following error message. 2011-08-08 14:27:09 [E]: xxx - ORA-06502: PL/SQL: numeric or
I'm following a tutorial on PL/SQL http://www.plsqltutorial.com/plsql-procedure/ . I have created procedure with the
In the JDBC code, I have the following that is working with SQL Server:
I have the PL/SQL code that is similar to the following snippet: create or
I have the following block of PLSQL that succeeds when ln_length is 4000 characters
I have the following Oracle PL/SQL codes that may be rusty from you guys
I have the following PL/SQL being sent to a remote oracle 11gr2 server via
I have a String stored in a table in the following key-value format: Key1☺Value1☺Key2☺Value2☺KeyN☺ValueN☺.
Lets say we have the following: create view view_1 as ( select key, data
Hi I have following data in the table: ID-----startDate----endDate 5549 2008-05-01 4712-12-31 5567 2008-04-17

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.