Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

If...else statement

goodluck247Jan 16 2018 — edited Jan 17 2018

Hello, I have a general question about the if...else statement:

What is generally considered good practice, to put the most frequently occurring conditions in the beginning, and less frequent towards the end, or is there no such preference?

Just as an example, suppose client #10 has 100 ships, and client #20 has 120 ships, but clients #30, #40, #50, and #60 have 23, 12, 45, and 67 ships respectively.

In this case, should I write my statement like this:

if custno in (10,20) then

-- some code for hundreds of ships, different logic for each ship, potentially a lot of code

elsif custno in (60) then

-- some code for <100 ships

else

-- some code for <50 ships

end if;

or should I "do as I please" regardless of how often an event occurs, e.g.

if custno in (30,40,50) then

-- some code for some ships

elsif custno in (60) then

-- some code for some ships

else

-- some code for some ships

end if;

Hope I explained this clearly.

Thank you.

This post has been answered by Cookiemonster76 on Jan 16 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 14 2018
Added on Jan 16 2018
32 comments
1,068 views