Sunday 3 April 2016

First PL/SQL Program

DECLARE
   X   NUMBER(3) :=  10;
   Y   NUMBER(3) :=  20;

BEGIN
    DBMS_OUTPUT.PUT_LINE(‘Welcome to PL/SQL Programming’);
    DBMS_OUTPUT.PUT_LINE(‘The value of variable X is : ‘ ||  X);
    DBMS_OUTPUT.PUT_LINE(‘The value of variable Y is : ‘ ||  Y);
END;

The Result will be :
 The value of variable X is : 10
 The value of variable Y is : 20

For each execution, a PL/SQL block is first compiled by the PLSQL compiler and if there are any compilation errors then the errors are shown. If compilation is successful then the block is immediately executed. A PL/SQL block is not stored in the database so to execute it again it has to be reloaded.



Note:- One can prefix a variable with “&” in the PL/SQL body to create a substitution variable, that prompts the user to enter a value.

No comments:

Post a Comment