DB2: How to insert a clob with line breaks

Zombies picture Zombies · Oct 1, 2010 · Viewed 10.8k times · Source

I have a simple thing which I want to do, yet is so frustrating in attempting and completing. I just want to take some value such as this:

'a value with
line breaks'

And insert it into a CLOB field and retain the line breaks in DB2. Something like this statement

insert into some_table (the_clob_field) VALUES('a value with
line breaks');

causes a value with line breaks to be inserted.

Answer

Fred Sobotka picture Fred Sobotka · Oct 21, 2010

Another alternative is

insert into some_table (the_clob_field) VALUES('a value with ' || chr(10)
||'line breaks');