Tuesday, April 16, 2019

Introduction to PLSQL

PLSQL is the combination of SQL statements. To increase the capabilities of SQL PLSQL is introduced. Full form of PLSQL is 'Procedural Structured query language'. 

* PL/SQL programs are divided and written in logical blocks of code. Each block consists of three sub-parts
- Declarations
- Executable Commands
- Exception Handling

* Following is the basic structure of a PL/SQL block
DECLARE 
<declarations section> 
BEGIN 
<executable command(s)>
EXCEPTION 
<exception handling> 
END;

* The PL/SQL single-line comments start with the delimiter -- (double hyphen) and multi-line comments are enclosed by /* and */.

 Example : 
    DECLARE 
   -- variable declaration 
   message  varchar2(20):= 'Hello, World!'; 
   BEGIN 
   /* 
   *  PL/SQL executable statement(s) 
   */ 
   dbms_output.put_line(message); 
   END; 
   /  

* A PL/SQL unit is any one of the following −
 PL/SQL block
 Function
 Package
 Package body
 Procedure
 Trigger
 Type
 Type body

No comments:

Post a Comment

SUBQUERIES PRACTISE QUESTIONS

1. Write a SQL query to find those employees who receive a higher salary than the employee with ID 7369. SELECT * FROM EMP WHERE SAL >  (...