RE: Handling INTERVAL datatypes
Posted in 1997
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
Similarily in 4gl do:
DEFINE f_tmp_seconds INTERVAL SECOND(9) TO SECOND
DEFINE f_tmp CHAR(10)
DEFINE f_normal_hours INTERVAL HOUR TO SECOND
DEFINE f_seconds INTEGER
LET f_normal_hours =3D ("09:30:30")
LET f_tmp_seconds =3D f_normal_hours
LET f_tmp =3D f_tmp_seconds
LET f_seconds =3D f_tmp
When defining the seconds interval make sure it is large enough (I have =20
it at 9).
Catalin Dumitrache. EXE Technologies Melbourne.
----------
From: proberts@lynx.informix.com[SMTP:PC @INTERNET =20
{proberts@lynx.informix.com}]
Sent: Tuesday, 9 September 1997 11:05
To: informix-list@rmy.emory.edu; Catalin Dumitrache
Subject: Re: Handling INTERVAL datatypes
--------------------------------------------------------------------------=
=20
--
In article <34147014.57188646@news>, Peter Jessup <pje@fmsc.com.au> =20
wrote:
>I have a table that contains a couple of columns defined as INTERVAL
>HOUR TO SECOND. Is there an easy way using SQL to cast this into an
>INTEGER datatype representing the number of seconds in the interval?
I feel sure that there must be a better way, but this worked for me
(using I-SQL 6.01 & OnLine 7.20 [I think that's what I'm running])...
create temp table t1 ( a interval hour to second ) ;
insert into t1 values ( "17:42:23" ) ;
insert into t1 values ( "01:42:23" ) ;
insert into t1 values ( "00:42:23" ) ;
create temp table t2 ( b interval second(5) to second ) ;
insert into t2 select * from t1 ;
create temp table t3 ( c char(100) ) ;
insert into t3 select * from t2 ;
create temp table t4 ( d integer ) ;
insert into t4 select * from t3 ;
select * from t4 ;
which gave me:-
d
63743
6143
2543
3 row(s) retrieved.
Curiously, I can convert from
"interval second(5) to second" to "char(100)" and thence to =20
"integer"
but not directly from
"interval second(5) to second" to =20
"integer"
(ie I got a `can't convert' error when I tried to cut out temp table t3)
- Paul (not a spokesman)