Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Can't save an empty string
Sat, Sep 22 2007 7:13 AMPermanent Link

Mats Berggren
Hello

I can't save an empty text field. When I read the field it contains a blank instead of an empty string.
I use Elevatedb VCL Trial (Unicode) Version 1.05 with Delphi 2006.

The field I try to save is defined as:

Field: Citattab.fktabell2
Type: Char
Collation: SVE_CI
Length: 1
Nullable: Yes
Generated: No

Here is a code example. Before read the variable s1 is empty but after read it is blank.
 
 var s1:string;

 s1 := ''; (* empty string *)
 cf.indexname:='';
 cf.first;
 cf.edit;
 cf.fieldbyname('fktabell2').asstring := s1; (* saving an empty field *)
 cf.post;
 cf.first;

 if (s1 = '') then application.messagebox('string s1 is empty','before read'); (* displayed !!!!!!!*)
 if (s1 = ' ') then application.messagebox('string s1 is blank','before read');

 s1 := cf.fieldbyname('fktabell2').asstring; (* reading the empty field *)

 if (s1 = '') then application.messagebox('string s1 is empty','after read');
 if (s1 = ' ') then application.messagebox('string s1 is blank','after read'); (* displayed !!!!!!!!!*)


What is wrong here? Shouldn't it be possible to save empty strings? Are blanks always appended to empty fields?

I  would be very grateful if I could get an answer to this problem.

Thank you in advance

Mats Berggren
Sat, Sep 22 2007 11:09 AMPermanent Link

Eryk Bottomley
Mats

> Field: Citattab.fktabell2
> Type: Char

You probably need to use VARCHAR, not CHAR (Disclaimer: I don't use
ElevateDB so I haven't actually tried this).

Eryk
Sat, Sep 22 2007 12:53 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Mats,

<< What is wrong here? Shouldn't it be possible to save empty strings? Are
blanks always appended to empty fields? >>

Eryk is correct.  You need to use a VARCHAR instead of a CHAR if you don't
want the column blank-padded.

--
Tim Young
Elevate Software
www.elevatesoft.com

Image