Oracle Certification, Database Administration, SQL, Application, Programming Reference Books
Editing commands at the SQL> prompt

When executing commands at the SQL prompt, do you ever find (either before or after typing the SQL in) that you entered something wrong?  If you thought the only way two ways to fix the problem was to [1] retype the the SQL statement or [2] edit the command using the EDIT command, then you are mistaken.  Here's an example of the way I often fix problems.
Wrong SQL Right SQL
select decode(to_char(sysdate,'YYYY'),'1998') select decode(to_char(sysdate,'YYYY'),'1998',1)
from dual; from dual;

See what's wrong  on the Wrong SQL side?  The action that's done if the Year does match '1998' is not specified!  Executing this would result in a run-time error.  The Right SQL side shows the addition of an action.  So if the year did match '1998', then a '1' would be the result of executing this SQL statement.  Here are the steps that I would take to fix this problem:
Since the problem is on line 1, at the SQL> prompt, enter the command 1 and then press 
The line '1* select decode(to_char(sysdate,'YYYY'),'1998')' will appear and you will be back at a SQL> prompt
Type c/1998')/1998',1 and then press .  At the SQL> prompt, enter a '/' to run your command correctly

Return to : Oracle Database, SQL Tips