function with select if statement query
939701May 30 2012 — edited May 30 2012Hi,
I want to use if condition in select statement in function.
But i implemented in case too ,its taking more time to return the value while using case statement.
My function is like this
create or replace FUNCTION GET_CODE
(pv_type IN table1.type%TYPE,
pv_desc1 IN table2.type%TYPE,
pv_desc2 IN table3.type%TYPE)
RETURN varchar2(35 byte)
IS
V_ret_string varchar2(35 byte);
BEGIN
SELECT case when(table2.xxx like 'fff%') then 1
when (table3.yyy like 'fff%') then 2
when (table4.zzz like 'fff%') then 3
else table1.aaa
INTO V_ret_string
FROM
table1 a,table2 b,table3 c table4 d
WHERE
table1.column1=table2.column1
and (table1.column2=table3.column1 or table1.column2=table4.column1) and
UPPER(b.type) = UPPER(pv_type) and
(UPPER(c.desc) = UPPER(pv_desc1) or UPPER(d.desc1) = UPPER(pv_desc2)) ;
RETURN V_ret_string;
END GET_TRANSACTION_CODE;
Pls help me how to use if condition.
Regards,
Punitha