Skip to content
Advertisement

PL/SQL procedure to output line the given date if not existing, latest date should be given

I have this table informationvalues with the contents:enter image description here

Now I create a procedure where I need to input a date parameter which should output line the correct attr with given price. If the date doesn’t exist the latest date should be selected.

The solution table for to_date('01-jan-19') would look like this:

enter image description here

This would be then output line in the procedure.

Should I select to correct tuple and output line it or would it be best to just bulk collect everything and then check in a for loop with an if statement what tuple I need to display.

What I have so far:

A select statement with the tuples I am looking for:

Or a procedure where I bulk collect everything and then I need to sort out what tuple I need:

Both are not working right, so what am I missing to display tuple with the correct date.

Advertisement

Answer

Please try:

Sample execution:

Output:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement