• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[ PL/SQL ] - Simple PL/SQL statement.

Ben

Developer - JS
Developer
Joined
Jul 6, 2013
Messages
1,224
Reaction score
506
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 END. this 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 RaGEZONE';
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 RaGEZONE' 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 RaGEZONE' 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!
 
Back
Top