1st Example - Basic PL/SQL
Here's our first example. PL/SQL block that is
made is non-modular. This block
has 3 variables
a, b and c. a variable has a data type INT, b
has a data type INT and c has the NUMBER data type. The output of the program is
the calculation of the value of (a + b-a) / b * a which are stored in
the variable c
DECLARE
a INT;
b INT;
c NUMBER;
BEGIN
a: = 10;
b: = 40;
c: = (a + b - a) / b * a;
Dbms_output.put_line ('Result =' | | c | | 'dollar');
END;
/
PL/SQL block is executed if (copy-paste into SQL*Plus) will not display the expected output will only display the message "PL/SQL procedure successfully completed.". To be able to produce the expected output value needs to be typed SERVEROUTPUT ON SET command in SQL * Plus before executing the PL/SQL block that. The value of “Result = 10 dollar” would be appeared to indicate block PL/SQL successfully process the command lines well.
a INT;
b INT;
c NUMBER;
BEGIN
a: = 10;
b: = 40;
c: = (a + b - a) / b * a;
Dbms_output.put_line ('Result =' | | c | | 'dollar');
END;
/
PL/SQL block is executed if (copy-paste into SQL*Plus) will not display the expected output will only display the message "PL/SQL procedure successfully completed.". To be able to produce the expected output value needs to be typed SERVEROUTPUT ON SET command in SQL * Plus before executing the PL/SQL block that. The value of “Result = 10 dollar” would be appeared to indicate block PL/SQL successfully process the command lines well.
Leave a Comment