dbTalk Databases Forums  

TO_CHAR bug?

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss TO_CHAR bug? in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
suvinay
 
Posts: n/a

Default TO_CHAR bug? - 07-21-2006 , 03:07 PM






Hi,
In a few databases, the following statements results in a missing "Z"
at the end?
A bug?


SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z"')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-
------------------------------
2006-07-21T15:52:36.09

//--- where is "Z" at the end?

If I give two space in "Z{space}{space}" as "Z ", it works

SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z "')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-DD
--------------------------------
2006-07-21T15:07:29.14Z


Help appreciated very much.

Thanks.
-- Suvinay


Reply With Quote
  #2  
Old   
Michel Cadot
 
Posts: n/a

Default Re: TO_CHAR bug? - 07-22-2006 , 12:19 AM







"suvinay" <suvinay (AT) gmail (DOT) com> a écrit dans le message de news: 1153512454.968662.250260 (AT) h48g20...oglegroups.com...
Quote:
Hi,
In a few databases, the following statements results in a missing "Z"
at the end?
A bug?


SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z"')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-
------------------------------
2006-07-21T15:52:36.09

//--- where is "Z" at the end?

If I give two space in "Z{space}{space}" as "Z ", it works

SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z "')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-DD
--------------------------------
2006-07-21T15:07:29.14Z


Help appreciated very much.

Thanks.
-- Suvinay

Works for me:

SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z"')
2 from dual;
TO_CHAR(SYSTIMESTAMP,'YYYY-MM-
------------------------------
2006-07-22T07:14:45.10Z

But of course a bug is neither related to a version nor to an environment.

Regards
Michel Cadot




Reply With Quote
  #3  
Old   
Dave
 
Posts: n/a

Default Re: TO_CHAR bug? - 07-24-2006 , 08:46 AM



suvinay wrote:
Quote:
Hi,
In a few databases, the following statements results in a missing "Z"
at the end?
A bug?


SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z"')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-
------------------------------
2006-07-21T15:52:36.09

//--- where is "Z" at the end?

If I give two space in "Z{space}{space}" as "Z ", it works

SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z "')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-DD
--------------------------------
2006-07-21T15:07:29.14Z


Help appreciated very much.

Thanks.
-- Suvinay

Platform/version? What distinguishes databases that reproduce the
problem from those that don't?

Short answer: maybe. However, TFM states "The total length of a
datetime format model cannot exceed 22 characters" and yours do, so does
it work ok if you split it and concatenate the results?


Reply With Quote
  #4  
Old   
suvinay
 
Posts: n/a

Default Re: TO_CHAR bug? - 07-25-2006 , 10:45 AM



Thanks for all the feedback.
Dave, you are correct about "split and concat" - that works. I didnot
know about the
length restriction of dataformat. Not sure if that was causing it but
here is a little bit
more information.

If it was 24 char limit issue, then why does it work if the SQL
statement looks as follows:

select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z "') from
dual;

Notice two space inside "Z " i.e, "Z<space><space>". This produces
correct result.
So apparently it is truncating last two characters which to me
indicates that it is
something to do with character set issue since TO_CHAR's behavior
depends
on db character set.

So looking at current character set of db, this is what I have:

CHARACTER SET UTF8
NATIONAL CHARACTER SET AL16UTF16

and the problem shows.

I recreate the db with the following character sets:

CHARACTER SET WE8ISO8859P1
NATIONAL CHARACTER SET UTF8

and the problem is gone! woohooo!

So definitely a character set issue.


BTW, this is 9206 ORACLE.



Thanks
-- suvinay




Dave wrote:
Quote:
suvinay wrote:
Hi,
In a few databases, the following statements results in a missing "Z"
at the end?
A bug?


SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z"')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-
------------------------------
2006-07-21T15:52:36.09

//--- where is "Z" at the end?

If I give two space in "Z{space}{space}" as "Z ", it works

SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z "')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-DD
--------------------------------
2006-07-21T15:07:29.14Z


Help appreciated very much.

Thanks.
-- Suvinay


Platform/version? What distinguishes databases that reproduce the
problem from those that don't?

Short answer: maybe. However, TFM states "The total length of a
datetime format model cannot exceed 22 characters" and yours do, so does
it work ok if you split it and concatenate the results?


Reply With Quote
  #5  
Old   
suvinay
 
Posts: n/a

Default Re: TO_CHAR bug? - 07-25-2006 , 10:46 AM



Oh and I forgot to add - this is 9206 Oracle on Solaris 64-bit.


suvinay wrote:
Quote:
Thanks for all the feedback.
Dave, you are correct about "split and concat" - that works. I didnot
know about the
length restriction of dataformat. Not sure if that was causing it but
here is a little bit
more information.

If it was 24 char limit issue, then why does it work if the SQL
statement looks as follows:

select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z "') from
dual;

Notice two space inside "Z " i.e, "Z<space><space>". This produces
correct result.
So apparently it is truncating last two characters which to me
indicates that it is
something to do with character set issue since TO_CHAR's behavior
depends
on db character set.

So looking at current character set of db, this is what I have:

CHARACTER SET UTF8
NATIONAL CHARACTER SET AL16UTF16

and the problem shows.

I recreate the db with the following character sets:

CHARACTER SET WE8ISO8859P1
NATIONAL CHARACTER SET UTF8

and the problem is gone! woohooo!

So definitely a character set issue.


BTW, this is 9206 ORACLE.



Thanks
-- suvinay




Dave wrote:
suvinay wrote:
Hi,
In a few databases, the following statements results in a missing "Z"
at the end?
A bug?


SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z"')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-
------------------------------
2006-07-21T15:52:36.09

//--- where is "Z" at the end?

If I give two space in "Z{space}{space}" as "Z ", it works

SQL> select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z "')
from dual;

TO_CHAR(SYSTIMESTAMP,'YYYY-MM-DD
--------------------------------
2006-07-21T15:07:29.14Z


Help appreciated very much.

Thanks.
-- Suvinay


Platform/version? What distinguishes databases that reproduce the
problem from those that don't?

Short answer: maybe. However, TFM states "The total length of a
datetime format model cannot exceed 22 characters" and yours do, so does
it work ok if you split it and concatenate the results?


Reply With Quote
  #6  
Old   
Anurag Varma
 
Posts: n/a

Default Re: TO_CHAR bug? - 07-25-2006 , 12:27 PM




suvinay wrote:
Quote:
Thanks for all the feedback.
Dave, you are correct about "split and concat" - that works. I didnot
know about the
length restriction of dataformat. Not sure if that was causing it but
here is a little bit
more information.

If it was 24 char limit issue, then why does it work if the SQL
statement looks as follows:

select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z "') from
dual;

Notice two space inside "Z " i.e, "Z<space><space>". This produces
correct result.
So apparently it is truncating last two characters which to me
indicates that it is
something to do with character set issue since TO_CHAR's behavior
depends
on db character set.

So looking at current character set of db, this is what I have:

CHARACTER SET UTF8
NATIONAL CHARACTER SET AL16UTF16

and the problem shows.

I recreate the db with the following character sets:

CHARACTER SET WE8ISO8859P1
NATIONAL CHARACTER SET UTF8

and the problem is gone! woohooo!

So definitely a character set issue.


BTW, this is 9206 ORACLE.



Thanks
-- suvinay
--snip--

Yes it appears to be the Bug 4777057
WRONG OUTPUT TO_CHAR(DATE FORMAT) IN UTF8 DATABASE

I don't see any workaround listed in the bug description

Anurag



Reply With Quote
  #7  
Old   
suvinay
 
Posts: n/a

Default Re: TO_CHAR bug? - 07-25-2006 , 01:06 PM



There you go - thanks Anurag.
I specially like their resolution:
<quote>
Workaround/s ~~~~~~~~~~~~ Do not use literal constants in date
format strings.
</quote>

Lovely!

Thanks again.

Anurag Varma wrote:
Quote:
suvinay wrote:
Thanks for all the feedback.
Dave, you are correct about "split and concat" - that works. I didnot
know about the
length restriction of dataformat. Not sure if that was causing it but
here is a little bit
more information.

If it was 24 char limit issue, then why does it work if the SQL
statement looks as follows:

select TO_CHAR(systimestamp, 'YYYY-MM-DD"T"HH24:MI:SS.FF2"Z "') from
dual;

Notice two space inside "Z " i.e, "Z<space><space>". This produces
correct result.
So apparently it is truncating last two characters which to me
indicates that it is
something to do with character set issue since TO_CHAR's behavior
depends
on db character set.

So looking at current character set of db, this is what I have:

CHARACTER SET UTF8
NATIONAL CHARACTER SET AL16UTF16

and the problem shows.

I recreate the db with the following character sets:

CHARACTER SET WE8ISO8859P1
NATIONAL CHARACTER SET UTF8

and the problem is gone! woohooo!

So definitely a character set issue.


BTW, this is 9206 ORACLE.



Thanks
-- suvinay
--snip--

Yes it appears to be the Bug 4777057
WRONG OUTPUT TO_CHAR(DATE FORMAT) IN UTF8 DATABASE

I don't see any workaround listed in the bug description

Anurag


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.