Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOW DO I OPTIMIZE MULTIPLE IFS?

Status
Not open for further replies.

gys67

Programmer
Nov 4, 2003
19
US
Begin
IF nvl(mv_xyz_id,'A') = 'A' then
if (nvl(mv_rec.sec_b_id,'B') <> 'B') and (mv_rec.sec_b_id_type = 'XYZ') then
m_b_end_date_2 := to_char(sysdate-1,'YYYYMMDD');
end if;
Else
if (nvl(mv_rec.sec_b_id,'B') <> 'B') and (mv_rec.sec_buid_id_type = 'XYZ') then
if mv_rec.pri_b_id <> mv_abc_id then -- IF not for the same BU
m_b_end_date_2 := to_char(sysdate-1,'YYYYMMDD');
end if;
else
mv_message :='ADD NEW XYZ USING THE SYSDATE';
m_b_2 := mv_rec.sec_b_id;
m_b_type_2 := mv_rec.sec_b_id_type;
m_buid_start_date_2 := to_char(sysdate,'YYYYMMDD');
end if;
END IF;
End;
ELSE
 
Gys,

Besides your having the extraneous &quot;ELSE&quot; following your final &quot;End;&quot; statement, what seems to be the problem with your code? What makes you think that your multiple &quot;IFs&quot; are not &quot;optimized&quot;?

Dave
Sandy, Utah, USA @ 02:13 GMT, 19:13 Mountain Time
 
how about decode?

Ion Filipski
1c.bmp
 
Ion,

Notice that Gys's code is PL/SQL. You can use DECODE only within a SQL statement, not alone in PL/SQL.

Dave
Sandy, Utah, USA @ 16:23 GMT, 09:23 Mountain Time
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top