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!

Use in(<values>) for an if statement

james_hambrickApr 14 2015 — edited Apr 14 2015

Oracle 11G, working on a trigger. Is there a way to use something like in(24,26,27,29,37,43) as we can in SQL code to compare a new value against a list of values?

for example if the new value is in(1,3,5,6,7,9,11,13,14,15,17,18,20,22,25,27,29,30,31,33,34,35,36) then I want to set another column to "CLEC"

If the new value is in(2,4,8,9,12,16,19,21,23,26,28,32) then I want to set another column to "ILEC"

And if the new value is null or 1 then I want to set another column to "Company"

I know I could do

if :new.Column1 := 1 or :new.Column1 := 3 etc etc which would make for a very long if statement.

I could make separate arrays with these values and check against them.

But like I said, I am hoping for something more simplistic as stated above.

Comments

Solomon Yakobson

Yes, you can use:

if :new.Column1 IN (1,3,5,6,7,9,11,13,14,15,17,18,20,22,25,27,29,30,31,33,34,35,36) THEN ... END IF;

SY.

1 - 1
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on May 12 2015
Added on Apr 14 2015
1 comment
75 views