IBM Support

How could you insert a multiline paragraph with blank lines as one record into a table using INSERT SQL statement?

Question & Answer


Question

When you insert a multiline paragraph containing blank lines (LF:line feed - X'0A') into a table as one record, the INSERT statement may fail to preserve the blank lines. For example, you want to insert a multiline paragrah with blank lines as below into a table named T3. $ cat paragraph.sql INSERT INTO t3 VALUES ('aaaaa bbbbb ccccc')%% NOTE: The table T3 has definition as: $ db2 "create table T3(desc varchar(30))" When you invoke the paragraph.sql file to insert the value, after insertion you will find the column desc doesn't contain any of the bank lines. $ db2 -td%% -vf paragraph.sql $ db2 "select desc, hex(desc) as hex_value from t3" DESC HEX_VALUE ------------------------------ ------------------------------------------------------------ aaaaa bbbbb ccccc 6161616161206262626262206363636363 1 record(s) selected. So how could you insert a paragraph with blank lines into a table as one record?

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"Database Objects\/Config - Tables","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"},{"code":"PF033","label":"Windows"}],"Version":"9.7;9.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Log InLog in to view more of this document

This document has the abstract of a technical article that is available to authorized users once you have logged on. Please use Log in button above to access the full document. After log in, if you do not have the right authorization for this document, there will be instructions on what to do next.

Document Information

Modified date:
30 April 2025

UID

swg21404777