| |
GeekInterview.com > Interview Questions > Oracle > Basics
| Print | |
Question: Catch The Error
Answer: SQL>DECLARE 2 dayofweek VARCHAR2(200); 3 BEGIN 4 SELECT TO_CHAR(sysdate,'Day') INTO dayofweek FROM DUAL ; 5 6 IF dayofweek = 'Tuesday' 7 THEN 8 DBMS_OUTPUT.PUT_LINE('Aloha!!! Today Is Tuesday'); 9 ELSE 10 DBMS_OUTPUT.PUT_LINE('Today is '||to_char(sysdate,'Day')); 11 END IF; 12 END; 13 / Today is Tuesday
PL/SQL procedure successfully completed. SQL>
What's wrong in the above anonymous block if anything at all.
|
| July 07, 2008 16:41:13 |
#3 |
| ulricp |
Member Since: March 2008 Total Comments: 1 |
RE: Catch The Error |
There is nothing wrong with the code. To try it just cut and paste the code into a SQL script, substitute the current day for Tuesday and run it. The result is as expected.
The "error" is in the output. So I think the question is misleading although it does say "... error if any ...".
Regards Ulric. |
| |
Back To Question | |