Search code examples
oracle-databasecharacter-encodingclob

Declaring a CLOB in an Oracle database with a custom charset


Is it possible to declare a UTF-8 CLOB if the database is set up with the following character sets?

PARAMETER               VALUE
NLS_CHARACTERSET        CL8ISO8859P5
NLS_NCHAR_CHARACTERSET  AL16UTF16

I tried passing a charset name to the declaration, but it looks like it can only accept references to character sets of other objects.

declare
  clob_1 clob character set "AL32UTF8";
begin
  null;
end;

/


Solution

  • I don't think this is possible, see PL/SQL Language Fundamentals

    PL/SQL uses the database character set to represent:

    • Stored source text of PL/SQL units
    • Character values of data types CHAR, VARCHAR2, CLOB, and LONG

    So, in your case you have to use NCLOB which uses AL16UTF16 or try a workaround with BLOB. However, this might become cumbersome.