Category: PL/SQL Cursors

PL/SQL Cursor to Find Total Salary in Department 0

PL/SQL Cursor to Find Total Salary in Department

Follow me PL/SQL Cursor to Find Total Salary in Department: declare dno number; vdno number; totsalary number; cnt number; cursor tot_sal(vdno number) is select * from emp where deptno=vdno; begin cnt:=0; totsalary:=0; vdno:=:vdno; dbms_output.put_line(‘Department...

PL/SQL Cursor to Display Names in Uppercase 0

PL/SQL Cursor to Display Names in Uppercase

Follow me PL/SQL Cursor to Display Names in Uppercase: declare cursor upr is select upper(ename)ename from emp order by empno; begin for i in upr loop dbms_output.put_line(i.ename); end loop; end; OUTPUT: SMITH ALLEN WARD...

PL/SQL Cursor to Display Names in Lowercase 0

PL/SQL Cursor to Display Names in Lowercase

Follow me PL/SQL Cursor to Display Names in Lowercase: declare cursor lowwer is select lower(ename)ename from emp order by empno; begin for i in lowwer loop dbms_output.put_line(i.ename); end loop; end; OUTPUT: smith allen ward...

PL/SQL Cursor to Display Last Five Records 0

PL/SQL Cursor to Display Last Five Records

Follow me PL/SQL Cursor to Display Last Five Records: declare tot number; cnt number; rcnt number; cursor last_five_record is select * from emp; begin cnt:=1; select count(*) into tot from emp; rcnt:=tot-5; for i...

PL/SQL Cursor to Display Record from One Number to Another 0

PL/SQL Cursor to Display Record from One Number to Another

Follow me PL/SQL Cursor to Display Record from One Number to Another: declare cursor rec_print is select * from emp; frno number; upto number; cnt number; begin cnt:=1; frno:=:frno; upto:=:upto; for i in rec_print...

PL/SQL Cursor to Display Record having Third Highest Salary 0

PL/SQL Cursor to Display Record having Third Highest Salary

Follow me PL/SQL Cursor to Display Record having Third Highest Salary: declare cursor third_hsal is select * from student order by salary desc; cnt number; begin cnt:=1; for i in third_hsal loop if(cnt =...

PL/SQL Cursor to Display Last Five Records having Highest Salary 0

PL/SQL Cursor to Display Last Five Records having Highest Salary

Follow me PL/SQL Cursor to Display Last Five Records having Highest Salary: declare cursor hsal is select * from student order by salary desc; cnt number; begin cnt:=1; for i in hsal loop if(cnt<=3)...

PL/SQL Cursor Example with Parameter 0

PL/SQL Cursor Example with Parameter

Follow me PL/SQL Cursor Example with Parameter: declare vno number; cursor sname(vno number) is select * from student where id=vno; begin vno:=:vno; for i in sname(vno) loop dbms_output.put_line(i.name); end loop; end;

PL/SQL Cursor to Update Table Records 0

PL/SQL Cursor to Update Table Records

Follow me PL/SQL Cursor to Update Table Records: declare cursor cupd is select * from student for update; begin for i in cupd loop update student set city=initcap(city), salary=salary+100 where current of cupd; end...

PL/SQL Cursor to Display Records in Even Numbers 0

PL/SQL Cursor to Display Records in Even Numbers

Follow me PL/SQL Cursor to Display Records in Even Numbers: declare cursor s_even is select * from student; cnt number; rcnt number; begin cnt:=2; rcnt:=1; for i in s_even loop if(cnt = rcnt) then...