Variable Declaration in PL/SQL - Steem Dev Community.

in hive-151113 •  10 months ago 

Hello Everyone,


portfolio (3).jpg

Good afternoon to all, how are you. I hope you all friends will be well and good. By the grace of God, i am also good. Today i am here with new post in which we will discuss the Variable Declaration in PL/SQL language. in the previous post, i have share the overview about PLSQL. now we move one step forward.

let's start with syntax.

DECLARE
    A NUMBER := 100;
    B NUMBER := 200;
    C NUMBER;
BEGIN
    C:= A + B;
    DBMS_OUTPUT.PUT_LINE(C);
END;

In the DECLARE part, we declare all types of variables with different data types. Variables are used to store and manipulate data within the program. in the above example, I have declared two variable and assign the values to each variable by using NUMBER datatype.

:= Operators are called assignment operator and it is used for assigning the initial value to a variable. if these operators will not use then default null value will be considered for declared variable.

DBMS_OUTPUT.PUT_LINE is a built-in procedure in PL/SQL used to display messages and output data to the console or output buffer. It is effectively used in PLSQL programs for debugging and monitoring purposes.

We also see the nested declaration in plsql, so variable declaration is divided into two types on the base of nested blocks. one is global and second is local variable type. If variables declare in the inner block, then it will known as local. if variable is declared in outer block, then it will known as global.

DECLARE 
-- Globally Declared
A number := 100; 
BEGIN  
dbms_output.put_line(A);
DECLARE  
-- Local variables 
num1 number := 100;  
BEGIN  
dbms_output.put_line(num1); 
END;  
END; 

It would be my pleasure if you will share your opinion and reviews on this topic.

Please cast witness vote to @bangla.Witness or set proxy to @rme.

_
Vote @bangla.witness as witness
Set Proxy @rme as proxy

Special Thanks.

Cc: @rme
Cc: @hungry-griffin
Cc: @pennsif

Thanks for giving your precious time to my post.
Follow | Upvote | Share | Comments
Follow me on Instagram.
Instagram

🆃🅷🅰️🅽🅺 🆈🅾️🆄

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!