Types of cursors?

Answers were Sorted based on User's Feedback



Types of cursors?..

Answer / saleem

1) Implicit: declared for all DML and pl/sql statements.
By default it selects one row only.
2) Explicit: Declared and named by the programmer.
Use explicit cursor to
individually process each row returned by a
Multiple
statements, is called ACTIVE SET.
Allows the programmer to
manually control explicit cursor in the
Pl/sql block
a) declare: create a named sql area
b) Open: identify the active set.
c) Fetch: load the current row in to variables.
d) Close: release the active set.

CURSOR ATTRIBUTES
a) %is open: evaluates to true if the cursor is open.
b) %not found: evaluates to true if the most recent fetch
does not return a row
c) %found: evaluates to true if the most recent fetch
returns a row.
d) %row count: evaluates to the total number of rows
returned to far.

Example for cursor:
1) Declare
Vno emp.empno%type;
Vname emp.ename %type;
Cursor emp_cursor is
Select empno,ename
From emp;
Begin
Open cursor;
For I in 1..10 loop
Fetch emp_cursor into vno,vname;
Dbms_output.putline(to_char(vno) ||? ?||vname);
End if;
E nd;

2) Begin
Open emp_cursor;
Loop
Fetch when emp_cursor % rowcount >10 or

Emp_curor % not found;
Bdms_output_put_line(to_char(vno)||? ?||
vname);
End loop;
Close emp_cursor;
End;

CURSOR FOR LOOP
A) cursor for loop is a short cut to process explicit cursors
B) it has higher performance
C) cursor for loop requires only the declaration of the
cursor, remaining things like opening, fetching and close
are automatically take by the cursor for loop

Example:
1) Declare
Cursor emp_cursor is
Select empno,ename
From emp;
Begin
For emp_record in emp_cursor loop
Dbms_output.putline(emp_record.empno);
Dbms_output.putline(emp_record.ename)
End loop
End;

Is This Answer Correct ?    33 Yes 11 No

Types of cursors?..

Answer / fahad iqbal

A cursor is a handle (pointer) in memory for a DML operation
(Select , Update).

There are mainly 2 types of cursors .
1) Implicit Cursor.
2) Explicit Cursor.

Implicit cursor: Oracle will implicitly creates an area for
the DML operations. Programmer will not have control on
implicit cursors. The only useful attribute on this implicit
cursor is SQL%ROWCOUNT , it will give the number of rows
affected by the recent DML operation.

The only Implicit cursor is SQL.

Explicit Cursor:
Explicit cursors are created by the programmer and
programmer have control on it
Programmer can

1) Open


2) Close

3) Fetch

and do some manipulations on the values

Explicit Cursors are classified into

1) Normal cursor

2) Parameterized cursor

3) Cursor For Loops and

4) REF cursors

REF Cursors:

Normally when we create a normal cursor , we cant change the
select query associated to that query (the query which is
given at the time of definition)

But using REF cursors , we can change the cursor statement also.

These REF cursors are useful when we are sending data from
one environment to another environment.

Thanks And Regards
FAHAD IQBAL

Is This Answer Correct ?    12 Yes 1 No

Types of cursors?..

Answer / manoj

Declare
var emp.empno%type;
emp emp.ename %type;
Cursor emp_cursor is
Select empno,ename
From emp;
Begin
Open cursor;
For I in 1..11 loop
Fetch emp_cursor into vno,vname;
Dbms_output.putline(to_char(vno) ||? ?
||vname);
End if;
E nd;

Is This Answer Correct ?    12 Yes 20 No

Post New Answer

More Oracle Apps Technical Interview Questions

What is secuirity's in R12 features.

1 Answers   KPIT,


Types of cursors?

3 Answers  


What is MO operating units. Why it need to to set this and where .

2 Answers   IBM,


What are different execution methods of executabls?

1 Answers   Genpact, TCS,


how can u find the status in po?

1 Answers  






In SQL Loader i have 100 Records to be loaded into my table. How do i load the first 30 Records and skip the last 10 Records within a single .ctl file ? So my total no.of records to be loaded would be 60. Could anybody help me in this ?

2 Answers  


HOW CAN YOU KNOW UPDATE STMT IS WORKED OR NOT IN PL/SQL?

2 Answers   TCS,


how to get the on hand quantity of an item across all organizations? name the underlying tables.

2 Answers   Ranves IT Solutions, Scan Steel,


API?s FOR CUSTOMER INTERFACE? Tell me some API's?

1 Answers  


what is the difference between procedure and function

3 Answers   Wipro,


Assume i have three Procedures defined in a Package Spec. I have created the Package Specification. now i create the Package Body by including the three procedures in addition to that i include a fourth procedure which is not included in my Package Spec. I compile the Package Body. Will the Package body Compile ? What will the end result ? what will happen if the execute the package by calling the 4th procedure ?

7 Answers   Satyam,


What and Who is the best Institute or Trainer for Oracle Apps Technical ?

2 Answers  


Categories
  • Oracle Apps Technical Interview Questions Oracle Apps Technical (547)
  • Oracle Apps Financial Interview Questions Oracle Apps Financial (793)
  • Oracle Apps Manufacturing Interview Questions Oracle Apps Manufacturing (53)
  • Oracle Apps HRMS Interview Questions Oracle Apps HRMS (169)
  • Oracle Apps CRM Interview Questions Oracle Apps CRM (9)
  • Oracle Apps SCM Interview Questions Oracle Apps SCM (141)
  • Oracle Install Base Interview Questions Oracle Install Base (62)
  • Oracle Service Contracts Interview Questions Oracle Service Contracts (101)
  • Oracle Apps AllOther Interview Questions Oracle Apps AllOther (114)