Hello you all,

I just can't find a way to solve this problem:

I have a couple of tables

my_table_a

my_table_b

my_table_c

These tables have a date field. I need to loop through all the tables and find the newest Date.

example:

my_table_a
10-06-2006
12-06-2006
13-06-2006
my_table_b
11-06-2006
my_table_c
12-06-2006
15-06-2006

In this case I need the 10-06-2006

However...unfortenately this is not the only problem.

I have the same tables, but temporary tables which also have date fields.

t_my_table_a

08-06-2006

09-06-2006

12-06-2006

t_my_table_b

07-06-2006

11-06-2006

13-06-2006

15-06-2006

16-06-2006

t_my_table_c

12-06-2006

15-06-2006

18-06-2006

What I need is this:

I need the minimum date from the t_ tables, but this date has to be greater than the newest date in the other tables

the newest in the first tables is: 15-06-2006

the minimum date in the t_ tables, which is greater that 15-06-2006 is 16-06-2006.

And this is what I need...A function which returns this date.

What I have so far is:

all the tables in an array...and I loop through the tables:

FOR r_index IN tables.FIRST .. tables.LAST
LOOP
v_date := func_GetDate(tables(r_index);
END LOOP;

Can someone please help me out with the unimplemented func_GetDate function?

Thanks...and i really do hope someone comes up with a usefull idea.....