GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  Oracle  >  Basics
Go To First  |  Previous Question  |  Next Question 
 Basics  |  Question 45 of 47    Print  
Catch The Error
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.




  
Total Answers and Comments: 6 Last Update: October 10, 2008     Asked by: saginandkishore 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
June 28, 2008 07:42:41   #1  
Sainathreddy Member Since: June 2008   Contribution: 1    

RE: Catch The Error
set server output on is missing
 
Is this answer useful? Yes | No
July 01, 2008 15:27:36   #2  
sandy1970 Member Since: July 2008   Contribution: 1    

RE: Catch The Error
SELECT TO_CHAR(sysdate,'Day') INTO dayofweek FROM DUAL  returns

"Name of day padded with blanks to length of 9 characters"


IF 'Tuesday  ' = 'Tuesday' is not ture
 

 
Is this answer useful? Yes | No
July 09, 2008 16:41:13   #3  
ulricp Member Since: March 2008   Contribution: 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.

 
Is this answer useful? Yes | No
August 12, 2008 09:59:54   #4  
nagasankar Member Since: August 2008   Contribution: 2    

RE: Catch The Error
You have to use the TRIM before TO_CHAR as given below

SELECT TRIM(TO_CHAR(sysdate,'Day')) INTO dayofweek FROM DUAL returns.

 
Is this answer useful? Yes | No
September 24, 2008 01:40:48   #5  
Praveen2384 Member Since: September 2008   Contribution: 7    

RE: Catch The Error
No out put is because we have to set setserverout
 
Is this answer useful? Yes | No
October 10, 2008 09:43:52   #6  
nagellikiran1283 Member Since: October 2008   Contribution: 1    

RE: Catch The Error
There is nothing wrong in it.
 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape