RE: two case in one select statement

RE: two case in one select statement

 

  


hai
select
case col_1 when 1 then (v_col_2 - v_col_3) else (v_col_2 -
v_col_3) * v_col_4)
end ,
case col_1 when 1 then v_col_5 else (v_col_5 *
v_col_6)
end from table1
dhanya M
-----Original Message-----
From: Firman Afandi
[mailto:oracledba-ezmlmshield-x52508664.[Email address protected]
Sent: Saturday, December 04, 2004 4:14 AM
To: LazyDBA Discussion
Subject: 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




--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: see http://www.lazydba.com
By using this list you agree to these
terms:http://www.lazydba.com/legal.html




Oracle LazyDBA home page