oracle-databaseinsertnclob

Oracle insert NCLOB data into NVARCHAR2


I am tyring to insert NCLOB data into NVARCHAR2.it is showing error ORA - 06512 in stored procedure.

How to fix this error?.


Solution

  • You didn't share much information so it is difficult to guess what you did and why Oracle complained about it. Though, would TO_NCHAR do any good?

    TO_NCHAR (character) converts a character string, CHAR, VARCHAR2, CLOB, or NCLOB value to the national character set. The value returned is always NVARCHAR2

    SQL> create table test (col_nclob nclob);
    
    Table created.
    
    SQL> create table test2 (col_nvarchar2 nvarchar2(20));
    
    Table created.
    
    SQL> insert into test values ('x');
    
    1 row created.
    
    SQL> insert into test2 (col_nvarchar2)
      2    select to_nchar(t.col_nclob) from test t;
    
    1 row created.
    
    SQL>