IF and Else running both at the same time.

Hello world

I have a strange problem underneath the small piece of code, both if and other blocks are run at the same time.

Kindly advise on this strange behavior.

DECLARE

p_year varchar2 (4): = 9999;

BEGIN

FOR I IN (SELECT lookup_code FROM fnd_lookup_values, meaning)

WHERE lookup_type = 'PARALLEL_ALLOCATION')

loop

DBMS_OUTPUT. Put_line(i.Meaning ||) e -'|| i.lookup_code);

IF i.meaning = THEN p_year

DBMS_OUTPUT. Put_line ("year values now");

DBMS_OUTPUT. Put_line(i.Meaning ||) e -'|| p_year);

on the other

DBMS_OUTPUT. Put_line (' year values in other ');

DBMS_OUTPUT. Put_line(i.Meaning ||) e -'|| p_year);

end if;

end loop;

END;

/

OUTPUT-

9999 2012

Now the values of the year

9999 9999

8888 2016

Values of the year in the world

8888-9999

Select used in for loop is to have two values only i.e.

sense lookup_code

9999 2012

8888 2016

Expected results should be in part IF that is and on the other hand does not run.

9999 and 2012 of DBMS_OUTPUT

Nope...

If you compare 8888 with 9999, it means that this condition is false (it is not true)...

It will be ignored... in your case... (nothing will happen)

You can also change your query... so, you can select just the data in your table when meaning is equal to a number...

SELECT meaning, lookup_code FROM fnd_lookup_values
         WHERE lookup_type = 'PARALLEL_ALLOCATION'
and meaning = p_year

but... These are really programming basics...

Tags: Database

Similar Questions

Maybe you are looking for