Reputation: 1512
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
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
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
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