Populated zero in decimal field when given space as a value

Database
KVB
Enthusiast

Populated zero in decimal field when given space as a value

Hi

There is a space in my flat file and it's being populated to a decimal field in the target.It inserted as zero.Any pointers on this?

3 REPLIES
KVB
Enthusiast

Re: Populated zero in decimal field when given space as a value

CT SAMPLE(ID DECIMAL(5,2));

INS INTO SAMPLE VALUES(' ');

SEL * FROM SAMPLE;

Enthusiast

Re: Populated zero in decimal field when given space as a value

CT Sample_1(ID DECIMAL(5,2));
 INS INTO Sample_1 VALUES(' ');
  INS INTO Sample_1 VALUES(Null);
 SEL * FROM Sample_1;

Hope the above explains. if you are trying to view the NULL value. space defined for a decimal will be casted internaly into a decimal number and defaults to 0.

if you try to insert a character, then it fails. Also if you insert 2 more values like insert into sample_1 values('1'); and insert into sample_1 values (1). The first query succeeds and the second one fails unless you define it as a multi set table. if defined as a ,multiset table then there will be 2 values for 1.00.

KVB
Enthusiast

Re: Populated zero in decimal field when given space as a value

Thanks!!