GeekInterview.com
  I am new, Sign me up!
 
GeekInterview.com  >  Interview Questions  >  Oracle  >  PL/SQL
Go To First  |  Previous Question  |  Next Question 
 PL/SQL  |  Question 206 of 241    Print  
Difference between 'TABLE OF' and 'REF CURSOR'
What exactly the difference between 'TABLE OF' and 'REF CURSOR' in PL/SQL?
For what purposes these both might be used?



  
Total Answers and Comments: 1 Last Update: May 31, 2008     Asked by: dgandhi 
  
 Sponsored Links

 
 Best Rated Answer
Submitted by: krishnaindia2007
 
A ref cursor is a dynamic cursor in which the contents of cursor can be changed dynamically at run time depending upon our requirement.

A ref cursor is basically a data type. A variable declared based on such data type is called cursor variable. We can assosiate differenct statement to a cursor variable dynamically.

The main advantage of ref cursor is
1. We can  return result set to a client which we can't do using normal cursors.
2. It can be passed as parameter to sub programs.

Table of is use to define a collection type.

Collections are generally used for bulk processing. In cursors the data is processed sequentially. Using collections we can  process all the data in one go.



Above answer was rated as good by the following members:
ratna82, Mad Hatter
May 31, 2008 23:32:28   #1  
krishnaindia2007 Member Since: September 2007   Contribution: 854    

RE: Difference between 'TABLE OF' and 'REF CURSOR'
A ref cursor is a dynamic cursor in which the contents of cursor can be changed dynamically at run time depending upon our requirement.

A ref cursor is basically a data type. A variable declared based on such data type is called cursor variable. We can assosiate differenct statement to a cursor variable dynamically.

The main advantage of ref cursor is
1. We can return result set to a client which we can't do using normal cursors.
2. It can be passed as parameter to sub programs.

Table of is use to define a collection type.

Collections are generally used for bulk processing. In cursors the data is processed sequentially. Using collections we can process all the data in one go.


 
Is this answer useful? Yes | NoAnswer is useful 2   Answer is not useful 0Overall Rating: +2    

 Related Questions

 Some  scalar  data  types  such  as NUMBER, VARCHAR2, DATE, CHAR, LONG, BOOLEAN.Some composite data types such as RECORD & TABLE. 
Latest Answer : ScalarCHARVARCHAR2 LONGLONG RAWNUMBER [(precision, scale)]BINARY_INTEGERPLS_INTEGERBOOLEAN Composite TypesRECORDTABLEVARRAYLOB TypesBFILEBLOBCLOBNCLOBReference TypesREF CURSORREF object_type ...

 %  TYPE  provides  the data type of a variable or a database column to that variable. % ROWTYPE  provides the record type that represents a entire row of a table or view 
Latest Answer : %TYPE is used to declare a variable with the same type as that of a database table column.%ROWTYPE is used to declare a record as same type found in database table.These two provides data independence and allows you to adopt database changes due to new ...

 %  ROWTYPE  is to be used whenever query returns a entire row of a table or view. TYPE  rec  RECORD is to be used whenever query returns columns of differenttable or views 
Latest Answer : %ROWTYPE is used when you need to work with complete record.TYPE RECORD is used to create your own data type with specificed number of values to hold.Suppose If a table has 20 columns and you need to work with only seven columns . If I use %ROWTYPE, ...

 Objects  of  type  TABLE are called "PL/SQL  tables", which are modeled as (but  not the same as) database tables,  PL/SQL tables use a primary PL/SQL tables 
Latest Answer : Example for PL/SQL table:==================In the below block "typlsql" and "ty_plsql2" are PL/SQL tablesdeclaretype ty_plsql is record ( empno number, ename varchar2(50));TYPE ty_plsql2 is table of ty_plsql;ty_plsql1 ty_plsql2;j number;cursor ...

 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. 
Latest Answer : Cursor is an small memory allocation or workstation where operation or processing is done on the data.Types of attribute of cursor are-:1)ROWCOUNT2)ISOPEN3)FOUND4)NOTFOUND ...

 There are two types of cursors, Implicit  Cursor and Explicit Cursor.PL/SQL uses Implicit Cursors for queries.User  defined cursors are called Explicit Cursors. They can be declared and 
Latest Answer : Cursors are of two types1. Implicit Cursors: -  Whenever we execute sql statements oracle server assigns a work area called private sql area to store precessed infomation. The most recently used work are can be accessed using SQL%. In implicit cursors ...

 DECLARE  CURSOR  cursor  name,  OPEN  cursor  name,  FETCH cursor name INTO  or Record types, CLOSE cursor name. 
Latest Answer : There are two ways of processing a cursor output. These mainly depend on the type of cursor used. Cursors can be1) Static      : Declared in declarations section with a definate command2) Dynamic : Usually passed a string, which ...

 %ISOPEN  - to check whether cursor is open or not   % ROWCOUNT - number of rows fetched/updated/deleted.   %  FOUND - to check whether cursor has fetched any row. True 
Latest Answer : %ISOPEN - To check whether cursor is open or not.Returns true if cursor or cursor variable is open or not otherwise false.%FOUND - To check wheteher cursor is found or not. Returns true if fetch returns a row otherwise false.%NOTFOUND - To check whether ...

 Cursor  for loop implicitly declares %ROWTYPE as loop index,opens a cursor, fetches rows of values from active set into fields in the record and closeswhen all the records have been processed.      
Latest Answer : Cursor for loop implicitly declares a loop index as %rowtype. It uses result of query  to determine  dynamically no of times the loop is to be repeated. It  performs open, fectch , close operations implicitly. ...

          Cursor C1 is          Select empno,          ename from 
Latest Answer : Commit in this context will not do anything except the commiting the changes into database, done using DML statements. However, if the cursor is created with FOR UPDATE  clause, it will raise runtime exception as commit, in that case, would also ...


 Sponsored Links

 
Related Articles

Querying Data with Oracle XQuery

Querying Data with Oracle XQuery Starting with Oracle Database 10g Release 2 you can take advantage of a full featured native XQuery engine integrated with the database With Oracle XQuery you can accomplish various tasks involved in developing PHP Oracle XML applications operating on any kind of dat
 

Using Oracle XML DB Repository

Using Oracle XML DB Repository Another variation on accessing and manipulating XML content stored in Oracle database is provided by Oracle XML DB repository which is an essential component of Oracle XML DB mosgoogle NOTE Oracle XML DB repository also known as XML repository is a hierarchically organ
 

Using Oracle Database for Storing, Modifying, and Retrieving XML Data

Using Oracle Database for Storing Modifying and Retrieving XML Data With Oracle XML DB you have various XML storage and XML processing options allowing you to achieve the required level of performance and scalability One of the most interesting things about Oracle XML DB is that it allows you to per
 

XML Processing in PHP and Oracle Applications

Processing XML in PHP Oracle Applications As mentioned there are two alternatives when it comes to performing XML processing in your PHP Oracle application You can perform any required XML processing using either PHP s XML extensions or PEAR XML packages or Oracle s XML features mosgoogle In the fol
 

PHP Oracle Web Development

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax is a good starting b
 

ODP.NET - Populating a Dataset with a Single Data Table

ODP NET Populating a Dataset with a Single Data Table A dataset is simply a group of data tables These data tables can be identified with their own unique names within a dataset You can also add relations between data tables available in a dataset mosgoogle The following code gives you the details o
 

Getting Started with Oracle and ODP.NET

ODP NET Developer’ s Guide by Jagadish Chatarji Pulakhandam Sunitha Paruchuri A practical guide for developers working with the Oracle Data Provider for NET and the Oracle Developer Tools for Visual Studio 2005 Application development with ODP NET Dealing with XML DB using ODP NET Oracle
 

PHP Oracle Web Development Review

PHP Oracle Web Development Data processing Security Caching XML Web Services and Ajax The book is written by Yuli Vaseliev a well known author of different web development and programming books The author is also an expert in open source technologies and SOA Service Oriented Architecture But besides
 

jQuery Table Row Finished Code

jQuery Table Row Finished Code The Finished Code Our second example page has demonstrated table row striping highlighting tooltips collapsing expanding and filtering Taken together the JavaScript code for this page is mosgoogle geshibot lang php" document ready function var highlighted
 

jQuery Expanding and Collapsing Table Rows

jQuery Expanding and Collapsing Table Rows The expanding and collapsing behavior added earlier also conflicts with our filters If a section is collapsed and a new filter is chosen then the matching items are displayed even if in the collapsed section Conversely if the table is filtered and a section
 

About Us -  Privacy Policy -  Terms and Conditions -  Contact -  Ask Question -  Propose Category -  Site Updates 

Copyright © 2005 - 2009 GeekInterview.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape