Categories: PLSQL Tutorials

What is implicit cursor with real examples? | Implicit cursor examples

In my previous articles i have started giving you examples of anonymous block with examples. I also gave information about difference between SQL and tsql in detail. We can check the implicit cursor in PL SQL with real example. There is always question in interview that is difference between implicit cursor and explicit cursor. In this article i would like to give you different Implicit cursor examples in detail.

The article contains :

What is mean by cursor?

Types of Cursor

Implicit cursor examples

What is cursor?

A cursor is nothing but the pointer to private memory area allocated by oracle server. The key use of the cursor is it is used to handle and process the select records in detail.

There are following two types of cursor :

Implicit Cursor :

The implicit cursor is a cursor which has been created and managed by Oracle server internally.

The select statements are always processed internally using the implicit cursor.

When you fire any select statement the internal implicit cursor will be fired in the background.

Explicit Cursor :

The explicit cursor will be defined explicitly by the programmer.

What are different attributes of implicit cursor ?

The cursor attributes are used to test the outcomes of SQL statements.

SQL % FOUND :

The %FOUND attribute is important attribute which is nothing but the boolean value attribute.The boolean return will come or return value as true if at least one statement of SQL will return the value.

SQL % NOT FOUND :

The % NOT FOUND attribute is important attribute which is nothing but the boolean value attribute.The boolean return will come or return value as true if at least NO statement of SQL will return the value.

SQL % ROWCOUNT :

The %ROWCOUNT attribute is one of the SQL attribute which will count the number of rows return by SQL statement. The internal

Implicit Cursor attributes

Real life industry example :

Write a block to retrieve the Salary which will internally execute the SQL statements.

–write a block that retrieve the salary for employee 100 in  variable v_sal

–raise the salary 100 in variable v_new_sal

–update the employee 100 with this new salary

–insert new department called  test with ID=1

DECLARE

v_sal hr.employees.salary%type;

v_new_sal hr.employees.salary%type;

BEGIN

  select salary

  into v_sal

  from hr.employees

  where employee_id=100;

dbms_output.put_line(‘the old salary is ‘||v_sal);

v_new_sal:=v_sal+100;

   update hr.employees

   set salary=v_new_sal

   where employee_id=100;

 dbms_output.put_line(‘the new salary is ‘||v_new_sal);

 insert into hr.DEPARTMENTS (DEPARTMENT_ID,DEPARTMENT_NAME,MANAGER_ID,LOCATION_ID)

 values                 (1,’test’,null,null);

 commit;

END;

I hope you like this article of implicit cursor with real life examples. If you like this article or if you have any issues with the same kindly comment in comments section.

Amit S

Oracle Consultant with vast experience in Oracle BI and PL/SQL Development. Amiet is the admin head of this website who contributes by preparing tutorials and articles related to database technologies. He is responsible to manage the content and front-end of the website.

Share
Published by
Amit S

Recent Posts

What is Root Cause Analysis (RCA) With real examples

In my previous article I have given details about application support engineer day to day…

4 weeks ago

Application Support Engineer Day to day responsibilities

In my previous articles I have given the roles and responsibilities of L1,L2 and L3…

4 weeks ago

What is mean by SLA ( Service Level Agreement) with Examples?

In my previous articles i have given the hierarchy of production support in real company…

1 month ago

What is Production support Hierarchy in organization?

In this article i would like to provide information about production support organization structure or…

1 month ago

What are roles and responsibilities for L3 Support Engineer?

In my previous article I have given roles for L1 and L2 support engineer with…

1 month ago

What are roles and responsibilities of L2 Engineer?

I have started this new series of how to become application support engineer. This article…

1 month ago