What is the use of cursor ? how cursor allocate context area for executing the sql statement?

Answers were Sorted based on User's Feedback



What is the use of cursor ? how cursor allocate context area for executing the sql statement?..

Answer / sowmya

Hi
cursors allow row -by-row processing of the resultsets
Types of cursors are: static,dynamic,
forward-only,keyset-driven,

disadvantages of cursors are : each time you fetch a row
from the cursor,it results in a network roundtrip,where are
as normal select query makes only one round trip
cursors are costly as they need temparory storage.

Is This Answer Correct ?    5 Yes 0 No

What is the use of cursor ? how cursor allocate context area for executing the sql statement?..

Answer / kamal

Cursor is a named private SQL area from where information
can be accessed. Cursors are required to process rows
individually for queries returning multiple rows.


Within the library cache, parsed SQL is stored as cursors.
The cursors are indexed by handlers referencing memory
locations within which parsed statements and information
relating to processing are stored. A context area is a
shared area of memory that stores the environment and
session variables for an instruction. Buffer caches store
active data and use a cache replacement scheme storing the
most recently used data.

Is This Answer Correct ?    1 Yes 0 No

What is the use of cursor ? how cursor allocate context area for executing the sql statement?..

Answer / anil kumar jaiswal

cursor :

Oracle create a memory area called context area to execute sql statements. that context area keep all information about the statement processed.
cursor is just a pointer to that context area and you can also say a cursor is pointing to result set of a query.
Types cursor :
1.Implicit cursor : implicit cursor automatically created by oracle when ever there is dml operation performed inside pl/sql block.(dml operation means insert,update,delete).
2. Explicit Cursor : its a user defined cursor, user need to define it explicitly.
cursor declared in declaration section called explicit cursor.

Cursor Attributes : there is 4 types of cursor attributes used.
1.%notfound.
2.%found.
3.%isopen
4.%rowcount.
for more queries contact me on aniljaiswal143@gmail.com.

Is This Answer Correct ?    1 Yes 0 No

What is the use of cursor ? how cursor allocate context area for executing the sql statement?..

Answer / ragaventhar

Cursor is used to fetch the data from a main table to temporary variable at run time and it is affected row by row .Mainly used to stored a data temporary and give the result set at the time of run time

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

what are enums used for in mysql? : Sql dba

0 Answers  


How do I audit the sql sent to the server?

0 Answers  


Types of cursors and explanation each of them ?

4 Answers   DELL,


What are the advantages of pl sql?

0 Answers  


What is the difference between unique and primary key constraints?

0 Answers  






What trigger means?

0 Answers  


Hi, I am new in oracle(SQL), could anyone help me in writing a correct SQL. Below is the table structure. Table: Subsc Fields: 1. Sub_no (this field will hold values of subscriber nos, for e.g. S111111, S222222, S333333, S444444, etc.) 2. s_status (this field will hold values for different status of subscriber, for e.g. 'A', 'S', 'C', etc.) 3. cus_id (this field will hold values of bill nos for e.g. 11111111, 22222222, 33333333, 44444444, etc.) Table: Bill Fields: 1. Bill_no this field will hold values of bill nos for e.g. 11111111, 22222222, 33333333, 44444444, etc.) 2. b_status = (this field will hold values for different status of bill for e.g. 'O', 'C', 'S', etc.) Note: 1. The Sub_no is a Primary key of Subsc table. 2. The cus_id is a foreign in Subsc table (referred from Bill_no field of Bill table) 3. The Bill_no field is the Primary key of Bill table. Query A --> I wrote a query to select cus_id/Bill_no which is in status open (b_status = 'O') and having more than two active subscriber (i.e. S_status = 'A') in it ( i.e. more the two subscribers in same bill). select s.cus_id from subsc s where exists (select 1 from bill where bill_no = s.cus_id and b_status = 'O') and s_status = 'A' group by s.cus_id having count(sub_no) = 2 Problem : The above query will give the cus_id (or rather bill_no) which are in open status (b_status ='O) and which are having TWO ACTIVE Subscribers (s_status ='A') in it. However, this query will also lists the cus_id/bill_no which are having more than TWO subscribers in it (but only two subscriber will be in Active status (s_status = 'A') and the others will be in s_status = 'C' or s_status = 'S'. Help needed: I want to write a query which will fetch ONLY the cus_id/bill_no which are in open status (b_status ='O') and which are having ONLY TWO ACTIVE subscribers (s_status ='A') in it. B--> If I include the sub_no in the above query then NO row are returned. select s.cus_id, s.sub_no from subsc s where exists (select 1 from bill where bill_no = s.cus_id and b_status = 'O') and s_status = 'A' group by s.cus_id, s.sub_no having count(sub_no) = 2 Help needed: I want to modify the above query which will fetch ONLY the cus_id/bill_no which are in open status (b_status ='O') and which are having ONLY TWO ACTIVE subscribers (s_status ='A') in it ALONG with the sub_no. Thanks a lot in advance. Regards, Nitin

0 Answers  


Is big data nosql?

0 Answers  


What are the advantages of normalization?

0 Answers  


What are all types of user defined functions?

0 Answers  


What is a design view?

0 Answers  


I need a exceptoin in pl/sql block so that if any errors occur in the block then no exception should errors should raise?

1 Answers  


Categories