| View previous topic :: View next topic |
| Author |
Message |
Meursault Guest
|
Posted: Sun Jul 30, 2006 6:02 pm Post subject: Space instead of empty string |
|
|
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
|
Posted: Sun Jul 30, 2006 8:50 pm Post subject: Re: Space instead of empty string |
|
|
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
|
Posted: Sun Jul 30, 2006 10:31 pm Post subject: Re: Space instead of empty string |
|
|
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
|
Posted: Sun Jul 30, 2006 11:55 pm Post subject: Re: Space instead of empty string |
|
|
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
|
Posted: Mon Jul 31, 2006 2:14 pm Post subject: Re: Space instead of empty string |
|
|
| 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 |
|
 |
|