Timestamp literal in Oracle SQL Developer

Viewed 4618

I need to test sql queries on Oracle SQL Developer. These queries contain timestamp literals in the format

{ts 'yyyy-mm-dd hh:mm:ss.fff'}

Oracle SQL Developer does not seem to accept this syntax, the symbol { causes error ORA-00911: invalid character.

Is there anything I can do?

EDIT

The sql editor advises me that { is not allowed. I tried with two other tools (DbVisualizer and DBeaver), both using the Oracle Thin driver, all works fine.

However I still want to use that syntax in Oracle SQL Developer because it has interesting features. The queries I have to test are not written by me, change syntax is not an option.

3 Answers

Use an actual SQL timestamp literal:

TIMESTAMP 'yyyy-mm-dd hh:mm:ss.fff'

What you were using is the JDBC escape syntax, which is supported by JDBC drivers, but not by the Oracle database itself.

You can use CAST

select to_char(cast(sysdate as timestamp),'DD-MON-YYYY HH24:MI:SS.FF') from dual
Related