[fpc-pascal]SQLite and NULL Strings...
Michael Van Canneyt
michael.vancanneyt at wisa.be
Tue Jul 15 15:15:58 CEST 2003
On Tue, 15 Jul 2003, James Mills wrote:
> On Tue, Jul 15, 2003 at 04:36:24AM -0700, Alan Mead wrote:
> > --- James Mills <prologic at daisy.ods.org> 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.
More information about the fpc-pascal