Professional Documents
Culture Documents
PLSQL Assignment3
PLSQL Assignment3
1.W.A.P to transfer all employee names from emp table and store it into index_by__table and
display the data
A. declare
index by binary_integer;
v1 INDEX_TABLE_ENAME;
N number(5):=1;
begin
open c1;
loop
DBMS_OUTPUT.PUT_LINE(v1(N));
N:=N+1;
end loop;
close c1;
end;
2.W.A.P to retrieve all join dates of emp from emp table and store it into index_by__table and
display the data
A.
declare
index by binary_integer;
V1 INDEX_TABLE_HIRE;
N number(5):=1;
begin
open c1;
loop
GE Internal
fetch c1 into v1(n);
DBMS_OUTPUT.PUT_LINE(v1(N));
N:=N+1;
end loop;
close c1;
end;
A. declare
index by binary_integer;
v BULK_COLLECT;
begin
for i in v.first..v.last
loop
DBMS_OUTPUT.PUT_LINE(v(i).ename);
end loop;
end;
A.
declare
type REF_CURSOR is ref cursor;
v1 REF_CURSOR;
i emp%rowtype;
j emp%rowtype;
v_deptno number(10):=:deptno;
begin
if v_deptno=10 then
open V1 for select * from emp where deptno=10;
GE Internal
loop
fetch v1 into i;
exit when v1%notfound;
dbms_output.put_line(i.ename||','||i.deptno);
end loop;
close v1;
elsif v_deptno=20 then
open v11 for select * from dept where deptno=20;
loop
fetch v1 into j;
exit when v1%notfound;
dbms_output.put_line(j.ename||','||j.deptno);
end loop;
close v1;
end;
5.W.A.P to transfer all empnames from emp table and store it into nested table and display data
A. declare
v NESTED_TABLE:=NESTED_TABLE();
n number(10):=1;
begin
for
i in E_NAME
loop
v.extend();
v(n):=i.ename;
n:=n+1;
end loop;
for i in v.first..v.last
loop
dbms_output.put_line(v(i));
end loop;
end;
6.W.A.P to transfer first 10 empname from emp and export into varray and display data
A. declare
GE Internal
type V_ARRAY is varray(50) of emp%rowtype;
v V_ARRAY:=V_ARRAY();
begin
for i in v.first..v.next(9)
loop
DBMS_OUTPUT.PUT_LINE(v(i).ename);
end loop;
end;
7.W.A.P in PL/SQL stored procedure to modify salary of clerk from emp table and this modified value
should be stored into index_by_table and display data
index by binary_integer;
V1 STORED_INDEX_TABLE;
begin
returning empno,ename,job,mgr,hiredate,sal,comm,deptno
for i in v1.first..v1.last
loop
DBMS_OUTPUT.PUT_LINE(v1(i).empno||','||v1(i).ename||','||v1(i).deptno);
end loop;
end;
8.W.A.P W.A.P in PL/SQL stored procedure to modify salary of clerk from emp table and this
modified value should be stored into index_by_table and display data using bulk bind process
declare
type BULK_BIND is table of emp%rowtype
GE Internal
index by binary_integer;
v1 BULK_BIND;
begin
select empno bulk collect into v1 from emp where job='CLERK';
forall i in v1.first..v1.last
update emp set sal=sal+500 where empno=v1(i);
end;
GE Internal