

Cursors play a crucial role when it comes to performing different task by giving a name to the memory area (context area) where the result of SQL queries are saved. Pointing to the memory location and performing actions accordingly is one of the important tasks in any programming language.

It fetches the records and assigns them to a variable defined.Ĥ. The SELECT statement is executed and the fetched rows are stored in the context area. Fetch the cursor: In this process, one row is accessed at a time. Open the cursor: Opening a cursor, allocates the memory to it and make it available to fetch the records returned by the SQL statement.ģ. Declare the cursor: It is used to give a name to the context area/cursor along with the select statement that needs to be executed.Ģ. Steps to use Explicit Cursor are mentioned below:ġ. There is a specific procedure that needs to be followed for using an Explicit Cursor. It is created for the SQL statements that return more than one row after processing them. These cursors need to be first defined in the declaration block of the PL/SQL program. Explicit Cursors are those cursors that are defined by programmers to have more control over the Context Area (where the results of SQL queries are stored). IF sql%NOTFOUND THEN dbms_output.put_line (‘No records of English subject are updated’) ĮLSIF sql%FOUND THEN affected rows: = affected rows%rowcountĭbms_output.put_line(‘Congrats.
CURSORS TYPES UPDATE
UPDATE students SET marks = marks+10 where subject = ‘English’ Scenario: To update the marks of all students in a table ‘student’ in English Subject having column ‘subject’ by 10.
CURSORS TYPES CODE
the count of the number of rows that are affected by the mentioned DML statements by the programmer in the PL/SQL code like INSERT, DELETE and UPDATE or the number of rows that are returned by SELECT INTO statement. In the case of Implicit cursors, it always returns False because Oracle closes the cursor just after the execution of SQL statements. It is the opposite of %FOUND attribute, It returns True if none of the rows are affected by DML statement or SELECT statement returns no results.


Returns True if DML statements like INSERT,ĭELETE, UPDATE affect one or more rows or SELECT statement returns one or more rows. Though Oracle provides some attributes to perform some operations on it like These cursors cannot be named by the programmer and hence cannot be referred and used at some other place in code. When the programmer does not create any cursor, Oracle by itself creates it to hold the rows affected by the DML statements. Implicit CursorsĪs the name indicates, Implicit cursors are those cursors that are automatically created by Oracle when any DML statements like INSERT, DELETE, UPDATE are executed. Hadoop, Data Science, Statistics & others 1.
