two case in one select statement

two case in one select statement

 

  

Hello LazyDBA,

I want to write this script in plsql (oracle 9i):
---------------------------------------------------
table1:
v_col_1
v_col_2
v_col_3
v_col_4
v_col_5
v_col_6


the script:
declare
....
begin
BEGIN
for x in ( select
case
when col_1 = 1 then
(v_col_2 - v_col_3)
when col_1 != 1 then
(v_col_2 - v_col_3) * v_col_4)
end case,
case
when col_1 = 1 then
v_col_5
when col_1!= 1 then
(v_col_5 * v_col_6)
end case from table1 ) loop
begin
...
end;
end loop;

end;
/

and it always return PLS-00402: alias required in SELECT list of cursor to avoid duplicate column names

how to make aliasing of this select statement?

thank's in advanced.



--
Best regards,
Firman Afandi



Oracle LazyDBA home page