Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Yearly Automatic Table Insertion
> You could insert all of the years for the next 20 years all at once.
> That way you don't have to schedule a job. Change your query so that
> it selects only the appropriate values...
>
> select year
> from dates
> where year<=to_number(to_char(sysdate, 'YYYY'))
> /
Why use a special table at all? In 20 years, you'll just have to add more rows. But you don't need a special table for this. Just extend your query further:
SQL> select rownum+1990 from all_objects 2 where rownum+1990 <= to_char(sysdate,'YYYY');
ROWNUM+1990
1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004
14 rows selected.
All you need is *any* table or view that has the number of rows you need to display. It doesn't have to be a table that you specifically populate with data. In my example above, I display all of the years from 1990 to the current year. This can be modified accordingly.
Cheers,
Brian
-- =================================================================== Brian Peasland dba_at_remove_spam.peasland.com Remove the "remove_spam." from the email address to email me. "I can give it to you cheap, quick, and good. Now pick two out of the three"Received on Tue Mar 23 2004 - 07:49:22 CST