Follow us: Connect on YouTube Connect on YouTube Connect on YouTube

Pages

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.
Share this article :

2 comments:

  1. Hallo,

    Hip Hip Hooray! I was always told that slightly slow in the head, a slow learner. Not anymore! It’s like you have my back. I can’t tell you how much I’ve learnt here and how easily! Thank you for blessing me with this
    effortlessly ingestible digestible content
    .

    The third-party has installed SQL Server 2017 for our company but we dont know it is a license or cracked version :( How to check it?

    I am so grateful for your blog. Really looking forward to read more.

    Thanks a heaps,

    ReplyDelete
  2. Szia,


    Grazie! Grazie! Grazie! Your blog is indeed quite interesting around First PL/SQL Program ! I agree with you on lot of points!


    I posted before regarding using oracle UDT stored procedure parameter type to pass a list of records for multiple insert using .net c#.
    I had the below example where a class definition is needed at .net side to map to oracle object. Unfortunately, I did not apply this due to the extra mapping code that is needed.
    http://appsjack.blogspot.com.eg/2010/09/pass-custom-udt-types-to-oracle-stored.html

    My question is: did this change with oracle 12c? Can we now use:

    parameter.UdtTypeName = directOracleUDTName; //without the need for .net definition and mapping classes
    Once again thanks for your tutorial.


    Best Regards,

    ReplyDelete