Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 8

WEEK9

PL/SQL
BY: DR. AHMED AMR
Declarations
• DECLARE

Executable Commands
• BEGIN
• END
PL/SQL – Table creation

begin
execute immediate 'create table student(
student_id number(6),
student_name varchar2(20),
student_address varchar2(30),
constraint student_pk primary key (student_id))';
.
.
END;
PL/SQL – Insert
begin

insert into dept values(40 , 'operat' , 'BOSTON' );


insert into dept values(50 , 'mrkt', 'washonton' );
insert into dept values(60 , 'fince', 'new yourk');
insert into dept values(dept_seq.nExtval,'HR' , 'LoS VEg' );
insert into dept values(dept_seq.nExtval,'PROD', 'LoS ANG');
insert into dept values(dept_seq.nExtval,'MAIN', 'CALFORN');

END;
PL/SQL – Delete

begin

delete from dept where deptno = 40;


delete from dept where deptno = 50;
delete from depat where deptno = 60;

END;
PL/SQL – Update

begin

UPDATE Customers SET ContactName = 'Amr', City= 'Maadi' WHERE


CustomerID = 2210;

UPDATE Employees SET ContactName = 'Amr', City= 'Maadi' WHERE


CustomerID = 2020;

END;
PL/SQL – using variables

declare

x number(5) := 10;

begin
delete from emp where deptno = x ;

end;
ANY
QUESTIONS ?
DR. AHMED AMR

You might also like