Article View: borland.public.interbase.sql
Article #11268Re: Variant types for Interbase data types
From: Edward Diener
Date: Mon, 02 Dec 2002 03:54
Date: Mon, 02 Dec 2002 03:54
41 lines
3145 bytes
3145 bytes
"Wayne Niddery [TeamB]" <wniddery@chaff.aci.on.ca> wrote in message
news:3deaa556$1@newsgroups.borland.com...
> "Edward Diener" <eddielee@tropicsoft.com> wrote in message
> news:3dea8b03$1@newsgroups.borland.com...
> >
> > That's not the question. The question is: how do I convert DATE, TIME,
and
> > TIMESTAMP variant values to values I can use in an SQL statement. Does
SQL
> > using these types accept a 32 bit integer number, a 32 bit integer
number,
> > or a 64 bit integer number respectively for each of these values, or do
> > these values have to be in some sort of string format, ie. for DATE "Dec
> > 01,2002", to be accepted. If SQL accepts these values as just integer
> > numbers, then everything is fine, but if SQL needs some sort of string
> > values, then I have to convert them to some sort of acceptable string
> > format.
>
> Interbase accepts them as strings in standard formats, or as parameters.
You
> are *much* better off using parameters wherever possible. You are also
much
> better off avoiding variants wherever possible, especially with regard to
> dates and times. For dates and times, use the Delphi TDateTime type if you
> can. If you want to format a date into SQL, you can use the FormatDateTime
> function (avoid DateToStr, et al as these convert according to the local
> Windows settings which may or may not be acceptable formats for
Interbase).
>
> Using parameters is simple:
>
> Query1.SQL.Text := 'select * from table where datefield = :datefield';
> Query1.ParamByName('datefield').AsDateTime := MyTDateTimeVar;
> // or... Query1.Params[0].AsDateTime := MyTDateTimeVar;
I can't avoid Variants ( why should I ? ) but I will use your suggestion
above for using parameters, as that should work to get the values
automatically converted. I do wish their were a straightforward way to
convert the Variant value to a valid DATE, TIME, or TIMSTAMP string but
maybe that is what the Variant streaming operator, which I am using for all
other values does ( I am using C++ ). Thanks !
Technical Details
Message-ID:
<3dead8be$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3dea4ff3$1@newsgroups.borland.com> <s5tkuuklumb7k0o2tdo46fjujjtpf2v998@4ax.com> <3dea8b03$1@newsgroups.borland.com> <3deaa556$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 114a0e,4b82b358170a5247 X-Google-Attributes: gid114a0e,public X-Google-ArrivalTime: 2002-12-01 20:06:01 PST From: "Edward Diener" <eddielee@tropicsoft.com> Newsgroups: borland.public.interbase.sql References: <3dea4ff3$1@newsgroups.borland.com> <s5tkuuklumb7k0o2tdo46fjujjtpf2v998@4ax.com> <3dea8b03$1@newsgroups.borland.com> <3deaa556$1@newsgroups.borland.com> Subject: Re: Variant types for Interbase data types Date: Sun, 1 Dec 2002 22:54:19 -0500 Lines: 43 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 216.175.67.251 Message-ID: <3dead8be$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1038801086 216.175.67.251 (1 Dec 2002 19:51:26 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!newsfeed.news2me.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail