You
do not need to explicitly declare variables for all the columns in a table. If you alter the column specification in the
database table, you do not need to update the code.
The
disadvantage of declaring the record
as a ROWTYPE is: When you create a record as a ROWTYPE, fields will be created
for all the columns in the table and memory
will be used to create the data type for all the fields. So use ROWTYPE
only when you are using all the columns of the table in the program.
The use of the data type %ROWTYPE: The data type %ROWTYPE is used for
declaring a variable whose type is that of an entire row from a table. In other words, a variable of this type would
hold a complete record from a table.
Example:
declare
nRecord emp%rowtype;
nFactor constant number (4, 2) :=
1.11;
begin
select * into nRecord from emp
where empno=7934;
if nRecord.sal <2000 then
update emp set
sal=sal*nFactor where empno=7934;
end if;
end;
PL/SQL procedure successfully
completed.
No comments:
Post a Comment