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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

valid values 3

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I know I've seen something way more elegant than this:

if ADivision <> 1 and ADivision <> 5 and ADivision <> 12 and ADivision <> 15 and ADivision <> 17 then


can anyone please help me remember how to make a list of values and use the equivalent of IN?

Leslie

Anything worth doing is a lot more difficult than it's worth - Unknown Induhvidual

Essential reading for anyone working with databases: The Fundamentals of Relational Database Design
 
a) Ordinals:

a.1) Sets if your are using ordinals with ordinality between 0..255.

Code:
if ADivision not (in [1, 5, 12, 15, 17]) then ...

a.2) "Case" statement otherwise.

Code:
case ADivision of
  1000, 5000, 12000, 15000, 17000 : ....;
  case else                       : ....
  end;

b) "If" statement for strings

buho (A).


 
I guess I just wasn't getting the IN syntax correct! I knew it could be done though!

have a star!

les
 
buho,

shouldn't
a.1)
be
Code:
if not ( ADivision in [ 1, 5, 12, 15, 17 ] ) then ...

and
a.2)
be
Code:
case ADivision of
  1000, 5000, 12000, 15000, 17000 : ....;
  else                       ....
  end;

Andrew
Hampshire, UK
 
I'll try that tomorrow Andrew, I couldn't get buho's to work correctly, so you're probably right!

les
 
Indeed, Andrew!

What a mess I did. Passing the star to you.

buho (A).
 
Yeah! Thanks for all the help, a.1 worked just fine!

Les
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top