You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Brian Bonner <br...@paraware.com> on 2005/08/29 23:47:10 UTC

Inserting a new line (\n) via sql script into Derby

How do I insert a string with a linefeed into derby via an SQL script 
with ij?

The string literal that java would insert would look like this:  
"line1\nline2".

I need to insert it via an SQL script.  I've tried using unicode \u000A 
and \n and neither will work.
i.e.  insert into test (id, test) values (1, 'line1\u000Aline2');  (or 
line1\nline2 respectively)

When I select the contents, I get the line1\u000Aline2  or line1\nline2 
back out and not the line feed I was expecting (ok, hoping) to see:

ie.

line1
line2

Is this possible?

-- 
Brian



Re: Inserting a new line (\n) via sql script into Derby

Posted by Brian Bonner <br...@paraware.com>.
Simmi,

This does not work for derby.  char returns the character string 
representation.  for 10, it returns '6     '.  I'm aware of other DB's 
using chr(10).

Brian



simmi iyer wrote:

>This method works for many other databases. Not sure
>about Derby but try it out.
>
>insert into table1 (id,test)
>values(1,'try'||char(10)||'try')
>
>
>
>--- Brian Bonner <br...@paraware.com> wrote:
>
>  
>
>>ok, well, I thought I unicodeEscape was what I
>>needed, but I tried:
>>
>>java -cp derbyclient.jar;derbytools.jar
>>-Dij.unicodeEscape=on 
>>org.apache.derby.tools.ij
>>insert into test (id, test) values (1,
>>'line1\u000Aline2');
>>
>>and I still got:
>>line1\u000Aline2 when I selected the rows for test.
>>
>>Any ideas?
>>
>>Brian
>>
>>
>>
>>Brian Bonner wrote:
>>
>>    
>>
>>>I think I found it:
>>>*ij.unicodeEscape= { onoff }*
>>>
>>>Brian
>>>
>>>
>>>Brian Bonner wrote:
>>>
>>>      
>>>
>>>>How do I insert a string with a linefeed into
>>>>        
>>>>
>>derby via an SQL script 
>>    
>>
>>>>with ij?
>>>>
>>>>The string literal that java would insert would
>>>>        
>>>>
>>look like this:  
>>    
>>
>>>>"line1\nline2".
>>>>
>>>>I need to insert it via an SQL script.  I've
>>>>        
>>>>
>>tried using unicode 
>>    
>>
>>>>\u000A and \n and neither will work.
>>>>i.e.  insert into test (id, test) values (1,
>>>>        
>>>>
>>'line1\u000Aline2');  
>>    
>>
>>>>(or line1\nline2 respectively)
>>>>
>>>>When I select the contents, I get the
>>>>        
>>>>
>>line1\u000Aline2  or 
>>    
>>
>>>>line1\nline2 back out and not the line feed I was
>>>>        
>>>>
>>expecting (ok, 
>>    
>>
>>>>hoping) to see:
>>>>
>>>>ie.
>>>>
>>>>line1
>>>>line2
>>>>
>>>>Is this possible?
>>>>
>>>>        
>>>>
>>    
>>
>
>
>__________________________________________________
>Do You Yahoo!?
>Tired of spam?  Yahoo! Mail has the best spam protection around 
>http://mail.yahoo.com 
>  
>


Re: Inserting a new line (\n) via sql script into Derby

Posted by simmi iyer <si...@yahoo.com>.
This method works for many other databases. Not sure
about Derby but try it out.

insert into table1 (id,test)
values(1,'try'||char(10)||'try')



--- Brian Bonner <br...@paraware.com> wrote:

> ok, well, I thought I unicodeEscape was what I
> needed, but I tried:
> 
> java -cp derbyclient.jar;derbytools.jar
> -Dij.unicodeEscape=on 
> org.apache.derby.tools.ij
> insert into test (id, test) values (1,
> 'line1\u000Aline2');
> 
> and I still got:
> line1\u000Aline2 when I selected the rows for test.
> 
> Any ideas?
> 
> Brian
> 
> 
> 
> Brian Bonner wrote:
> 
> > I think I found it:
> > *ij.unicodeEscape= { onoff }*
> >
> > Brian
> >
> >
> > Brian Bonner wrote:
> >
> >> How do I insert a string with a linefeed into
> derby via an SQL script 
> >> with ij?
> >>
> >> The string literal that java would insert would
> look like this:  
> >> "line1\nline2".
> >>
> >> I need to insert it via an SQL script.  I've
> tried using unicode 
> >> \u000A and \n and neither will work.
> >> i.e.  insert into test (id, test) values (1,
> 'line1\u000Aline2');  
> >> (or line1\nline2 respectively)
> >>
> >> When I select the contents, I get the
> line1\u000Aline2  or 
> >> line1\nline2 back out and not the line feed I was
> expecting (ok, 
> >> hoping) to see:
> >>
> >> ie.
> >>
> >> line1
> >> line2
> >>
> >> Is this possible?
> >>
> >
> 
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Inserting a new line (\n) via sql script into Derby

Posted by Brian Bonner <br...@paraware.com>.
ok, well, I thought I unicodeEscape was what I needed, but I tried:

java -cp derbyclient.jar;derbytools.jar -Dij.unicodeEscape=on 
org.apache.derby.tools.ij
insert into test (id, test) values (1, 'line1\u000Aline2');

and I still got:
line1\u000Aline2 when I selected the rows for test.

Any ideas?

Brian



Brian Bonner wrote:

> I think I found it:
> *ij.unicodeEscape= { onoff }*
>
> Brian
>
>
> Brian Bonner wrote:
>
>> How do I insert a string with a linefeed into derby via an SQL script 
>> with ij?
>>
>> The string literal that java would insert would look like this:  
>> "line1\nline2".
>>
>> I need to insert it via an SQL script.  I've tried using unicode 
>> \u000A and \n and neither will work.
>> i.e.  insert into test (id, test) values (1, 'line1\u000Aline2');  
>> (or line1\nline2 respectively)
>>
>> When I select the contents, I get the line1\u000Aline2  or 
>> line1\nline2 back out and not the line feed I was expecting (ok, 
>> hoping) to see:
>>
>> ie.
>>
>> line1
>> line2
>>
>> Is this possible?
>>
>


Re: Inserting a new line (\n) via sql script into Derby

Posted by Brian Bonner <br...@paraware.com>.
Thomas that works, although I was hoping for something that was less 
sensitive to whitespace (specifically carriage returns).

Brian



Thomas J. Taylor wrote:

>What's wrong with just using the <ENTER> key?
>- Thomas
>
>ij> create table test (value varchar(60));
>0 rows inserted/updated/deleted
>ij> insert into test values ('First Line
>Second Line');
>1 row inserted/updated/deleted
>ij> select * from test;
>VALUE
>------------------------------------------------------------
>First Line
>Second Line 
>
>-----Original Message-----
>From: Brian Bonner [mailto:brian.bonner@paraware.com] 
>Sent: Monday, August 29, 2005 10:03 PM
>To: Derby Discussion
>Subject: Re: Inserting a new line (\n) via sql script into Derby
>
>I think I found it: 
>
>*ij.unicodeEscape= { onoff }*
>
>Brian
>
>
>
>Brian Bonner wrote:
>
>  
>
>>How do I insert a string with a linefeed into derby via an SQL script 
>>with ij?
>>
>>The string literal that java would insert would look like this:  
>>"line1\nline2".
>>
>>I need to insert it via an SQL script.  I've tried using unicode 
>>\u000A and \n and neither will work.
>>i.e.  insert into test (id, test) values (1, 'line1\u000Aline2');  (or
>>line1\nline2 respectively)
>>
>>When I select the contents, I get the line1\u000Aline2  or
>>line1\nline2 back out and not the line feed I was expecting (ok,
>>hoping) to see:
>>
>>ie.
>>
>>line1
>>line2
>>
>>Is this possible?
>>
>>    
>>
>
>
>
>  
>


RE: Inserting a new line (\n) via sql script into Derby

Posted by "Thomas J. Taylor" <th...@itqa.miami.edu>.
What's wrong with just using the <ENTER> key?
- Thomas

ij> create table test (value varchar(60));
0 rows inserted/updated/deleted
ij> insert into test values ('First Line
Second Line');
1 row inserted/updated/deleted
ij> select * from test;
VALUE
------------------------------------------------------------
First Line
Second Line 

-----Original Message-----
From: Brian Bonner [mailto:brian.bonner@paraware.com] 
Sent: Monday, August 29, 2005 10:03 PM
To: Derby Discussion
Subject: Re: Inserting a new line (\n) via sql script into Derby

I think I found it: 

*ij.unicodeEscape= { onoff }*

Brian



Brian Bonner wrote:

> How do I insert a string with a linefeed into derby via an SQL script 
> with ij?
>
> The string literal that java would insert would look like this:  
> "line1\nline2".
>
> I need to insert it via an SQL script.  I've tried using unicode 
> \u000A and \n and neither will work.
> i.e.  insert into test (id, test) values (1, 'line1\u000Aline2');  (or
> line1\nline2 respectively)
>
> When I select the contents, I get the line1\u000Aline2  or
> line1\nline2 back out and not the line feed I was expecting (ok,
> hoping) to see:
>
> ie.
>
> line1
> line2
>
> Is this possible?
>




Re: Inserting a new line (\n) via sql script into Derby

Posted by Brian Bonner <br...@paraware.com>.
I think I found it: 

*ij.unicodeEscape= { onoff }*

Brian



Brian Bonner wrote:

> How do I insert a string with a linefeed into derby via an SQL script 
> with ij?
>
> The string literal that java would insert would look like this:  
> "line1\nline2".
>
> I need to insert it via an SQL script.  I've tried using unicode 
> \u000A and \n and neither will work.
> i.e.  insert into test (id, test) values (1, 'line1\u000Aline2');  (or 
> line1\nline2 respectively)
>
> When I select the contents, I get the line1\u000Aline2  or 
> line1\nline2 back out and not the line feed I was expecting (ok, 
> hoping) to see:
>
> ie.
>
> line1
> line2
>
> Is this possible?
>