Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2003-07

SQLite and NULL Strings...

29 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

James Mills

Hi,

This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know...

I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself.

The problem therein lies in the fact that test3.pas returns "" for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program.

$ ./test2
Creating class
Fields Names -------------------
0 -> channel
1 -> owner
2 -> regTime
3 -> state
4 -> URL
5 -> email
6 -> channelNotice
7 -> joins
8 -> peak
9 -> games
10 -> modeLocked
11 -> mailLevel
12 -> restrict
13 -> entries
14 -> quota
15 -> channelIdle
16 -> noIdle
17 -> lastSuspension
18 -> hideAccess
19 -> keepTopic
20 -> onChannel
21 -> opRestrict
22 -> funMsg
23 -> mustId
24 -> tellAdd
25 -> tellDel
26 -> tellSet
27 -> msgNotice
28 -> topic
29 -> topicSetter
30 -> lastTopic
31 -> autoCmd
32 -> modes
Fields -------------------
0 -> #ProLogiTech prologic 1057934559 REGISTERED 1 1 0 0 1 50 0 OFF NO YES YES NO NO NO NO NO NO NO

$ ./test3
Creating class
Fields Names -------------------
0 -> channelNotice
Fields -------------------
0 -> ""

This should be: 0 ->

Any ideas anyone ?
The attached sqlite.pas and sqlitedb.pas were put together by Michael, myself and Eric Jourde (possibly ported from tsqlite I hear)

cheers
James

- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Michael Van Canneyt
to James Mills
James Mills wrote 14 lines
Hi, This is a very weird behaviour I've found of either SQLite, or the Unit. I'm not sure... I have been discussing this same problem on the SQLite mailing list but without success there, so perhaps someone here might know... I have attached a test database, which contains 1 database entry, null strings are inserted using NULL... Check the database schema yourself. The problem therein lies in the fact that test3.pas returns "" for the query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; It should return a null string as it does in test2.pas and in the sqlite shell program.

The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy)

You'd need to have (as a minimum) an array of TField records:
  TField = Record
    IsNull : Boolean;
    Value : String;
  end;

But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your .

Reply by email

James Mills
to Michael Van Canneyt
Michael Van Canneyt wrote 22 lines
On Mon, 14 Jul 2003, James Mills wrote: > Hi, > > This is a very weird behaviour I've found of either SQLite, or the Unit. > I'm not sure... I have been discussing this same problem on the SQLite > mailing list but without success there, so perhaps someone here might > know... > > I have attached a test database, which contains 1 database entry, null > strings are inserted using NULL... Check the database schema yourself. > > The problem therein lies in the fact that test3.pas returns "" for the > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > It should return a null string as it does in test2.pas and in the sqlite > shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy)

"is done." in what ? The SQLite library or TStringList ?

Show quoted text 10 lines
You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your major would the changes be ? Otherwise I'll try and search for a

TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda of done something similar in creating a TDatabase descendant..., but it doesn't solve my problem)

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Michael Van Canneyt
to James Mills
James Mills wrote 25 lines
On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: > > > On Mon, 14 Jul 2003, James Mills wrote: > > > Hi, > > > > This is a very weird behaviour I've found of either SQLite, or the Unit. > > I'm not sure... I have been discussing this same problem on the SQLite > > mailing list but without success there, so perhaps someone here might > > know... > > > > I have attached a test database, which contains 1 database entry, null > > strings are inserted using NULL... Check the database schema yourself. > > > > The problem therein lies in the fact that test3.pas returns "" for the > > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > > It should return a null string as it does in test2.pas and in the sqlite > > shell program. > > The problem is that an implicity conversion from Nil to empty string is > done. You cannot solve this as long as stringlists are used to contain > the data. (ok, you could set 'Null' as the string, but that is sloppy) "is done." in what ? The SQLite library or TStringList ?

sqlite.

Show quoted text 16 lines
> > You'd need to have (as a minimum) an array of TField records: > TField = Record > IsNull : Boolean; > Value : String; > end; > > But this will require major changes, so I suggest trying to find or > implement a TDataset descendent for SQLIte, this will solve most of > your problems at once. How major would the changes be ? Otherwise I'll try and search for a TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda of done something similar in creating a TDatabase descendant..., but it doesn't solve my problem)

Implementing a TDataset descendent is not easy, it'll take you at least a week (conservative estimate).

Michael.

Reply by email

James Mills
to Michael Van Canneyt
Michael Van Canneyt wrote 31 lines
On Mon, 14 Jul 2003, James Mills wrote: > On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: > > > > > > On Mon, 14 Jul 2003, James Mills wrote: > > > > > Hi, > > > > > > This is a very weird behaviour I've found of either SQLite, or the Unit. > > > I'm not sure... I have been discussing this same problem on the SQLite > > > mailing list but without success there, so perhaps someone here might > > > know... > > > > > > I have attached a test database, which contains 1 database entry, null > > > strings are inserted using NULL... Check the database schema yourself. > > > > > > The problem therein lies in the fact that test3.pas returns "" for the > > > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > > > It should return a null string as it does in test2.pas and in the sqlite > > > shell program. > > > > The problem is that an implicity conversion from Nil to empty string is > > done. You cannot solve this as long as stringlists are used to contain > > the data. (ok, you could set 'Null' as the string, but that is sloppy) > > "is done." in what ? The SQLite library or TStringList ? sqlite.

But you said "You cannot solve this as long as stringlists are used to contain the data." This made me think it was a behaviour of TStringList ... If it truely is a behaviour of SQLite, I'll get them to change it.

Show quoted text 20 lines
> > > > > You'd need to have (as a minimum) an array of TField records: > > TField = Record > > IsNull : Boolean; > > Value : String; > > end; > > > > But this will require major changes, so I suggest trying to find or > > implement a TDataset descendent for SQLIte, this will solve most of > > your problems at once. > > How major would the changes be ? Otherwise I'll try and search for a > TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda > of done something similar in creating a TDatabase descendant..., but it > doesn't solve my problem) Implementing a TDataset descendent is not easy, it'll take you at least a week (conservative estimate).

Why is this a hard thing to do ? Give me some ideas here, you might be conservative, but I don't muck around :)
I'll attach my dbclass.pas a tiny desendant I wrote to simplify using queries (it's centered around making queries simpler)...

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

James Mills
to Michael Van Canneyt: The problem is that an implicity conversion from Nil to empty string is done. You cannot…
Michael Van Canneyt wrote 32 lines
On Mon, 14 Jul 2003, James Mills wrote: > Hi, > > This is a very weird behaviour I've found of either SQLite, or the Unit. > I'm not sure... I have been discussing this same problem on the SQLite > mailing list but without success there, so perhaps someone here might > know... > > I have attached a test database, which contains 1 database entry, null > strings are inserted using NULL... Check the database schema yourself. > > The problem therein lies in the fact that test3.pas returns "" for the > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > It should return a null string as it does in test2.pas and in the sqlite > shell program. The problem is that an implicity conversion from Nil to empty string is done. You cannot solve this as long as stringlists are used to contain the data. (ok, you could set 'Null' as the string, but that is sloppy) You'd need to have (as a minimum) an array of TField records: TField = Record IsNull : Boolean; Value : String; end; But this will require major changes, so I suggest trying to find or implement a TDataset descendent for SQLIte, this will solve most of your might I find such a descendent that using SQLite ? I'm not quite

sure what I'm looking for here... An initial search on google provides some delphi units that are probably not what I'm looking for.

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Michael Van Canneyt
to James Mills: But you said "You cannot solve this as long as stringlists are used to contain the data."…
James Mills wrote 36 lines
On Mon, Jul 14, 2003 at 02:26:28PM +0200, Michael Van Canneyt wrote: > > > On Mon, 14 Jul 2003, James Mills wrote: > > > On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: > > > > > > > > > On Mon, 14 Jul 2003, James Mills wrote: > > > > > > > Hi, > > > > > > > > This is a very weird behaviour I've found of either SQLite, or the Unit. > > > > I'm not sure... I have been discussing this same problem on the SQLite > > > > mailing list but without success there, so perhaps someone here might > > > > know... > > > > > > > > I have attached a test database, which contains 1 database entry, null > > > > strings are inserted using NULL... Check the database schema yourself. > > > > > > > > The problem therein lies in the fact that test3.pas returns "" for the > > > > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > > > > It should return a null string as it does in test2.pas and in the sqlite > > > > shell program. > > > > > > The problem is that an implicity conversion from Nil to empty string is > > > done. You cannot solve this as long as stringlists are used to contain > > > the data. (ok, you could set 'Null' as the string, but that is sloppy) > > > > "is done." in what ? The SQLite library or TStringList ? > > sqlite. But you said "You cannot solve this as long as stringlists are used to contain the data." This made me think it was a behaviour of TStringList ... If it truely is a behaviour of SQLite, I'll get them to change it.

The problem is that there is no way to distinguish between a 'null' and an empty string once it is converted to a string. The information is simply lost.

Show quoted text 24 lines
> > > > > > > > > You'd need to have (as a minimum) an array of TField records: > > > TField = Record > > > IsNull : Boolean; > > > Value : String; > > > end; > > > > > > But this will require major changes, so I suggest trying to find or > > > implement a TDataset descendent for SQLIte, this will solve most of > > > your problems at once. > > > > How major would the changes be ? Otherwise I'll try and search for a > > TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda > > of done something similar in creating a TDatabase descendant..., but it > > doesn't solve my problem) > > Implementing a TDataset descendent is not easy, it'll take you at least > a week (conservative estimate). Why is this a hard thing to do ? Give me some ideas here, you might be conservative, but I don't muck around :)

Because TDataset is not an easy subject. You need to implement a lot of calls in a correct and predefined way.

Michael.

Reply by email

James Mills
to Michael Van Canneyt: On the contrary, on Torry's pages there are some units that do exactly what I described.…
Michael Van Canneyt wrote 44 lines
On Mon, 14 Jul 2003, James Mills wrote: > On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: > > > > > > On Mon, 14 Jul 2003, James Mills wrote: > > > > > Hi, > > > > > > This is a very weird behaviour I've found of either SQLite, or the Unit. > > > I'm not sure... I have been discussing this same problem on the SQLite > > > mailing list but without success there, so perhaps someone here might > > > know... > > > > > > I have attached a test database, which contains 1 database entry, null > > > strings are inserted using NULL... Check the database schema yourself. > > > > > > The problem therein lies in the fact that test3.pas returns "" for the > > > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > > > It should return a null string as it does in test2.pas and in the sqlite > > > shell program. > > > > The problem is that an implicity conversion from Nil to empty string is > > done. You cannot solve this as long as stringlists are used to contain > > the data. (ok, you could set 'Null' as the string, but that is sloppy) > > > > You'd need to have (as a minimum) an array of TField records: > > TField = Record > > IsNull : Boolean; > > Value : String; > > end; > > > > But this will require major changes, so I suggest trying to find or > > implement a TDataset descendent for SQLIte, this will solve most of > > your problems at once. > > Where might I find such a descendent that using SQLite ? I'm not quite > sure what I'm looking for here... An initial search on google provides > some delphi units that are probably not what I'm looking for. On the contrary, on Torry's pages there are some units that do exactly what I described.

Ok thanks. I had searched for "TDataset descendant sqlite pascal" one page came up from Torry's pages.

*hits Mozilla, it crashes too much :P*

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Michael Van Canneyt
to James Mills: sure what I'm looking for here... An initial search on google provides some delphi units…
James Mills wrote 37 lines
On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: > > > On Mon, 14 Jul 2003, James Mills wrote: > > > Hi, > > > > This is a very weird behaviour I've found of either SQLite, or the Unit. > > I'm not sure... I have been discussing this same problem on the SQLite > > mailing list but without success there, so perhaps someone here might > > know... > > > > I have attached a test database, which contains 1 database entry, null > > strings are inserted using NULL... Check the database schema yourself. > > > > The problem therein lies in the fact that test3.pas returns "" for the > > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > > It should return a null string as it does in test2.pas and in the sqlite > > shell program. > > The problem is that an implicity conversion from Nil to empty string is > done. You cannot solve this as long as stringlists are used to contain > the data. (ok, you could set 'Null' as the string, but that is sloppy) > > You'd need to have (as a minimum) an array of TField records: > TField = Record > IsNull : Boolean; > Value : String; > end; > > But this will require major changes, so I suggest trying to find or > implement a TDataset descendent for SQLIte, this will solve most of > your problems at once. Where might I find such a descendent that using SQLite ? I'm not quite sure what I'm looking for here... An initial search on google provides some delphi units that are probably not what I'm looking for.

On the contrary, on Torry's pages there are some units that do exactly what I described.

Michael.

Reply by email

James Mills
to Michael Van Canneyt: The problem is that there is no way to distinguish between a 'null' and an empty string…
Michael Van Canneyt wrote 44 lines
On Mon, 14 Jul 2003, James Mills wrote: > On Mon, Jul 14, 2003 at 02:26:28PM +0200, Michael Van Canneyt wrote: > > > > > > On Mon, 14 Jul 2003, James Mills wrote: > > > > > On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: > > > > > > > > > > > > On Mon, 14 Jul 2003, James Mills wrote: > > > > > > > > > Hi, > > > > > > > > > > This is a very weird behaviour I've found of either SQLite, or the Unit. > > > > > I'm not sure... I have been discussing this same problem on the SQLite > > > > > mailing list but without success there, so perhaps someone here might > > > > > know... > > > > > > > > > > I have attached a test database, which contains 1 database entry, null > > > > > strings are inserted using NULL... Check the database schema yourself. > > > > > > > > > > The problem therein lies in the fact that test3.pas returns "" for the > > > > > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > > > > > It should return a null string as it does in test2.pas and in the sqlite > > > > > shell program. > > > > > > > > The problem is that an implicity conversion from Nil to empty string is > > > > done. You cannot solve this as long as stringlists are used to contain > > > > the data. (ok, you could set 'Null' as the string, but that is sloppy) > > > > > > "is done." in what ? The SQLite library or TStringList ? > > > > sqlite. > > But you said "You cannot solve this as long as stringlists are used to > contain the data." This made me think it was a behaviour of TStringList > ... If it truely is a behaviour of SQLite, I'll get them to change it. The problem is that there is no way to distinguish between a 'null' and an empty string once it is converted to a string. The information is simply lost.

Just reconfirming with you and solidifying my knowledge. The reason it returns "" is because: when working with native pascal types, assigning null to a string results in an empty string "" right ?

cheers
James

Show quoted text 35 lines
> > > > > > > > > > > > > > You'd need to have (as a minimum) an array of TField records: > > > > TField = Record > > > > IsNull : Boolean; > > > > Value : String; > > > > end; > > > > > > > > But this will require major changes, so I suggest trying to find or > > > > implement a TDataset descendent for SQLIte, this will solve most of > > > > your problems at once. > > > > > > How major would the changes be ? Otherwise I'll try and search for a > > > TDataset descendent ? Couldn't I write a descendent myself ? (I've kinda > > > of done something similar in creating a TDatabase descendant..., but it > > > doesn't solve my problem) > > > > Implementing a TDataset descendent is not easy, it'll take you at least > > a week (conservative estimate). > > Why is this a hard thing to do ? Give me some ideas here, you might be > conservative, but I don't muck around :) Because TDataset is not an easy subject. You need to implement a lot of calls in a correct and predefined way. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Alan Mead
to James Mills
--- James Mills wrote 7 lines
Just reconfirming with you and solidifying my knowledge. The reason it returns "" is because: when working with native pascal types, assigning null to a string results in an empty string "" right ? cheers James

James,

Pascal is a strongly typed language and there is no Pascal string precisely equivalent to a NULL. Someone (either the SQLite authors or the one who wrote the Pascal wrapper) decided to automatically translate NULL into empty (zero-length) strings. And it's impossible now to distinguish actual null values from fields containing actual zero-length strings.

You could solve this in several ways:

1) re-write all the code to return and store a more complex record (as suggested in a previous post) that include a string and a boolean, this record completely and precisely captures the data SQL is returning;

2) re-write the code that does the automatic translation to insert the string 'NULL' (in which case, you will never be able to distinguish NULL's from actual fields containing the value 'NULL'--but maybe this is no problem);

3) you could simply avoid ever having empty strings in your database (in which case, empty strings returned are always NULL's)

4) Live with not being able to distinguish, in many instances, an empty string is practically the same as a NULL (in other instances, however, it indicates that some records in a full join failed to find a match)

HTH,

-Alan

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Reply by email

James Mills
to Alan Mead
Alan Mead wrote 19 lines
--- James Mills wrote: > Just reconfirming with you and solidifying my knowledge. > The reason it returns "" is because: when working with > native pascal types, assigning null to a string results > in an empty string "" right ? > > cheers > James James, Pascal is a strongly typed language and there is no Pascal string precisely equivalent to a NULL. Someone (either the SQLite authors or the one who wrote the Pascal wrapper) decided to automatically translate NULL into empty (zero-length) strings. And it's impossible now to distinguish actual null values from fields containing actual zero-length strings.

I think I'm slowly understanding this bit now. I don't claim to be an SQL expert. But SQL (sqlite anyway) is capable of storing any data types, strings, integers, boolean etc, including NULL values. I hope I'm correct here...

I don't believe the authors of the sqlite unit do translate NULL into empty (zero-length) strings. I did check the source, check yourself if I'm wrong.

Why could I not simply check for '""' in my sql return functions and simply return '' instead (a pascal empty string) ? Would this be terribly wrong ? Or am I still going to have to follow Michael's suggestion in finding a TDataset desendant ? (I don't understand what a TDataset desendant really is and why I need to use one but anyway...)

Show quoted text 15 lines
You could solve this in several ways: 1) re-write all the code to return and store a more complex record (as suggested in a previous post) that include a string and a boolean, this record completely and precisely captures the data SQL is returning; 2) re-write the code that does the automatic translation to insert the string 'NULL' (in which case, you will never be able to distinguish NULL's from actual fields containing the value 'NULL'--but maybe this is no problem); 3) you could simply avoid ever having empty strings in your database (in which case, empty strings returned are always NULL's)

There should be no empty string in my database anyway. If a field is empty it's value is NULL.

Show quoted text 5 lines
4) Live with not being able to distinguish, in many instances, an empty string is practically the same as a NULL (in other instances, however, it indicates that some records in a full join failed to find a match)

cheers
James

Show quoted text 13 lines
HTH, -Alan __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Michael Van Canneyt
to James Mills
James Mills wrote 29 lines
On Tue, Jul 15, 2003 at 04:36:24AM -0700, Alan Mead wrote: > > --- James Mills wrote: > > > Just reconfirming with you and solidifying my knowledge. > > The reason it returns "" is because: when working with > > native pascal types, assigning null to a string results > > in an empty string "" right ? > > > > cheers > > James > > James, > > Pascal is a strongly typed language and there is no Pascal string > precisely equivalent to a NULL. Someone (either the SQLite authors > or the one who wrote the Pascal wrapper) decided to automatically > translate NULL into empty (zero-length) strings. And it's impossible > now to distinguish actual null values from fields containing actual > zero-length strings. I think I'm slowly understanding this bit now. I don't claim to be an SQL expert. But SQL (sqlite anyway) is capable of storing any data types, strings, integers, boolean etc, including NULL values. I hope I'm correct here... I don't believe the authors of the sqlite unit do translate NULL into empty (zero-length) strings. I did check the source, check yourself if I'm wrong.

They do. But implicitly, by converting a pchar to a string. A nil will be converted to an empty string.

Michael.

Reply by email

James Mills
to Michael Van Canneyt
Michael Van Canneyt wrote 36 lines
On Tue, 15 Jul 2003, James Mills wrote: > On Tue, Jul 15, 2003 at 04:36:24AM -0700, Alan Mead wrote: > > > > --- James Mills wrote: > > > > > Just reconfirming with you and solidifying my knowledge. > > > The reason it returns "" is because: when working with > > > native pascal types, assigning null to a string results > > > in an empty string "" right ? > > > > > > cheers > > > James > > > > James, > > > > Pascal is a strongly typed language and there is no Pascal string > > precisely equivalent to a NULL. Someone (either the SQLite authors > > or the one who wrote the Pascal wrapper) decided to automatically > > translate NULL into empty (zero-length) strings. And it's impossible > > now to distinguish actual null values from fields containing actual > > zero-length strings. > > I think I'm slowly understanding this bit now. I don't claim to be an > SQL expert. But SQL (sqlite anyway) is capable of storing any data > types, strings, integers, boolean etc, including NULL values. I hope I'm > correct here... > > I don't believe the authors of the sqlite unit do translate NULL into > empty (zero-length) strings. I did check the source, check yourself if > I'm wrong. They do. But implicitly, by converting a pchar to a string. A nil will be converted to an empty string.

Oh :)

It's funny how I haven't been able to actually reproduce this in some test programs on Linux using FPC.

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

James Mills
to Michael Van Canneyt: On the contrary, on Torry's pages there are some units that do exactly what I described.…
Michael Van Canneyt wrote 44 lines
On Mon, 14 Jul 2003, James Mills wrote: > On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: > > > > > > On Mon, 14 Jul 2003, James Mills wrote: > > > > > Hi, > > > > > > This is a very weird behaviour I've found of either SQLite, or the Unit. > > > I'm not sure... I have been discussing this same problem on the SQLite > > > mailing list but without success there, so perhaps someone here might > > > know... > > > > > > I have attached a test database, which contains 1 database entry, null > > > strings are inserted using NULL... Check the database schema yourself. > > > > > > The problem therein lies in the fact that test3.pas returns "" for the > > > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > > > It should return a null string as it does in test2.pas and in the sqlite > > > shell program. > > > > The problem is that an implicity conversion from Nil to empty string is > > done. You cannot solve this as long as stringlists are used to contain > > the data. (ok, you could set 'Null' as the string, but that is sloppy) > > > > You'd need to have (as a minimum) an array of TField records: > > TField = Record > > IsNull : Boolean; > > Value : String; > > end; > > > > But this will require major changes, so I suggest trying to find or > > implement a TDataset descendent for SQLIte, this will solve most of > > your problems at once. > > Where might I find such a descendent that using SQLite ? I'm not quite > sure what I'm looking for here... An initial search on google provides > some delphi units that are probably not what I'm looking for. On the contrary, on Torry's pages there are some units that do exactly what I described.

Not having much luck with Torry's pages I'm afraid. However I've looked at the FCL source, there is a mysqldb.pp in the db directory... Couldn't that be used for sqlite (obviously with changes) ?

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Michael Van Canneyt
to James Mills
James Mills wrote 49 lines
On Mon, Jul 14, 2003 at 03:39:36PM +0200, Michael Van Canneyt wrote: > > > On Mon, 14 Jul 2003, James Mills wrote: > > > On Mon, Jul 14, 2003 at 09:59:17AM +0200, Michael Van Canneyt wrote: > > > > > > > > > On Mon, 14 Jul 2003, James Mills wrote: > > > > > > > Hi, > > > > > > > > This is a very weird behaviour I've found of either SQLite, or the Unit. > > > > I'm not sure... I have been discussing this same problem on the SQLite > > > > mailing list but without success there, so perhaps someone here might > > > > know... > > > > > > > > I have attached a test database, which contains 1 database entry, null > > > > strings are inserted using NULL... Check the database schema yourself. > > > > > > > > The problem therein lies in the fact that test3.pas returns "" for the > > > > query: SELECT channelNotice FROM channels WHERE channel LIKE '#ProLogiTech'; > > > > It should return a null string as it does in test2.pas and in the sqlite > > > > shell program. > > > > > > The problem is that an implicity conversion from Nil to empty string is > > > done. You cannot solve this as long as stringlists are used to contain > > > the data. (ok, you could set 'Null' as the string, but that is sloppy) > > > > > > You'd need to have (as a minimum) an array of TField records: > > > TField = Record > > > IsNull : Boolean; > > > Value : String; > > > end; > > > > > > But this will require major changes, so I suggest trying to find or > > > implement a TDataset descendent for SQLIte, this will solve most of > > > your problems at once. > > > > Where might I find such a descendent that using SQLite ? I'm not quite > > sure what I'm looking for here... An initial search on google provides > > some delphi units that are probably not what I'm looking for. > > On the contrary, on Torry's pages there are some units that do exactly > what I described. Not having much luck with Torry's pages I'm afraid. However I've looked at the FCL source, there is a mysqldb.pp in the db directory... Couldn't that be used for sqlite (obviously with changes) ?

Yes.

Michael.

Reply by email

Alan Mead
to James Mills: I think I'm slowly understanding this bit now. I don't claim to be an SQL expert. But SQL…
--- James Mills wrote 30 lines
On Tue, Jul 15, 2003 at 04:36:24AM -0700, Alan Mead wrote: > > --- James Mills wrote: > > > Just reconfirming with you and solidifying my knowledge. > > The reason it returns "" is because: when working with > > native pascal types, assigning null to a string results > > in an empty string "" right ? > > > > cheers > > James > > James, > > Pascal is a strongly typed language and there is no Pascal string > precisely equivalent to a NULL. Someone (either the SQLite authors > or the one who wrote the Pascal wrapper) decided to automatically > translate NULL into empty (zero-length) strings. And it's impossible > now to distinguish actual null values from fields containing actual > zero-length strings. I think I'm slowly understanding this bit now. I don't claim to be an SQL expert. But SQL (sqlite anyway) is capable of storing any data types, strings, integers, boolean etc, including NULL values. I hope I'm correct here...

I know nothing specifically about SQLite but SQL has many data types, similar to Pascal. However, SQL data fields can also have the value NULL which has no analog with Pascal data. Pascal data types cannot simultaneously hold data and this non-data missing value code (unless you define some convention within your code... like you could arrange for NULL results to be returned as the string value 'NULL' but then you would be unable to distinguish between actual strings with the value 'NULL' and the NULL result... which may be no big deal).

According to Michael, someone arranged for NULL values to be translated to empty strings, perhaps without even meaning to, because of how ansistrings act.. they are internally pointers and an empty string is represented as a nil pointer.

I have no idea why this behavior would be different between Windows (?) and Linux. (in fact, are you sure it is?)

Why could I not simply check for '""' in my sql return functions and simply return '' instead (a pascal empty string) ? Would this be terribly wrong ?

See below.

Show quoted text 5 lines
Or am I still going to have to follow Michael's suggestion in finding a TDataset desendant ? (I don't understand what a TDataset desendant really is and why I need to use one but anyway...)

I think the idea with the TDataset was to create a record in Pascal that could hold all the SQL data. Since a string alone cannot hold it, you need a record with a string and a boolean. The boolean holds NULL or not-NULL. When the boolean holds not-NULL, the string holds the data (the string should never hold data if the boolean hold NULL). By "boolean holds NULL", of course, I mean that you define the boolean in some way so that it indicates the NULL-ness. For example, define it as 'IsNull:boolean;' and then TRUE will indicate that the result is NULL.

Show quoted text 6 lines
> 3) you could simply avoid ever having empty strings in your database > (in which case, empty strings returned are always NULL's) There should be no empty string in my database anyway. If a field is empty it's value is NULL.

Well then why are you worried about distinguishing between NULL's and empty strings? All empty strings are NULL's. (I know originally, you were compiling test programs... is this really an issue?)

-Alan

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Reply by email

James Mills
to Alan Mead
Alan Mead wrote 72 lines
--- James Mills wrote: > On Tue, Jul 15, 2003 at 04:36:24AM -0700, Alan Mead wrote: > > > > --- James Mills wrote: > > > > > Just reconfirming with you and solidifying my knowledge. > > > The reason it returns "" is because: when working with > > > native pascal types, assigning null to a string results > > > in an empty string "" right ? > > > > > > cheers > > > James > > > > James, > > > > Pascal is a strongly typed language and there is no Pascal string > > precisely equivalent to a NULL. Someone (either the SQLite > authors > > or the one who wrote the Pascal wrapper) decided to automatically > > translate NULL into empty (zero-length) strings. And it's > impossible > > now to distinguish actual null values from fields containing > actual > > zero-length strings. > > I think I'm slowly understanding this bit now. I don't claim to be > an > SQL expert. But SQL (sqlite anyway) is capable of storing any data > types, strings, integers, boolean etc, including NULL values. I > hope I'm > correct here... I know nothing specifically about SQLite but SQL has many data types, similar to Pascal. However, SQL data fields can also have the value NULL which has no analog with Pascal data. Pascal data types cannot simultaneously hold data and this non-data missing value code (unless you define some convention within your code... like you could arrange for NULL results to be returned as the string value 'NULL' but then you would be unable to distinguish between actual strings with the value 'NULL' and the NULL result... which may be no big deal). According to Michael, someone arranged for NULL values to be translated to empty strings, perhaps without even meaning to, because of how ansistrings act.. they are internally pointers and an empty string is represented as a nil pointer. I have no idea why this behavior would be different between Windows (?) and Linux. (in fact, are you sure it is?) > Why could I not simply check for '""' in my sql return functions > and > simply return '' instead (a pascal empty string) ? Would this be > terribly wrong ? See below. > Or am I still going to have to follow Michael's > suggestion in finding a TDataset desendant ? (I don't understand > what a > TDataset desendant really is and why I need to use one but > anyway...) I think the idea with the TDataset was to create a record in Pascal that could hold all the SQL data. Since a string alone cannot hold it, you need a record with a string and a boolean. The boolean holds NULL or not-NULL. When the boolean holds not-NULL, the string holds the data (the string should never hold data if the boolean hold NULL). By "boolean holds NULL", of course, I mean that you define the boolean in some way so that it indicates the NULL-ness. For example, define it as 'IsNull:boolean;' and then TRUE will indicate that the result is NULL.

Why did Michael say that creating a TDataset was so hard ? If in it's simplest form it's just a record to hold the data with a boolean indicating it's null-ness, that doesn't seem so difficult to implement to me.

I might play around with the mysqldb.pp dataset class in the fcl source though...

Show quoted text 11 lines
> > 3) you could simply avoid ever having empty strings in your > database > > (in which case, empty strings returned are always NULL's) > There should be no empty string in my database anyway. If a field > is > empty it's value is NULL. Well then why are you worried about distinguishing between NULL's and empty strings? All empty strings are NULL's. (I know originally, you were compiling test programs... is this really an issue?)

My program relies on the fact that some fields (which are string types) are null. I'm not sure what to say next so I'll leave it at that :P

cheers
James

Show quoted text 12 lines
-Alan __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Michael Van Canneyt
to James Mills
James Mills wrote 78 lines
On Tue, Jul 15, 2003 at 07:04:05AM -0700, Alan Mead wrote: > > --- James Mills wrote: > > On Tue, Jul 15, 2003 at 04:36:24AM -0700, Alan Mead wrote: > > > > > > --- James Mills wrote: > > > > > > > Just reconfirming with you and solidifying my knowledge. > > > > The reason it returns "" is because: when working with > > > > native pascal types, assigning null to a string results > > > > in an empty string "" right ? > > > > > > > > cheers > > > > James > > > > > > James, > > > > > > Pascal is a strongly typed language and there is no Pascal string > > > precisely equivalent to a NULL. Someone (either the SQLite > > authors > > > or the one who wrote the Pascal wrapper) decided to automatically > > > translate NULL into empty (zero-length) strings. And it's > > impossible > > > now to distinguish actual null values from fields containing > > actual > > > zero-length strings. > > > > I think I'm slowly understanding this bit now. I don't claim to be > > an > > SQL expert. But SQL (sqlite anyway) is capable of storing any data > > types, strings, integers, boolean etc, including NULL values. I > > hope I'm > > correct here... > > I know nothing specifically about SQLite but SQL has many data types, > similar to Pascal. However, SQL data fields can also have the value > NULL which has no analog with Pascal data. Pascal data types cannot > simultaneously hold data and this non-data missing value code (unless > you define some convention within your code... like you could arrange > for NULL results to be returned as the string value 'NULL' but then > you would be unable to distinguish between actual strings with the > value 'NULL' and the NULL result... which may be no big deal). > > According to Michael, someone arranged for NULL values to be > translated to empty strings, perhaps without even meaning to, because > of how ansistrings act.. they are internally pointers and an empty > string is represented as a nil pointer. > > I have no idea why this behavior would be different between Windows > (?) and Linux. (in fact, are you sure it is?) > > > Why could I not simply check for '""' in my sql return functions > > and > > simply return '' instead (a pascal empty string) ? Would this be > > terribly wrong ? > > See below. > > > Or am I still going to have to follow Michael's > > suggestion in finding a TDataset desendant ? (I don't understand > > what a > > TDataset desendant really is and why I need to use one but > > anyway...) > > I think the idea with the TDataset was to create a record in Pascal > that could hold all the SQL data. Since a string alone cannot hold > it, you need a record with a string and a boolean. The boolean holds > NULL or not-NULL. When the boolean holds not-NULL, the string holds > the data (the string should never hold data if the boolean hold > NULL). By "boolean holds NULL", of course, I mean that you define > the boolean in some way so that it indicates the NULL-ness. For > example, define it as 'IsNull:boolean;' and then TRUE will indicate > that the result is NULL. Why did Michael say that creating a TDataset was so hard ? If in it's simplest form it's just a record to hold the data with a boolean indicating it's null-ness, that doesn't seem so difficult to implement to me.

It is not that, it's much more than that. TDataset manages such 'records' and much more.

You can write whole books about the TDataset class and it's descendents. I wouldn't advise someone with no experience with TDatasets to start writing a descendent.

Michael.

Reply by email

James Mills
to Michael Van Canneyt
Michael Van Canneyt wrote 89 lines
On Wed, 16 Jul 2003, James Mills wrote: > On Tue, Jul 15, 2003 at 07:04:05AM -0700, Alan Mead wrote: > > > > --- James Mills wrote: > > > On Tue, Jul 15, 2003 at 04:36:24AM -0700, Alan Mead wrote: > > > > > > > > --- James Mills wrote: > > > > > > > > > Just reconfirming with you and solidifying my knowledge. > > > > > The reason it returns "" is because: when working with > > > > > native pascal types, assigning null to a string results > > > > > in an empty string "" right ? > > > > > > > > > > cheers > > > > > James > > > > > > > > James, > > > > > > > > Pascal is a strongly typed language and there is no Pascal string > > > > precisely equivalent to a NULL. Someone (either the SQLite > > > authors > > > > or the one who wrote the Pascal wrapper) decided to automatically > > > > translate NULL into empty (zero-length) strings. And it's > > > impossible > > > > now to distinguish actual null values from fields containing > > > actual > > > > zero-length strings. > > > > > > I think I'm slowly understanding this bit now. I don't claim to be > > > an > > > SQL expert. But SQL (sqlite anyway) is capable of storing any data > > > types, strings, integers, boolean etc, including NULL values. I > > > hope I'm > > > correct here... > > > > I know nothing specifically about SQLite but SQL has many data types, > > similar to Pascal. However, SQL data fields can also have the value > > NULL which has no analog with Pascal data. Pascal data types cannot > > simultaneously hold data and this non-data missing value code (unless > > you define some convention within your code... like you could arrange > > for NULL results to be returned as the string value 'NULL' but then > > you would be unable to distinguish between actual strings with the > > value 'NULL' and the NULL result... which may be no big deal). > > > > According to Michael, someone arranged for NULL values to be > > translated to empty strings, perhaps without even meaning to, because > > of how ansistrings act.. they are internally pointers and an empty > > string is represented as a nil pointer. > > > > I have no idea why this behavior would be different between Windows > > (?) and Linux. (in fact, are you sure it is?) > > > > > Why could I not simply check for '""' in my sql return functions > > > and > > > simply return '' instead (a pascal empty string) ? Would this be > > > terribly wrong ? > > > > See below. > > > > > Or am I still going to have to follow Michael's > > > suggestion in finding a TDataset desendant ? (I don't understand > > > what a > > > TDataset desendant really is and why I need to use one but > > > anyway...) > > > > I think the idea with the TDataset was to create a record in Pascal > > that could hold all the SQL data. Since a string alone cannot hold > > it, you need a record with a string and a boolean. The boolean holds > > NULL or not-NULL. When the boolean holds not-NULL, the string holds > > the data (the string should never hold data if the boolean hold > > NULL). By "boolean holds NULL", of course, I mean that you define > > the boolean in some way so that it indicates the NULL-ness. For > > example, define it as 'IsNull:boolean;' and then TRUE will indicate > > that the result is NULL. > > Why did Michael say that creating a TDataset was so hard ? If in it's > simplest form it's just a record to hold the data with a boolean > indicating it's null-ness, that doesn't seem so difficult to implement > to me. It is not that, it's much more than that. TDataset manages such 'records' and much more. You can write whole books about the TDataset class and it's descendents. I wouldn't advise someone with no experience with TDatasets to start writing a descendent.

You obviously know a lot about this topic as I've seen in the mysql dataset you created and the generic dataset. I've looked at it and shaken my head! (I'll admit I don't know a lot about databases, but am learning, SQL is my only knowledge thus far).

Having said that though, I'm going to try and modify Eric Jourde's sqlite unit to accomadate for NULLs (try being the operative word :P)

cheers
James

Show quoted text 7 lines
Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Alan Mead
to James Mills: Why did Michael say that creating a TDataset was so hard ? If in it's simplest form it's…
--- James Mills wrote
My program relies on the fact that some fields (which are string types) are null. I'm not sure what to say next so I'll leave it at that :P

If your database never contains an empty string, then your program can rely on the empty strings you retrieve being NULL values in the database.

But if an empty string ever crept into a database field, then your program would think the field is null when it's not. If this would cause a grevious error, then you should find a better way.

-Alan

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Reply by email

James Mills
to Alan Mead
Alan Mead wrote 10 lines
--- James Mills wrote: > My program relies on the fact that some fields (which are string > types) > are null. I'm not sure what to say next so I'll leave it at that :P If your database never contains an empty string, then your program can rely on the empty strings you retrieve being NULL values in the database.

This case is true and the database will never contain empty strings only NULL values. The program has strict ways of doing this, unless of course you modify the databases externally, then bam (you're right as per below)...

cheers
James

Show quoted text 16 lines
But if an empty string ever crept into a database field, then your program would think the field is null when it's not. If this would cause a grevious error, then you should find a better way. -Alan __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Alan Mead
to James Mills
--- James Mills wrote 22 lines
On Tue, Jul 15, 2003 at 08:35:44AM -0700, Alan Mead wrote: > > --- James Mills wrote: > > > My program relies on the fact that some fields (which are string > > types) > > are null. I'm not sure what to say next so I'll leave it at that :P > > If your database never contains an empty string, then your program > can rely on the empty strings you retrieve being NULL values in the > database. This case is true and the database will never contain empty strings only NULL values. The program has strict ways of doing this, unless of course you modify the databases externally, then bam (you're right as per below)...

So if you do nothing, your program will work unless someone accesses the database externally (or there is a bug in whatever code ensures against inserting empty strings). You need to decide how likely and bad that is.

But maybe there is a simple work-around. Surely you can execute SQL select statements using SQLite, right? If so, then you can exploit the fact that SQL itself is well aware of the distinction between empty strings and NULL's to check for this error condition.

If you're checking one table called MYTABLE with a key called IDX and a couple fields to check are ADDRESS1 and ADDRESS2 then you would execute this select:

select IDX from MYTABLE where ADDRESS1='' or ADDRESS2=''

If you get no results, then there is no error condition (you can safely assume empty strings are NULL's). If you get any results, then you know which records need to be fixed.

You could execute this query at the start of your application's run. Or you could run it periodically (e.g., nightly) and email yourself the results.

-Alan

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Reply by email

James Mills
to Alan Mead
Alan Mead wrote 29 lines
--- James Mills wrote: > On Tue, Jul 15, 2003 at 08:35:44AM -0700, Alan Mead wrote: > > > > --- James Mills wrote: > > > > > My program relies on the fact that some fields (which are > string > > > types) > > > are null. I'm not sure what to say next so I'll leave it at > that :P > > > > If your database never contains an empty string, then your > program > > can rely on the empty strings you retrieve being NULL values in > the > > database. > > This case is true and the database will never contain empty strings > only > NULL values. The program has strict ways of doing this, unless of > course > you modify the databases externally, then bam (you're right as per > below)... So if you do nothing, your program will work unless someone accesses the database externally (or there is a bug in whatever code ensures against inserting empty strings). You need to decide how likely and bad that is.

Well the only bad thing is that it returns data where there should be no data. ie: '""' instead of the expected '', causing the program to treat '""' as if it were a real string.

James

Show quoted text 30 lines
But maybe there is a simple work-around. Surely you can execute SQL select statements using SQLite, right? If so, then you can exploit the fact that SQL itself is well aware of the distinction between empty strings and NULL's to check for this error condition. If you're checking one table called MYTABLE with a key called IDX and a couple fields to check are ADDRESS1 and ADDRESS2 then you would execute this select: select IDX from MYTABLE where ADDRESS1='' or ADDRESS2='' If you get no results, then there is no error condition (you can safely assume empty strings are NULL's). If you get any results, then you know which records need to be fixed. You could execute this query at the start of your application's run. Or you could run it periodically (e.g., nightly) and email yourself the results. -Alan __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Jeff Pohlmeyer
like you could arrange for NULL results to be returned as the string value 'NULL' but then you would be unable to distinguish between actual strings with the value 'NULL' and the NULL result...

Just a thought, but maybe you could return
the single-character string: #0

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Reply by email

James Mills
to Jeff Pohlmeyer
Jeff Pohlmeyer wrote 7 lines
> like you could arrange for NULL results to be returned as the string > value 'NULL' but then you would be unable to distinguish between > actual strings with the value 'NULL' and the NULL result... Just a thought, but maybe you could return the single-character string: #0

Thanks mate :) I'm so lost anyway, all these people with much deeper knowledge of databases...

cheers
James

Show quoted text 13 lines
__________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Alan Mead
to James Mills: Well the only bad thing is that it returns data where there should be no data. ie: '""'…
--- James Mills wrote 6 lines
Well the only bad thing is that it returns data where there should be no data. ie: '""' instead of the expected '', causing the program to treat '""' as if it were a real string.

All the better. The string '""' is unlikely to exists you your database naturally, right? So when you see it, you have a NULL.

Or you could, as you suggested earlier, just convert it to an empty string.

-Alan

__________________________________
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

Reply by email

James Mills
to Alan Mead
Alan Mead wrote 12 lines
--- James Mills wrote: > > Well the only bad thing is that it returns data where there should > be no > data. ie: '""' instead of the expected '', causing the program to > treat > '""' as if it were a real string. All the better. The string '""' is unlikely to exists you your database naturally, right? So when you see it, you have a NULL.

That's correct. What I've learnt over the past 2 days though is that I'll be leave blinded by all this unless I go pickup a book on database and read it! :)

Or you could, as you suggested earlier, just convert it to an empty string.

I might do that if I have no luck with a TDataset desendant...

Thanks Alan,

James

Show quoted text 12 lines
-Alan __________________________________ Do you Yahoo!? SBC Yahoo! DSL - Now only $29.95 per month! http://sbc.yahoo.com _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal
- - James Mills Zero Defect Software Engineers Group - ZDSEG

Reply by email

Boguslaw Brandys
to James Mills

Hello,
From SQLite docs:
"Note that the callback function reports a NULL value in the database as a NULL pointer, which is very different from an empty string. If the i-th parameter is an empty string, we will get:

argv[i][0] == 0
But if the i-th parameter is NULL we will get:

argv[i] == 0"So maybe there are different pointers here which You should test ?Best RegardsBoguslaw

Reply by email