Re: Handling INTERVAL datatypes
Posted in 1997
In article <34147014.57188646@news>, Peter Jessup <pje@fmsc.com.au> 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 "integer"
but not directly from
"interval second(5) to second" to "integer"
(ie I got a `can't convert' error when I tried to cut out temp table t3)
- Paul (not a spokesman)