>From: erik@rat.se (Erik Heimdahl)
>Date: 4 Jun 1997 13:05:25 GMT
>X-Informix-List-Id: <news.38722>
>
>I have a weird problem with a datetime host-variable (ESQL/C - 5.08 for
>SOLARIS). I use it as:
>
>void foo(){
> $datetime year to fraction(5) stWhen;
> $char szWhen[26];
>
> dtcurrent( &tWhen);
> dttoasc( &tWhen, szWhen);
>
> $insert into t1( :tWhen);
>
> return_to_user_and_log( szwhen);
>}
>
>Most of the time, calling foo() works just fine, but sometimes I get the error:
> '-1263 A field in a datetime or interval is out of range.'
>and my log produces:
> [1997-06-04 15:02:31.8200+]
>instead of:
> [1997-06-04 15:02:31.82000]
>as I expect it to. Where does the '+' sign come from ??
I've seen that sort of behaviour, but not for several years now. And
finding it in 5.08 is disturbing. I've forgotten exactly what the problem
was, but if my memory serves me correctly, the dtcurrent() function is
mismanaging an overflow somewhere. I recall the problem as normally
showing in the second or third digit, rather than the fifth, but when I was
looking at the code, dtcurrent didn't return a fifth digit anyway -- as it
would seem not to in your example.
What can you do about it? Not a lot, probably. Report it as a bug,
perhaps. I fixed the typo in your code (you declare stWhen and use tWhen,
and reference szwhen instead of szWhen), and replaced the insert and
return_to_user_and_log() operations with puts(szWhen). I then ran it in a
tight loop:
#include <stdio.h>
#include <datetime.h>
void foo()
{
$datetime year to fraction(5) tWhen;
$char szWhen[26];
dtcurrent( &tWhen);
dttoasc( &tWhen, szWhen);
puts(szWhen);
}
int main(void)
{
int i;
for (i = 0; i < 10000; i++)
foo();
return(0);
}
However, when I tested it on 5.08.UD1 ESQL/C on Solaris 2.5.1 (very close
to your configuration), I didn't see any problem. Do you see the problem
using the code above? Are you using 5.08.UD1 or a different version?
Yours,
Jonathan Leffler (johnl@informix.com) #include <disclaimer.h>