Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Which is best, IF or SELECT?

Author
Message
Rwilson
21
Years of Service
User Offline
Joined: 19th May 2003
Location: United States
Posted: 7th Sep 2003 23:31
What I'm asking is, in a situation where one is taking a single variable and deciding the next action based upon it, which is best, IF or SELECT. for example:

Blarg=rnd(500)

Select Blarg
case 20
stuff
endcase
case 50
stuff
endcase
case 500
stuff
endcase
endselect

if blarg = 20 then stuff
if blarg = 50 then stuff
if blarg = 500 then stuff

As one can see, both the SELECT and IF commands are doing the same thing, but what I can't tell is if perhaps one is faster than the other, or more efficient, or what. Does one go faster than the other, or is it just a matter of preference?
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 7th Sep 2003 23:34
With your if's in that form, the select is faster. However if you rearrange them like this then the difference is not really measurable.

Rwilson
21
Years of Service
User Offline
Joined: 19th May 2003
Location: United States
Posted: 7th Sep 2003 23:39
I see. Well, I suppose that makes it just a matter of preference. That's good to know. Thank you for the quick response IanM!

Login to post a reply

Server time is: 2024-09-20 21:24:39
Your offset time is: 2024-09-20 21:24:39