Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: Y2K problem with sysdate
On Thu, 06 Jan 2000 22:16:24 +0100, you wrote:
>Deepa Dinendra wrote:
>> My Pro*c programs which were not having any problems with dates before
>> 01-jan-2000 is failing where ever there is sysdate function call.
>>
>> I tried the following:
>> today varchar[15];
>>
>> EXEC SQL select sysdate into :today from dual;
>> printf("Today is %s \n", today.arr);
>>
>> The result I obtained is
>> Today is 05-JAN-015:20
>
>Perhaps not the real problem,
>but since when is a varchar \0 terminated?
>You use printf with %s...
>shouldn't the line "today.arr[today.len] = '\0';" be added just before
>printing?
excellent point. consider:
static void process()
{
VARCHAR today[15];
char bogusdata[55];
memset( &today, 'a', sizeof(today) ); memset( bogusdata, 'b', sizeof(bogusdata) ); exec sql select sysdate into :today from dual; printf( "%s\n", today.arr ); printf( "%.*s\n", today.len, today.arr );}
$ ./t
07-JAN-00aaaaaaaù@ï}D
07-JAN-00
there is garbage after the "O5-JAN-00" in their memory, looks like a backspace
and then some data. so the terminal prints the date, backspaces, prints the
rest of the garbage and finally finds a null terminator and stops printing...
--
See http://osi.oracle.com/~tkyte/ for my columns 'Digging-in to Oracle8i'...
Current article is "Part I of V, Autonomous Transactions" updated June 21'st
Thomas Kyte tkyte_at_us.oracle.com Oracle Service Industries Reston, VA USA
Opinions are mine and do not necessarily reflect those of Oracle Corporation Received on Fri Jan 07 2000 - 07:21:04 CST
![]() |
![]() |