BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Space instead of empty string

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Meursault
Guest





PostPosted: Sun Jul 30, 2006 6:02 pm    Post subject: Space instead of empty string Reply with quote



I'm switching from BDE to DBX. I used to do everything in BDE with automatic trim and now I'm having problem because dbx client returns empty fixed char fields as space (' ' instead of '') which doesn't go well with my old code.

I understand that this is on purpose (VARCHAR-CHAR distinction) but is there any simple workaround for this behaviour?

Thanx
Back to top
Bill Todd
Guest





PostPosted: Sun Jul 30, 2006 8:50 pm    Post subject: Re: Space instead of empty string Reply with quote



Since you have not provided any information about the circumstances
where this is a problem in your program it is difficult to suggest a
solution. If the problem occurs with data that is in a ClientDataSet
you could write an OnGetData event handler for the DSP and trim the
field values there.

--
Bill Todd (TeamB)
Back to top
Meursault
Guest





PostPosted: Sun Jul 30, 2006 10:31 pm    Post subject: Re: Space instead of empty string Reply with quote



This occures even when I use TSQLQuery directly and try
to read the value Q.FieldByName('field').AsString.
If the DB record is empty ('') the above line returns ' '.

As I understand, this is common behaviour;

QUOTED (http://www.visoco.com/forum/about82.html):
Yes, Open-Client doesn't return an empty string but a string
filled with a space. We decided to leave this feature to
distinguish CHAR datatype from VARCHAR datatype.
Back to top
Bill Todd
Guest





PostPosted: Sun Jul 30, 2006 11:55 pm    Post subject: Re: Space instead of empty string Reply with quote

Meursault wrote:

Quote:
This occures even when I use TSQLQuery directly and try
to read the value Q.FieldByName('field').AsString.
If the DB record is empty ('') the above line returns ' '.

As I understand, this is common behaviour;

Yes, what you see is the correct behavior. I was just suggesting a way
that you could change the data to what your code expects if you are
using a CDS. Unfortunately, there is no convenient event where you can
edit the data if you are just using TSQLQuery and manipulating the data
in code.

--
Bill Todd (TeamB)
Back to top
Martijn Tonies
Guest





PostPosted: Mon Jul 31, 2006 2:14 pm    Post subject: Re: Space instead of empty string Reply with quote

Quote:
This occures even when I use TSQLQuery directly and try
to read the value Q.FieldByName('field').AsString.
If the DB record is empty ('') the above line returns ' '.

As I understand, this is common behaviour;

QUOTED (http://www.visoco.com/forum/about82.html):
Yes, Open-Client doesn't return an empty string but a string
filled with a space. We decided to leave this feature to
distinguish CHAR datatype from VARCHAR datatype.

Depending on the driver, the TrimChar parameter set to
TRUE should trim trailing spaces. You can set this parameter
in TSQLConnection.


--
Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.