Saturday, 19 April 2014

Cursors

Steps
1. create table customer(id int,name char(20), age int, address char(20), salary int)

2. insert into customer values(1,'Raj',23,'Jalandhar',20000)
    insert into customer values(2,'Raju',25,'Simraungadh',20000);
   insert into customer values(3,'Ram',25,'Ludhania',25000);
   insert into customer values(4,'Ramu',26,'Janakpur',30000);
   insert into customer values(5,'Raman',29,'Birgunj',35000);

select*from customer
IDNAMEAGEADDRESSSALARY
1Raj23Jalandhar20000
2Raju25Simraungadh20000
3Ram25Ludhania25000
4Ramu26Janakpur30000
5Raman29Birgunj35000

set serveroutput on
declare
Total_rows number(2);
begin
update customer9999
set salary=salary+500;
if sql%notfound then
dbms_output.put_line('No customer selected');
else if sql%found then
Total_rows:=sql%rowcount;
dbms_output.put_line(Total_rows||'customer selected');
end if;
end if;
end;

Results
5customer selected 
PL/SQL procedure successfully completed.

No comments:

Post a Comment