GeekInterview.com
Series: Subject: Topic:
Question: 486 of 492

What is difference between % ROWTYPE and TYPE RECORD ?

 %  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 and variables.      E.g.  TYPE  r_emp is RECORD (eno emp.empno% type,ename emp ename %type);     e_rec emp% ROWTYPE     cursor c1 is select empno,deptno from emp;     e_rec c1 %ROWTYPE.
Asked by: Interview Candidate | Asked on: Sep 9th, 2004
Showing Answers 1 - 10 of 10 Answers
kishorebabukm

Answered On : Sep 20th, 2005

basically the %rowtype is used in case of fetching the values of the cursor irrespective of how many columns in it and also the data types associated with the tables column.for eg.declarecursor c_example is select * from emp;v_emp emp%rowtype;beginfor v_emp in c_example loop  statements ......end loop;end;the type record is a object oriented concept related to pl/sql tables, tables with datastructure format etc.create type ty_name is record ( a number,                                            b varchar2(10));this type stores data in a record fashion with 2 columns.

Yes  1 User has rated as useful.
  
Login to rate this answer.
sunilbidgar

Answered On : Apr 18th, 2008

View all answers by sunilbidgar

%rowtype is an attribute to inherit datatypes of attributes of a table into a RECORD variable. Type record is a keyword to create record type using either explicitly specifying atrributes or by implecitly inheriting attributes from a table or a existing cursor.

  
Login to rate this answer.
nagarajkv

Answered On : May 5th, 2008

View all answers by nagarajkv

TYPE RECORD is a composite datatype. It consits of multiple pieces of information, called fields. TYPE RECORD fields can be defined by the user. Eg:DECLARE   TYPE extra_book_info_t       IS RECORD (      title books.title%TYPE,      is_bestseller BOOLEAN   );   first_book extra_book_info_t;here, 'title' is the data type defined in books table. We can declare a RECORD based on this type.Where as %ROWTYPE is a direct link to the data type of the table.columns, EG:DECLARE   bestseller books%ROWTYPE;The advantage of TYPE RECORDS is you can pass these to Functions or Procedures which can reduce the parameter size or a repitative work.Hope this give a better explanation.

Yes  1 User has rated as useful.
  
Login to rate this 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, I get all 20 values unnecessarily. At the same time, my program will be bit clumsy if I use seven %TYPE declarations. A better way to solve this solution is by defining my own data type, which can hold seven values.

Yes  3 Users have rated as useful.
  
Login to rate this answer.
iqbal

Answered On : Nov 1st, 2011

There is no need to declare v_emp as we are using for loop....

  
Login to rate this answer.

This %rowtype is used declare record type

  
Login to rate this answer.
rayavarapu

Answered On : Jan 23rd, 2013

View all answers by rayavarapu

%rowtype:- %rowtype means it is will fetch entire row values.

Type record: Type record means we can fetch record from more than one table.

  
Login to rate this answer.
m.ajantha

Answered On : Apr 15th, 2013

Row type is used to hold the total row values

  
Login to rate this answer.
RReid

Answered On : Sep 19th, 2013

%ROWTYPE can be used to declare a record of all columns in a table. They are the same.

  
Login to rate this answer.
Ram Seshadri

Answered On : Sep 20th, 2013

View all answers by Ram Seshadri

%rowtype holds all the rows of a table while you are fetching the rows using a cursor where as the type_rec object can hold the specific columns based on whatever the columns are defined in the type_record variable.

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.