Multiple choice

In PL/SQL, which of the following is the correct syntax of the 'if-else' statement?

  1. If condition then statements elseif condition then statements else statements end if;

  2. if condition statements elseif condition statements else statements end if;

  3. if condition then statements elif condition then statements else statements end if;

  4. if condition statements elsif condition statements else statements endif;

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

'If-else' is a condition statement that is used to write conditional statement in a PL/SQL program. For example, the following code will print a message depending on whether the value of A is greater, B is greater or both of them have the same values - if a>b then      dbms_output.put_line('A is greater'); elsif b>a then      dbms_output.put_line('B is greater'); else      dbms_output.put_line('Both are equal'); end if;