[fpc-pascal]SQLite and NULL Strings...
James Mills
prologic at daisy.ods.org
Tue Jul 15 15:21:29 CEST 2003
On Tue, Jul 15, 2003 at 03:15:58PM +0200, Michael Van Canneyt wrote:
>
>
> 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.
Oh :)
It's funny how I haven't been able to actually reproduce this in some
test programs on Linux using FPC.
cheers
James
>
> Michael.
>
>
> _______________________________________________
> fpc-pascal maillist - fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
--
-
- James Mills
Zero Defect Software Engineers Group - ZDSEG
More information about the fpc-pascal
mailing list