%ROWTYPE ATTRIBUTE:
a) To declare a record based on a collection of columns in a database table or view, we can use the %ROWTYPE attribute.
b) The fields in the Record take their Names and datatypes from the columns of the table or view.
c) The Record can also store an entre row of the data fetched from cursor or cursor variable.
d) Prefix %ROWTYPE with the database table.
Syntax:
VariableName TableName%ROWTYPE;
Example:
V_EmpRecord Emp%ROWTYPE;
ADVANTAGES:
a) The number and datatypes of the underlying database columns may not be known.
b) The number and datatypes of the underlying database column may change at runtime.
c) It is mostly when retrieving a row with the SELECT statement.
Example:
SQL > DECLARE
V_Empno Emp.Empno%ROWTYPE:=&EnterEmpno;
V_EmpRecord Emp%ROWTYPE;
BEGIN
SELECT * INTO V_EmpRecord FROM WHERE Empno=V_Empno;
DBMS_OUTPUT.PUT_LINE('Employee Name:' || EmpRecord.V_EmpRecord.EName);
DBMS_OUTPUT.PUT_LINE('Designation:'|| EmpRecord.Job);
END;
[8:16 PM
|
0
comments
]



0 comments
Post a Comment
Do comment to make this blog better