Академический Документы
Профессиональный Документы
Культура Документы
PL/SQL blocks are defined by the keywords DECLARE, BEGIN, EXCEPTION and END,
which divide the block into a declarative part, an executable part and an exception-building part,
respectively. The declaration section of the block is used to define and initialize constants and
variables; if a variable is not initialized, it will default to NULL value. Blocks can be nested and
submitted to interactive tools, like SQL*Plus.
1. The basic difference between two languages is that SQL executes the single query at a time
whereas, Pl/SQL executes the block of code at once.
2. SQL is a Structured Query Language whereas, PL/SQL is a Procedural Language/ Structured
Query Language.
3. SQL act as a source to retrieve data that will be displayed by the application created using
PL/SQL.
4. SQL queries and commands are written using DDL (Data Definition Language), DML (Data
Manipulation Language). However, using PL/SQL you can write programming block which
has procedures, functions, triggers, packages, variables within its syntax.
5. SQL queries are used to retrieve data from the database; you can also add or delete or modify
the data in the database. On the other hands, PL/SQL is used to create applications that can
display the information retrieved by the SQL.
6. You can embed SQL queries within the syntax of PL/SQL. However, the opposite is not
possible.
Block Structure
1) Anonymous block : It is a block without a name. The anonymous block is the simplest unit in
PL/SQL. It is called anonymous block because it is not saved in the Oracle database. An
anonymous block is an only one-time use and useful in certain situations such as creating test
units.
2) Named block : That’s PL/SQL blocks which having header or labels are known as Named
blocks. These blocks can either be subprograms like functions, procedures, packages or Triggers.
Example:
BEGIN
END;
Output :
Hello World..
PL/SQL Literals