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!

Printing date in SQL*Plus

james_pAug 13 2022

RDBMS version: 19c

At the start of execution of an SQL script (which will executed from SQL*Plus), I want to print the following

Processing started at: 13-Aug-2022 18:45

So, in SQL*Plus, I tried the following. No luck. What am I doing wrong ?

SQL> select 'Processing started at: to_char(sysdate, 'DD-MON-YYYY HH24:MI')' from dual;
SP2-0552: Bind variable "MI" not declared.

SQL>
SQL> select 'Processing started at: to_char(sysdate, 'DD-MON-YYYY HH24\:MI')' ESCAPE '\' FROM DUAL;
SP2-0552: Bind variable "MI" not declared.

-- Tried enclosing the entire string in double quotes. But, SQL*Plus didn't like it
SQL> select "Processing started at: to_char(sysdate, 'DD-MON-YYYY HH24\:MI')" ESCAPE '\' FROM DUAL;
select "Processing started at: to_char(sysdate, 'DD-MON-YYYY HH24\:MI')" ESCAPE '\' FROM DUAL
                                                                                *
ERROR at line 1:
ORA-00923: FROM keyword not found where expected


This post has been answered by Frank Kulash on Aug 13 2022
Jump to Answer
Comments
Post Details
Added on Aug 13 2022
4 comments
1,426 views