CassidyHunt
IS-IT--Management
I am getting the impression that two departments that didn't communicate created the select case for SQL side of oracle but not the PL/SQL side in 8i.
i.e.
Now in PL/SQL
Haven't tested this exact code above to make sure it works but I have tested other code that I know works. For some reason you can not use nested selects, case statements, nvl, or decode in PL/SQL.
I guess to make it short, am I correct about this or do I need to adjust my code in PL/SQL to accomplish this? (Hoping for the code adjustment that does not require a view) If I am right that this is not support in PL/SQL then I wonder why would you do that to people.
Thanks
Cassidy
i.e.
Code:
select table1.field1
case
when table1.field2 is null
then
(select table2.field1
from table2
where table2.field2 = table1.field1)
else
table1.field2
end
as field2
from table1
Now in PL/SQL
Code:
declare
cursor my_cur is
(select table1.field1
case
when table1.field2 is null
then
(select table2.field1
from table2
where table2.field2 = table1.field1)
else
table1.field2
end
as field2
from table1);
begin
Open my_cur;
for cur_row in my_cur
loop
dbms_output.put_line(cur_row.field1 ||' '|| cur_row.field2);
end loop;
end;
Haven't tested this exact code above to make sure it works but I have tested other code that I know works. For some reason you can not use nested selects, case statements, nvl, or decode in PL/SQL.
I guess to make it short, am I correct about this or do I need to adjust my code in PL/SQL to accomplish this? (Hoping for the code adjustment that does not require a view) If I am right that this is not support in PL/SQL then I wonder why would you do that to people.
Thanks
Cassidy