PROCEDURE:
Create table employee3(eno number(5) primary key.ename varchar(20),esalary number(20));
Table created.
insert into employee3 values(&eno, &cname”,&esalary);
Enter value for eno: 1
Enter value for ename: sri Enter value for esalary: 20000
old 1: insert into employee3 values(&eno, &cname’, &esalary)
new 1: insert into employee3 values(1, ‘sri, 20000)
I row created.
Enter value for eno: 2
Enter value for ename: zoya
Enter value for esalary: 30000
old 1: insert into employee3 values(&eno, ‘&ename’,&esalary)
new 1: insert into employee3 values(2,’zoya’,30000)
Irow created.
Create or replace procedure proc(a in number)is
2 name varchar(20);
3 no number 4 sal number
5 begin
6 update employee3 set esalay esalary+1000 where eno-a;
7 select ename, eno, esalary into name, no,sal from employee where eno=a;
8 dbms_output.put_line(“name:’||name|[‘eid: “[[no||’esalary:’||sal);
9 exception
10 when no data found then
11 dbms_output.put_line(‘no such id exist);
12 end:
13/
Procedure created.
Set serveroutput on;
declare
2 eno number
3 begin
4 proc(eno);
5 end;
6/
FUNCTION:
set serveroutput on
declare
2 al number;
3 b1 varchar(15)
4 cl number;
5 d1 number:
6 el number;
7 function it(X is number, Y is number)
$ return number
9 is Z number;
10 begin
11 if(X >= 50000) then12Z :=5000:
13 elsif(X>=20000) and (X < 50000) then
14Z :=25000
15 else Z:=0;
16 end if:
17 return Z;
18 end:
19 begin
20 el :=101
21 select eno, ename, salary into al . b 1,c1 from employee where
22 eno: el;
23 d1 := it (c1,el)
24 dbms_output.put_line(/EMPLOYEE NO:’||a1);
25 dbms_output.put_line(‘EMPLOYEE NAME:’||61):
26 dbms_output.put_line(‘SALARY:’||e1);
27 dbms_output.put_line(‘RANGE:’||d1);
28 END;
29/
Leave a Reply