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!

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...