0% found this document useful (0 votes)
5 views3 pages

11th Dec

Uploaded by

RaJu Bhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views3 pages

11th Dec

Uploaded by

RaJu Bhai
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Declare

Tsum Number(7,2):=0;
Begin
For i in 1..10
Loop
Tsum:=Tsum+&n;
end Loop;
dopl(Tsum);
End;
/

PL/SQL Record:
--------------------
Declare
Type Emp_Rec is Record(
Empno Number(4),
Ename Varchar2(10),
Basic Number(7,2),
Hra Number(6,2),
Da Number(6,2),
Ta Number(6,2),
Gross Number(8,2),
Pf Number(6,2),
Netsal Number(8,2) );
e Emp_Rec;
Begin
E.Empno:=&Empno;
Select Ename, Sal into E.Ename, E.Basic from Emp where Empno=E.Empno;
E.Hra:=E.Basic*50/100; E.Da:=E.Basic*40/100; E.Ta:=E.Basic*20/100;
E.Gross:=E.Basic+E.Hra+E.Da+E.Ta;
E.Pf:=E.Basic*12/100;
E.NetSal:=E.Gross-E.Pf;
Dopl(Rpad('Empno',10)||Rpad('Ename',10)||' '||'Basic'||' '||'Hra'||' '||'Da'||'
'||'Ta'||' '||'Gross'||
' '||'Pf'||' '||'Netsal');
Dopl(Rpad(E.empno,10)||Rpad(E.ename,10)||' '||E.Basic||' '||e.Hra||' '||E.Da||'
'||E.Ta||' '||E.Gross||
' '||E.Pf||' '|| E.Netsal);
End;

PL/SQL Tables:
--------------------

Declare
Type Name is table of Emp.Ename%type Index by Binary_Integer;
Type Pay is table of Emp.Sal%type Index by Binary_Integer;
N Name;
P Pay;
Tot_Sal Number(8,2):=0;
Cnt Number(2):=0;
Begin
-- Inserting Data into Pl/Sql tables
For i in (select Ename, Sal from Emp)
Loop
N(Cnt):=i.Ename;
P(Cnt):=i.Sal;
Cnt:=Cnt+1;
End Loop;
-- Displaying Pl/Sql Table Info.
Dopl(Rpad('Ename',10)||Rpad('Basic',10));
Dopl(Rpad('-----',10)||Rpad('-----',10));
For k in N.First..N.Last
Loop
Dopl(Rpad(N(k),10)||Rpad(P(k),10));
Tot_Sal:=Tot_Sal+Nvl(P(k),0);
End Loop;
DOPL('All Employees Total Salary = '||Tot_Sal);
End;

Triggers:
-----------

Trigger Name: Emp_Trig

Table Name: Emp

Trigger Event: Before Insert

Create or replace Trigger Emp_Trig


Before Insert on Emp
for each row
Begin
if :new.sal<3000 then
Raise_Application_Error(-20001,'Sal Should be Graterthan or Equal to
Rs.3000/-.');
End if;
End;

You might also like