Friday, June 7, 2013

6th Example - IF Selection on PL/SQL

Leave a Comment
PL/SQL is a reliable programming language. AS well as other programming languages​​, PL/SQL also able to perform the selection operation. There are 2 types of selection operations on PL/SQL, the choice of IF and CASE WHEN selection. Here is an example of using IF selections on PL/SQL block:


DECLARE
        Var1 NUMBER;
        Hasil VARCHAR2(16);
BEGIN
        Var1 := &n1;
        IF Var1 >= 70 THEN
                        Hasil := 'Great';
        ELSIF Var1 >=60 AND Var1 < 70 THEN
                        Hasil := 'Good';
        ELSE
                        Hasil := 'Poor';
        END IF;
        DBMS_OUTPUT.PUT_LINE (Hasil);
END;
/

In the PL/SQL block above, there is a substitution variable that will receive number  input value. If the number entered >= 70 then output is great, if the input value is between 60 and 70 then the output is Good, other than that its output is Poor.
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment