Can you use cursors and if so, how? [message #419646] |
Mon, 24 August 2009 13:45 |
csphard
Messages: 8 Registered: February 2009
|
Junior Member |
|
|
I have a report where I need to count the following.
I need to check 2 dates from 2 separate fields aand pick the latest date.
The one with the latest date I need to count the information that is associated with it.
Is that possible?
I have been thinking about creating a cursor and counting the information as I loop through the
table. I just do not know how do I print out each line of information with its count as I
loop through.
Howard
|
|
|
|
Re: can you use cursors and if so how [message #420380 is a reply to message #419646] |
Fri, 28 August 2009 15:34 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Looping (i.e. row by row) is slow. Do you really want/need to do that? It is easy to find out which value is larger (use Oracle GREATEST function). Then, perhaps you could do something likeSELECT COUNT(*)
FROM your_table
WHERE date_column = GREATEST (date_1, date_2)
If you, however, want to do that in a loop, create a formula column - it accepts PL/SQL code so it is possible to use cursors and loops in there.
|
|
|