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!

LOCALTIMESTAMP, SYSTIMESTAMP and TO_TIMESTAMP

ApostolisJul 26 2012 — edited Jul 26 2012
Hello,

http://docs.oracle.com/cd/B19306_01/server.102/b14200/functions079.htm

The above link to the Oracle manual gives, regarding localtimestamp, the following working example:

INSERT INTO local_test VALUES
(TO_TIMESTAMP(LOCALTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF PM'));

I have some questions regarding the conversion to TIMESTAMP.
1) Why convert a TIMESTAMP value (the return type of LOCALTIMESTAMP is TIMESTAMP) to TIMESTAMP?
2) Why is the function TO_TIMESTAMP works when we supply as the first argument the LOCALTIMESTAMP? According to the manual, the function TO_TIMESTAMP converts to TIMESTAMP arguments of CHAR, VARCHAR2, NCHAR, or NVARCHAR2 datatype.
3) If the answer of the question above (2) is because of an implicit conversion to VARCHAR2, then why SYSTIMESTAMP fails? For example the following does not work:

INSERT INTO local_test VALUES
(TO_TIMESTAMP(SYSTIMESTAMP, 'DD-MON-RR HH.MI.SSXFF PM TZH:TZM'));

Thank you in advance,
Apostolos Giannakidis
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 23 2012
Added on Jul 26 2012
3 comments
1,248 views