Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add line breaks in a query (Informix)?

I need to do a query that updates text with a line break. I tried using \n but it inserts "\n" literally.

Example:

update table set text = "first line\nsecond line"

I want it to show that text as:

"first line
second line"

and not as "first line\nsecond line".

When I do this with .NET it works, but not on a stored procedure.

Does anyone know how to do this?

like image 278
sergiogx Avatar asked Feb 24 '10 17:02

sergiogx


People also ask

How do I insert a line break in varchar Nvarchar string in SQL Server?

You just concatenate the string and insert a CHAR(13) where you want your line break.

How do I add a new line character in postgresql?

To use "escape sequences" in a string literal you need to use an "extended" constant. You can specify the escape character by prefixing the letter E: UPDATE posts SET body = E'First Line\nSecond line.

How do I get a list of tables in Informix?

Informix iSQL has a command " info tables; " that shows all tables.


1 Answers

You might, perhaps, be looking for the function 'ifx_allow_newline'.

Alternatively, following the suggestion of OMG Ponies, you might be looking for the package 'ascii' from the IIUG Software Archive. Informix now has the functions ASCII() and CHR() built-in. Note that if you have older versions of Informix (anything before 11.50 — 11.70 for CHR()), these functions will not be available and you will need to consider the package from the IIUG archive.

like image 145
Jonathan Leffler Avatar answered Oct 01 '22 06:10

Jonathan Leffler