PL/SQL (MOSC)

MOSC Banner

Single row cursor for short text string from dual produces CHAR(32767)

Hi

19.9

I have noticed some suspicious thing regarding dual.

I will create an example. At the moment, here you can see that from mytab, there comes only single row.

Then I will dump the datatype to output.

SQL> set serveroutput on size unlimited;
declare
a clob;
  l_msg_content_begin CLOB := EMPTY_CLOB();
  CURSOR cur
    IS
    with mytab as (
      select 'SOMERANDOMTABLE' as main_table from dual
      --union select 'ALSOSOMERANDOMTABLE' as main_table from dual
    )
    select main_table, lower_main_table
    from (
      select main_table, lower(main_table) as lower_main_table
      from mytab
    )
    order by 1 desc;
  rec cur%rowtype;
BEGIN
  FOR rec IN cur LOOP
    dbms_output.put_line(rec.main_table);
    select dump(rec.lower_main_table) into a from dual;
    dbms_output.put_line(a);

    -- ORA-06502: PL/SQL: numeric or value error: character string buffer too small
    -- If you have only one row from dual, then you get error if you uncomment this
    --      "--l_msg_content_begin.....":
    -- With 2 or more rows from dual, all good
    --l_msg_content_begin := 'blabla '||rec.lower_main_table||' blablabla '||rec.lower_main_table||'bla'||UTL_TCP.CRLF;
  END

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center