You are on page 1of 2

Name: Sahil Changede

Roll no: 13129


Implicit Cursor

implicit.sql

DECLARE

total_rows number(2);

BEGIN

UPDATE emp

SET salary = salary + 5000;

IF sql%notfound THEN

dbms_output.put_line('no employees updated');

ELSIF sql%found THEN

total_rows := sql%rowcount;

dbms_output.put_line( total_rows || ' employee updated ');

END IF;

END;

OUTPUT

SQL> create table emp(id int,name varchar(20),salary int);

Table created.

SQL> insert into emp values(101,'Siddesh',80000);

1 row created.

SQL> insert into emp values(102,'Sahil',50000);

1 row created.

SQL> insert into emp values(103,'Akhil',60000); 1

row created.

SQL> insert into emp values(104,'Kiran',40000); 1

row created.

SQL> insert into emp values(105,'Priya',65000);

1 row created.

SQL> select * from customers;

ID NAME SALARY
101 Siddesh 80000

102 Sahil 50000

103 Akhil 60000

104 Kiran 40000

105 Priya 65000

SQL> set serveroutput on;

SQL> @implicit.sql;

5 customers updated

PL/SQL procedure successfully completed.

SQL> select * from customers;

ID NAME SALARY

101 Siddesh 85000

102 Sahil 55000

103 Akhil 65000

104 Kiran 45000

105 Priya 70000

You might also like