Re: Inserting control characters in SQL
On 14/03/2011 09:26, Bruce Wen wrote: If indeed necessary to insert one control character, you need insert the int value (ASCII code) of the control character, I think. Of course, the column's data type should be int or tinyint. No, it's a control character embedded in a string. I've ended up having to define a function in Java to convert an int to a char for lack of a better idea, but I'm amazed that there isn't a built-in function for this. John English | My old University of Brighton home page is still here: | http://www.it.brighton.ac.uk/staff/je
Re: Inserting control characters in SQL
To convert an int to a char, just use the following statement: char c = (char) 134; You can cast integer to char directly. Is this what you need? -Original Message- From: John English john.fore...@gmail.com To: derby-user@db.apache.org Sent: Thu, Mar 17, 2011 6:00 pm Subject: Re: Inserting control characters in SQL On 14/03/2011 09:26, Bruce Wen wrote: If indeed necessary to insert one control character, you need insert the int value (ASCII code) of the control character, I think. Of course, the column's data type should be int or tinyint. No, it's a control character embedded in a string. I've ended up having to define a function in Java to convert an int to a char for lack of a better idea, but I'm amazed that there isn't a built-in function for this. John English | My old University of Brighton home page is still here: | http://www.it.brighton.ac.uk/staff/je
Re: Inserting control characters in SQL
If indeed necessary to insert one control character, you need insert the int value (ASCII code) of the control character, I think. Of course, the column's data type should be int or tinyint. -Original Message- From: John English john.fore...@gmail.com To: derby-user@db.apache.org Sent: Sat, Mar 12, 2011 12:13 am Subject: Re: Inserting control characters in SQL On 11/03/2011 17:46, John English wrote: On 11/03/2011 17:42, Peter Ondruška wrote: Have you tried \b ? Hmm, silly me. I tried RTFMing -- stupid thing to do! OK, now I've tried it. It doesn't work. LENGTH('\b') == 2, not 1. Any other suggestions? John English | My old University of Brighton home page is still here: | http://www.it.brighton.ac.uk/staff/je
Re: Inserting control characters in SQL
Bruce Wen wrote: If indeed necessary to insert one control character, you need insert the int value (ASCII code) of the control character, I think. Of course, the column's data type should be int or tinyint. Note that Derby strings are UNICODE, not ASCII. The solution is dependent on what you actually want to do. If you want to store ASCII control characters, I would recommend to use an integer column. If you want to store Unicode control characters in CHAR or VARCHAR columns, you can't do that from SQL since Derby does not support feature F393 Unicode escapes in literals (See http://wiki.apache.org/db-derby/SQLvsDerbyFeatures). You can insert Unicode control characters from Java through JDBC, though. -Original Message- From: John English john.fore...@gmail.com To: derby-user@db.apache.org Sent: Sat, Mar 12, 2011 12:13 am Subject: Re: Inserting control characters in SQL On 11/03/2011 17:46, John English wrote: On 11/03/2011 17:42, Peter Ondruška wrote: Have you tried \b ? Hmm, silly me. I tried RTFMing -- stupid thing to do! OK, now I've tried it. It doesn't work. LENGTH('\b') == 2, not 1. Any other suggestions? John English | My old University of Brighton home page is still here: | http://www.it.brighton.ac.uk/staff/je
Inserting control characters in SQL
I have a DDL schema which I am processing using IJ. I want to insert a row into a table containg a backspace character: CREATE TABLE foo (name VARCHAR(20), value VARCHAR(200)); INSERT INTO foo VALUES('first',bs); where bs is an actual backspace character. I foolishly tried CHAR(8) but of course this doesn't do it. Obviously I could write a Java program that does this, but this means reinventing the IJ wheel. Is there any existing way to do this? TIA, John English | My old University of Brighton home page is still here: | http://www.it.brighton.ac.uk/staff/je
Re: Inserting control characters in SQL
Have you tried \b ? Peter On Mar 11, 2011 4:41 PM, John English john.fore...@gmail.com wrote: I have a DDL schema which I am processing using IJ. I want to insert a row into a table containg a backspace character: CREATE TABLE foo (name VARCHAR(20), value VARCHAR(200)); INSERT INTO foo VALUES('first',bs); where bs is an actual backspace character. I foolishly tried CHAR(8) but of course this doesn't do it. Obviously I could write a Java program that does this, but this means reinventing the IJ wheel. Is there any existing way to do this? TIA, John English | My old University of Brighton home page is still here: | http://www.it.brighton.ac.uk/staff/je
Re: Inserting control characters in SQL
On 11/03/2011 17:42, Peter Ondruška wrote: Have you tried \b ? Hmm, silly me. I tried RTFMing -- stupid thing to do! John English | My old University of Brighton home page is still here: | http://www.it.brighton.ac.uk/staff/je
Re: Inserting control characters in SQL
On 11/03/2011 17:46, John English wrote: On 11/03/2011 17:42, Peter Ondruška wrote: Have you tried \b ? Hmm, silly me. I tried RTFMing -- stupid thing to do! OK, now I've tried it. It doesn't work. LENGTH('\b') == 2, not 1. Any other suggestions? John English | My old University of Brighton home page is still here: | http://www.it.brighton.ac.uk/staff/je