Oracle - ORA-06502: PL/SQL: numeric or value error (DBMS_OUTPUT)

前端 未结 2 1321
闹比i
闹比i 2020-12-12 02:09

I implemented a function that returns clob data-type, and I would like to print the result in DBMS Output. Unfortunately, I am getting

2条回答
  •  無奈伤痛
    2020-12-12 03:06

    The following procedure will better:

    • Oracle 10g has limitation on put_line (a maximum of 32767 characters), But Oracle before 10g has a maximum of 255 characters limitation.
    • the 'put_line' adding end of line on every iteration loop during output clob. So we use put() better (and 'DBMS_OUTPUT.NEW_LINE' at end).
        PROCEDURE print_clob( p_clob in clob ) IS
            v_offset number default 1;
            v_chunk_size number := 255; 
          BEGIN
            LOOP
              EXIT when v_offset > dbms_lob.getlength(p_clob);
              dbms_output.put( dbms_lob.substr( p_clob, v_chunk_size, v_offset ) );
              v_offset := v_offset +  v_chunk_size;
            END LOOP;
            DBMS_OUTPUT.NEW_LINE;  
          END print_clob;
    

提交回复
热议问题