PL/SQL - Conditions

PLSQL conditions are to execute sequence of statements based on the condition.

There are three conditions
  • IF
  • IF ELSE
  • IF ELSIF ELSE
Statement is executed when condition is True

IF Condition

IF <condition> THEN
statements;
END IF;

Sample:

Declare
v_cust_name VARCHAR2(100);
BEGIN
v_cust_name := "ASK HAREESH";
IF v_cust_name = "ASK HAREESH" THEN
DBMS_OUTPUT.PUT_LINE('Customer matched');
END IF;
END;

IF ELSE Condition

IF <condition> THEN
statements;
ELSE
statements;
END IF;

Sample:

Declare
v_salary NUMBER;
BEGIN
v_salary := 20000;
IF v_salary >=30000 THEN
DBMS_OUTPUT.PUT_LINE('Employee Salary is already good');
ELSE
DBMS_OUTPUT.PUT_LINE('Employee Salary is less when compare to Market standards');
END IF;
END;


IF ELSIF ELSE Condition

IF <condition1> THEN
statements;
ELSIF <condition2> THEN
statements;
ELSIF <condition3> THEN
statements;
ELSE
statements;
END IF;

Sample

Declare
v_emp_rating NUMBER;
Begin
v_emp_rating := :v_emp_rating; -- Takes input
IF v_emp_rating = 5 THEN
DBMS_OUTPUT.PUT_LINE("Employee performance is very good");
ELSIF v_emp_rating = 4 THEN
DBMS_OUTPUT.PUT_LINE("Employee performance is good");
ELSIF v_emp_rating = 3 THEN
DBMS_OUTPUT.PUT_LINE("Employee performance is average");
ELSIF v_emp_rating = 2 THEN
DBMS_OUTPUT.PUT_LINE("Employee performance is not bad");
ELSE
DBMS_OUTPUT.PUT_LINE("Employee performance is worse");
END IF;
END;
*/

1 comment:


  1. Sosyal medya etkileşimlerinizi artırmak ve daha geniş kitlelere ulaşmak için güvenilir bir smm panel kullanmanız faydalı olabilir. Bu panel sayesinde çeşitli sosyal medya platformlarında hızlı ve güvenli şekilde takipçi beğeni ve yorum satın alabilirsiniz. Doğru ve kaliteli hizmet almak için smm panel incelemelerini dikkate almayı unutmayın. Böylece hesabınızın organik büyümesine katkıda bulunabilirsiniz.

    ReplyDelete