views:

209

answers:

2

I need to do a query that updates text with 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?

+2  A: 

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. IDS 11 has a function ASCII() built-in, but still doesn't have an analogue of CHR() which is included in the 'ascii' package.

Jonathan Leffler
A: 
SELECT 'Wibble' + CHAR(13) + CHAR(10) + 'Wobble'

Puts in the carriage return and the new line like \r\n in C#. You might want both if the text is ever going to be exported into a document anywhere because sometimes just newline -\n char(10) - appears as a box character for some very dreary reason that I've forgotten/never really got :-)

Philip Bathe
this is cool, but the thing is that I need to create the string on a stored procedure, not on .net
sergiogx