What is the diff between %Rowtype and %type?

Showing Answers 1 - 4 of 4 Answers

Rajeshwaran

  • Oct 12th, 2006
 

%Rowtype means associating a single variable to a entire row.(It is one way of Declaring a composite plsql datatype "RECORD")

%type means associating a single variable to a particular column in table.

both %Rowtype and %type declarations are known as Anchored Declarations in plsql .

sunnyjsr

  • Oct 21st, 2006
 

%RowType provides the records type the represent a entire row of a table or view or column select in the cursor

%Type provides the data type of a variable or a database column to that variable.

Sunny Singh

9860229246

  Was this answer useful?  Yes

%RowType provides the full records values in one variable, and if in a table any column is added then also your proc/function will not fail, that variable will hold the reference for new column also.

example:

v_rec emp%rowtype ;

%Type provides the data type of a column of a table

v_empno emp.empno%type;

use of %type, %rowtype makes your proc/function more effective and efficient.

  Was this answer useful?  Yes

Radha

  • Jul 14th, 2011
 

We use %type and %rowtype in PL/SQL programming part.
%Type: The variable will assign the datatype which contains in the column of that particular table we mentioned.
Ex: v_eno employee.eno%type;
Here V_eno is a variable which is assigned the data type of eno column of employee table.
%Rowtype: It anchors the variable to all columns of that table.
Ex: Declare
v_emp employee%rowtype;
Begin
select e.* into v_emp from employee;
v_emp.sal := v_emp.sal + 100;
end;
Here we are accessing the name of the column directly with name of the variable(v_emp.sal)

  Was this answer useful?  Yes

%type is used when we have to define the datatype of a variable similar to another existing column data-type.
eg- v_id employess.employee_id%type.
In this example we have make a variable v_id similar to the datatype of employee_id column.

%rowtype is used when we have to make a single variable which can have similar datatype values of a record i.e
it can handle different datatype at a time.

eg- v_id employee%rowtype.

  Was this answer useful?  Yes

Give your answer:

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

 

Related Answered Questions

 

Related Open Questions