plsql_Implicit_cursor1.htm
 
Cursor:

One of the best reference :

http://www.postgresql.org/docs/9.2/static/plpgsql-cursors.html#PLPGSQL-CURSOR-FOR-LOOP

The concept of Cursors in dbms remained hot discussion area, I agreed with few of the following views and references.
  • http://www.dbanotes.com/database-development/introduction-to-oracle-11g-cursors/
    "A cursor is a pointer, which points towards a pre allocated memory location in the SGA. For transparent understanding, it is a handle or gateway adopted by Oracle to execute a SQL query. The memory location to which it points is known as Context area. Oracle associates every SELECT statement with a cursor to hold the query information in this context area."
 
Cursor is a work area or a memory space to store processing information at the server end.  A SQL statement induce an implicit cursor, similar to the address of (&) operation with a pointer in C++,  in  at the server end
Code Used : Code_JavaApp1.txt
Consider This screen shot to emphasize the role of an implicit cursor . I used NetBean 7.X Tool from Oracle corporation, and PostgreSQL database.

Not the highlighted code  script-snippet, the resultset processed an array like a block with wile control structure, where indices (range 1- through 4, as row-counts) were strictly enforced. If we change the sequence, we would notice an run time error. Unlike an array, the first row count starts with 1.


System.out.println("main block executing ");
Connection con = null;
Statement st = null;
ResultSet rs = null;
//
rs = st.executeQuery("SELECT * FROM
emp WHERE job != 'MANAGER'");

//
while (rs.next())
{
System.out.print(rs.getInt(1));
System.out.print(" : "+rs.getString(2) +"\t");
System.out.print(" : "+rs.getString(3)+"\t");
System.out.print(" : "+rs.getInt(4)+"\t");
System.out.println();
}

 

The output screen shot


The server implicit processes a SQL / DML query into a collection block Oracle defines it as a context area). In the above report we used 4 column, with while statement. As a rule of thumb, the cursor can't go-back, or jump to an upstream row. 

Pros and Cons: The table shown below has 8 column



 

Edit the current SQL statement :


In the above conditin the columns can be shuffled as desired.