db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rajesh Kartha <karth...@gmail.com>
Subject Re: A question for derby
Date Sun, 24 Dec 2006 18:13:44 GMT
Hai Feng Li wrote:

> Hi, Dear all,
>
> Below is a test done be me:
>
> ij> create table lhf (luk char(10) for bit data);
> 0 rows inserted/updated/deleted
> ij> connect 
> 'jdbc:derby://nlsdev70.cn.ibm.com:1527/mydb;user=usr;password=pwd';
> ij> insert into lhf values (X'05');
> 1 row inserted/updated/deleted
> ij> insert into lhf values (X'5');
> ERROR 42606: An invalid hexadecimal constant starting with 'X'5'' has 
> been detec
> ted.
> ij> insert into lhf values (X'15');
> 1 row inserted/updated/deleted
>
> Why the blue part can not work? Does it work as expected?
>
> Thanks for your help!
>
> Best Regards,
> Haifeng
> ----------------------------------------------------------------------------------
> WebSphere Information Integrator, IBM China Software Development 
> Laboratory (CSDL)
> Phone: 86-10-82782244 ext.3512 Fax: 86-10-82782244 ext.3251
> Notes: Hai Feng Li/China/IBM E-mail: lihaif@cn.ibm.com
> Address: 8/F, Bld.A, Ying Chuang, No.1, East Road, Shang Di, Beijing 
> 100085, China
> ----------------------------------------------------------------------------------
>
Hi,

Hex values need to represented in two characters (using symbols 0-9 and 
A-F), hence (X'5') is invalid.
(X'05') or (X'50') - depending on values to be entered, are valid Hex 
values.
I am pretty sure other databases  will also throw similar error as Derby 
for  (X'5').

More info on CHAR for BIT DATA in Derby:
http://db.apache.org/derby/docs/10.1/ref/rrefsqlj57924.html

Also, for a CHAR FOR BIT DATA column if the value is smaller than the 
column size , it is padded with a *0x20 *byte value.
(two character hex padding for null)

HTH,
Rajesh






Mime
View raw message