IBM Support

How to use newline and carriage returns within SQL in dbaccess

Question & Answer


Question

How do you insert a newline / carriage return into a character field in dbaccess?

Cause

Sometimes there is the need to insert a newline / carriage return character into a character (varchar, lvarchar, etc.) column of a table to reflect a paragraph type format.

Answer

Within dbaccess or the ISQL menu, one could use the following steps to accomplish this:

create table t2 (c1 lvarchar);

insert into t2 values ('test'||chr(10)||chr(13)||'more test');

Selecting the data within dbaccess, one can see that the newline / carriage return is in the table by viewing the output format of the following select statement:

select * from t1;

c1 test
more test


1 row(s) retrieved.

[{"Product":{"code":"SSVT2J","label":"Informix Tools"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Component":"Informix SQL (I-SQL)","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF010","label":"HP-UX"},{"code":"PF016","label":"Linux"},{"code":"PF027","label":"Solaris"}],"Version":"7.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
20 January 2022

UID

swg21686620