Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Two weird things about the AT TIME ZONE clause

mathguyAug 12 2016 — edited Aug 15 2016

Oracle database 11.2.

https://docs.oracle.com/cd/E11882_01/server.112/e10729/ch4datetime.htm#NLSPG264     says:

Converting Time Zones With the AT TIME ZONE Clause

A datetime SQL expression can be one of the following:

  • A datetime column
  • A compound expression that yields a datetime value   [.......]

https://docs.oracle.com/cd/E11882_01/server.112/e10729/ch4datetime.htm#NLSPG238     says:

Datetime Data Types

This section includes the following topics:

My SQL*Plus session says:

SQL> select systimestamp at time zone 'Australia/Sydney' from dual;

SYSTIMESTAMPATTIMEZONE'AUSTRALIA/SYDNEY'
---------------------------------------------------------------------------
13-AUG-16 07.42.20.789000 AM AUSTRALIA/SYDNEY

1 row selected.

Which is perfectly fine. But it also says:

SQL> select sysdate at time zone 'Australia/Sydney' from dual;
select sysdate at time zone 'Australia/Sydney' from dual
       *
ERROR at line 1:
ORA-30084: invalid data type for datetime primary with time zone modifier

Huh?  Isn't sysdate of date data type?

Worse, the error message for the same command in SQL Developer says:

Error starting at line : 24 in command -

select sysdate at time zone 'Australia/Sydney' from dual

Error at Command Line : 24 Column : 8

Error report -

SQL Error: ORA-30084: invalid data type for datetime primary with time zone modifier

30084. 00000 -  "invalid data type for datetime primary with time zone modifier"

*Cause:    When a time zone modifier is specified, the data type of datetime

           primary must be one of the following: TIME, TIME WITH TIME ZONE,

           TIMESTAMP, TIMESTAMP WITH TIME ZONE.

*Action:

I didn't know "TIME" was an Oracle database data type.

Am I seeing things? Or is there a bug in the AT TIME ZONE implementation, and one more in the error handling message?

Cheers,   mathguy-ro

This post has been answered by Anton Scheffer on Aug 12 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 12 2016
Added on Aug 12 2016
7 comments
2,485 views