new line in H2 console

426 views
Skip to first unread message

Nitin

unread,
May 3, 2011, 3:26:23 AM5/3/11
to H2 Database
Hi Group,

In browser H2 console, Following updates filed as is ..inserts \n as
text character not new line character in the field.

update mytable set myfield='first line\nsecond line' where id=1;

I tried \\n and "\n" but no success.

I am using H2 1.2.147 console on windows xp.

Thanks.
Nitin

Thomas Mueller

unread,
May 3, 2011, 3:36:10 PM5/3/11
to h2-da...@googlegroups.com
Hi,

This is not ANSI standard SQL. \n is C style escaping, and not
supported by ANSI SQL. It is supported by MySQL when ANSI SQL mode is
disabled.

The preferred solution is to use a prepared statement:
update mytable set myfield=? where id=?;

Another solution is to use:


update mytable set myfield='first line

second line' where id=1;

Regards,
Thomas

Nitin

unread,
May 10, 2011, 10:52:06 AM5/10/11
to H2 Database
It worked with another solution with multi line :)
Thanks alot.

On May 4, 12:36 am, Thomas Mueller <thomas.tom.muel...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages