Day-39_ORACLE_PLSQL
Day-39_ORACLE_PLSQL
"Oracle Database"
Topic : Introduction To PL/SQL
Date : 16/01/2023
(Session - 39)
___________________________________________________________________________________
__________________________________________
Important Information
*********************
>> Oracle Class Notes ::: https://github.com/ashokitschool/ORACLE_CLASS_NOTES
>> Class Related Updates "Join In WhatsApp Group" check with Admin Team.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
++++++++++++++++++++++++++++++++++++++++++
Last Session
============
* We Just Completed SQL Part.
1) Simple view
2) Readonly view
3) Complex view
4) Maternalized View
Normal Views >>> By using the normal views always select query will
executed on base tables directly.
Maternalized Views >>> By using this kind of views always executing the
selecting query on base table + Holding output of an
select query.
exec dbms_mview.refresh("emp_mat_vw");
Today Session : PL/SQL
======================
* PL/SQL Stands "Procedural Language by Structured Query Language".
* SQL Language can't support for control structures but where as in Pl/SQL allows
the programmer to implement the different control structure.
cursors >>>>>>>>>> Holding the data and retrieving the data same as
ResultSet Object in Jdbc
**************************
Block Structure of Pl/SQL
**************************
...................
...................
2---------------------------------- Begin---------------------------------------
Mandatory Section
....................
....................
3----------------------------------Exception------------------------------------
Optional Section
......................
......................
4--------------------------------- End------------------------------------------
Mandatory Section
5--------------------------------- / -------------------------------------------
1) Declaration Section
======================
* It is optional section (or) optional block.
* We can declare only one variable at atime through out plsql block.
2) Begin
========
a := 10;
3) Exception
============
* It is an Optional section and it contains the code recording the error handling
occured during the Program execution.
4) End
======
* It is a mandatory section and it indicates the termination of plsql program it
must be end with semicolon.
ex: end;
5) /
====
* It is used to run the script file (or) plsql block and it is an Mandatory block
Example
======
begin
// block of statements
dbms_output.put_line('Welcome To AshokIT PL/SQL Programming.........');
end;
NOTE
====
* If the above PLSQL block doesn't having any errors then you will receive a
message from server as "PL/SQL Procedure Successfully Completed"
otherwise you will get errors list on the console.
set serveroutput on
* Re-execute the PL/SQL block by using "/" then we can see the below message
|| >>>>>>>>>>> Concation
Example
=======
declare
uname varchar2(50) := 'Mahesh'
begin
dbms_output.put_line('Welcome To Ashok IT For Oracle Sessions By.....' ||
uname);
end;
/
Example
=======
declare
a number := 10;
b number := 20;
c number;
begin
dbms_output.put_line('Sum of two numbers:::::' || c);
end;
/
OUTPUT
======
Sum of two numners::::: 30
DataTypes
=========
* The Datatypes same as SQL in PLSQL.
Operators
=========
* Same as SQL operators.
Output Statement
================
dbms_output.put_line('message');
Input Statement
===============
* There is no predefined input function given by plsql for this we need to use &
to read values from enduser.
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+++++++++++++++++++++++++++++++++++++++++