🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.interbase.sql
5 messages
5 total messages Started by Edward Diener Sun, 01 Dec 2002 18:10
Variant types for Interbase data types
#11258
Author: Edward Diener
Date: Sun, 01 Dec 2002 18:10
11 lines
1664 bytes
What are the equivalent variant types for the Interbase data types ? Some of
these I can guess, particular the numeric, float, and character, but how are
the DATE, TIME, and TIMESTAMP stored in Variants and what are the equivalent
Variant types ?

I want to take a Variant value and use its output streaming ability to
create values for an SQL INSERT or UPDATE statement. As far as I can see
this will work properly for INTEGER, SMALLINT, FLOAT, DOUBLE PRECISION,
NUMERIC, DECIMAL, CHAR, and VARCHAR but I do not think it will work for the
DATE, TIME, and TIMESTAMP values without using low-level isc_ functions that
convert these values in Variants to a form which SQL recognizes.
Re: Variant types for Interbase data types
#11261
Author: Bill Todd
Date: Sun, 01 Dec 2002 20:45
26 lines
1976 bytes
Assuming you are using Delphi, 

V := IBDataSet1.FieldByName('SomeField').Value;

will give you the value of any field as a variant.

On Sun, 1 Dec 2002 13:10:35 -0500, "Edward Diener"
<eddielee@tropicsoft.com> wrote:

>What are the equivalent variant types for the Interbase data types ? Some of
>these I can guess, particular the numeric, float, and character, but how are
>the DATE, TIME, and TIMESTAMP stored in Variants and what are the equivalent
>Variant types ?
>
>I want to take a Variant value and use its output streaming ability to
>create values for an SQL INSERT or UPDATE statement. As far as I can see
>this will work properly for INTEGER, SMALLINT, FLOAT, DOUBLE PRECISION,
>NUMERIC, DECIMAL, CHAR, and VARCHAR but I do not think it will work for the
>DATE, TIME, and TIMESTAMP values without using low-level isc_ functions that
>convert these values in Variants to a form which SQL recognizes.
>


--
Bill (TeamB)
(TeamB cannot respond to questions received via email)
Re: Variant types for Interbase data types
#11263
Author: Edward Diener
Date: Sun, 01 Dec 2002 22:22
44 lines
2760 bytes
"Bill Todd" <bill@notthis.dbginc.com> wrote in message
news:s5tkuuklumb7k0o2tdo46fjujjtpf2v998@4ax.com...
> Assuming you are using Delphi,
>
> V := IBDataSet1.FieldByName('SomeField').Value;
>
> will give you the value of any field as a variant.

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.

>
> On Sun, 1 Dec 2002 13:10:35 -0500, "Edward Diener"
> <eddielee@tropicsoft.com> wrote:
>
> >What are the equivalent variant types for the Interbase data types ? Some
of
> >these I can guess, particular the numeric, float, and character, but how
are
> >the DATE, TIME, and TIMESTAMP stored in Variants and what are the
equivalent
> >Variant types ?
> >
> >I want to take a Variant value and use its output streaming ability to
> >create values for an SQL INSERT or UPDATE statement. As far as I can see
> >this will work properly for INTEGER, SMALLINT, FLOAT, DOUBLE PRECISION,
> >NUMERIC, DECIMAL, CHAR, and VARCHAR but I do not think it will work for
the
> >DATE, TIME, and TIMESTAMP values without using low-level isc_ functions
that
> >convert these values in Variants to a form which SQL recognizes.
> >
>
>
> --
> Bill (TeamB)
> (TeamB cannot respond to questions received via email)
Re: Variant types for Interbase data types
#11265
Author: Wayne Niddery [TeamB]
Date: Mon, 02 Dec 2002 00:09
33 lines
2796 bytes
"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;


--
Wayne Niddery (Logic Fundamentals, Inc.)
RADBooks: http://www.logicfundamentals.com/RADBooks/delphibooks.html
It used to be that other people's achievements were considered an
inspiration, not a grievance.
Re: Variant types for Interbase data types
#11268
Author: Edward Diener
Date: Mon, 02 Dec 2002 03:54
41 lines
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 !
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads