Jump to content

Recommended Posts

Posted

Hello everyone, today we will be looking at PL/SQL the basic syntax into the SQL programming language.

PL-SQL is
a block-structure language.. this means that the actual program that you write is splitted into diffirent parts.

Every PL/SQL block is split into 3 parts:

  • Declarations
  • Executable Commands
  • Exception Handling

The declaration section will start with the keyword DECLARE this section is not required as you don't always need variables in your PL/SQL program.

The Executable section is enclosed between The BEGIN and the ENDthis section is required as this is the core of your SQL program.

A simple example of a PL/SQL program:

 
DECLARE
message varchar2(20) := 'Hello MaxCheaters;
BEGIN
dbms_output.put_line(message);
END;
 

As you see in the exampe, we decalre a variabele called message as a varchar with a length of 20.
the := means that your gonna give the variabele a value, 'Hello MaxCheaters' in our example.
 
Dbms_output.put_line();
 
dbms_output.put_line(); will print a line, as of our example, the dbms_output.put_line() has a variabele passed within the () which holds our text.
 
The dbms will show 'Hello MaxCheaters' in our sql terminal.
 
You can compare the dbms_output.put_line() with a System.out.println() or a Console.writeLine(); in java or C#.
 
Cheers!

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..