- It is a datatype of a variable or column
- Can be used when declaring a variable that refers to a column in a database
- Need to use exact datatype of column
- variable datatype changes accordingly at runtime when column definition changes
Example
old_salary emp.salary%TYPE;
new_salary emp.salary%TYPE;
declare
a emp.ename%type;
b emp.sal%type;
c emp.deptno%type;
/*Using %TYPE attribute for variable data type*/
begin
select ename,sal,deptno
into empname,salary,deptnumber
from emp
where ename = 'HAREESH';
dbms_output.put_line(empname ||'-'|| salary ||'-' || deptnumber);
end;
%RowType Attribute
- Can be used when declaring a record variable having same structure as a row in a table or view, or as a row fetched from a cursor
- Exact table name need to used
Example
employee_rec employee%ROWTYPE;
A specific field can be referenced using
employee_rec.emp_num;
declare
employee_rec emp%rowtype;
/*rowtype attribute holds the datatype of the columns of the
entire row*/
begin
select * INTO employee_rec
from emp
where ename = 'HAREESH';
dbms_output.put_line(employee_rec.sal);
dbms_output.put_line(employee_rec.ename);
dbms_output.put_line(employee_rec.deptno);
end;

ReplyDeleteHayatımız boyunca kendimizi geliştirmek ve yeni bilgiler edinmek adına sürekli olarak okumalar yaparız. Bu süreçte, farklı türlerde kitaplar seçerek bilgi dağarcığımızı genişletmek oldukça önemlidir. Özellikle, zaman zaman ilgimizi çeken ve bizi düşündüren eserleri takip etmek faydalı olur. Bu noktada, okunacak kitaplar listeleri, bize yeni ve ilginç öneriler sunabilir. Böylece, okuma alışkanlığımızı sürdürülebilir hale getiririz.