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.
Use the function trunc(my_timestamp). You can use select to_date(to_char(date_field,'dd/mm/yyyy')) from table.
yyyy-MM-dd HH:mm:ss. 2018-03-5 15:16:0; 2018-03-5 15:16:0 +5:30. yyyy-MM-dd HH.mm.ss. 2018-03-5 15.16.0; 2018-03-5 15.16.0 +5:30. yyyy-MM-dd HH:mm.
A literal is an explicit numeric, character, string, or Boolean value not represented by an identifier.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With