Alejandro Bastidas
Alejandro Bastidas

Reputation: 1512

'OR' CLAUSE INSIDE IF CONDITIONAL

I'm trying to create a function in oracle. It seems it is not possible to do something like this:

IF (VAR1 IS NULL OR LENGTH(TRIM(VAR2))) = 0 THEN
    -- do something;
END IF;

How can I use 'OR' clause inside if. I want to ask for two possible conditions in the same line using if.

Upvotes: 0

Views: 268

Answers (3)

user2001117
user2001117

Reputation: 3777

Yes we can check multiple condition In a single line with the IF statement.But parenthesis should be place correctly.

See the syntax:

IF (VAR1 IS NULL OR LENGTH(TRIM(VAR2)) = 0) THEN
  do something
End if;

Upvotes: 0

Justin Cave
Justin Cave

Reputation: 231661

You just need to get your parenthesis lined up. Your last right paren is in the wrong place.

IF (VAR1 IS NULL OR LENGTH(TRIM(VAR2)) = 0) THEN
    -- do something;
END IF;

Upvotes: 1

Anton Kovalenko
Anton Kovalenko

Reputation: 21507

It is possible if you place your parenthesis correctly:

IF (VAR1 IS NULL OR LENGTH(TRIM(VAR2)) =0) THEN
-- do something;
END IF;

Upvotes: 2

Related Questions