Prepare for your Next Interview
This is a discussion on pl/sql within the SQL forums, part of the Databases category; write a program to accept a year and display all sundays along with the date....
|
|||
|
Re: pl/sql
Create or replace procedure test_proc ( year number ) is
lastday_prev_year date; first_sunday date; i number; begin lastday_prev_year:= '31-dec-'||to_char(year-1); select next_day(lastday_prev_year,'sunday') into first_sunday from dual; for i in 1..52 loop dbms_output.put_line(first_sunday|| ' is sunday'); first_sunday := first_sunday + 7; end loop; end ; / Last edited by krishnaindia2007 : 08-09-2008 at 08:26 AM. |
|
|||
|
in this query you have to enter the year 4 times(e.g 08) in yy format.....!
====================================================== SELECT * FROM (SELECT (TO_DATE ('01-jan-'||&ENTER_YY_FORMAT, 'dd-mon-yy') + rownum-1 ) date_list, TRIM(to_char((TO_DATE ('01-jan-'||&ENTER_YY_FORMAT, 'dd-mon-yy') + rownum-1 ),'DAY')) DAY_LIST FROM all_objects WHERE rownum <= TO_DATE ('31-dec-'||&ENTER_YY_FORMAT, 'dd-mon-yy') - TO_DATE ('01-jan-'||&ENTER_YY_FORMAT, 'dd-mon-yy')+1)TOT_DATE WHERE TOT_DATE.DAY_LIST ='SUNDAY'; ================================================ hope this will work for you... THANKS RAJIV GUPTA YOGIK TECHNOLOGIES PVT. LTD. |