Preamble
In Oracle PL/SQL, the %ROWTYPE attribute provides a record type representing a string in the Oracle database table (or view).
A record may store an entire string of data selected from the table, or be extracted from a cursor or a strictly typed cursor variable.
Syntax for declaring a variable with the %ROWTYPE attribute in Oracle PL/SQL
v_rec table_name%ROWTYPE
Parameters and arguments of the attribute
- v_rec – name of a variable which is assigned a record value
- table_name – name of the database table
Note:
- Columns in a row and corresponding fields in a record have the same names and data types.
- Fields in the %ROWTYPE record do not inherit the NOT NULL column limit.
Consider the Oracle example to understand how to apply %ROWTYPE in Oracle PL/SQL.
For example:
DECLARE
-- %ROWTYPE can include all columns in a table ...
emp_rec employees%ROWTYPE;
-- ... or a subset of columns based on the cursor.
CURSOR c1 IS
SELECT department_id, department_name FROM departments;
dept_rec c1%ROWTYPE;
-- You can even create %ROWTYPE with columns from several tables.
CURSOR c2 IS
SELECT employee_id, email, employees.manager_id, location_id
FROM employees, departments
WHERE employees.department_id = departments.department_id;
join_rec c2%ROWTYPE;
BEGIN
-- We know that EMP_REC can contain a row from an EMPLOYEES table.
SELECT * INTO emp_rec FROM employees WHERE ROWNUM < 2;
-- We can refer to EMP_REC fields using column names.
-- from the EMPLOYEES table.
IF emp_rec.department_id = 20 AND emp_rec.last_name = 'JOHNSON' THEN
emp_rec.salary := emp_rec.salary * 1.15;
END IF;
END;
In this Oracle PL/SQL example, we declared the emp_rec variable based on the employees table entry. We also declared the join_rec variable based on the record of the c2 cursor created from the fields of the employees and departments tables.
An example with cumulative assignment
Consider an example that shows how to assign values to all fields in one record simultaneously. You can assign one record to another if their ads belong to the same table or cursor. For example, the following assignment is allowed:
DECLARE
dept_rec1%ROWTYPE;
dept_rec2 departments%ROWTYPE;
CURSOR c1 IS SELECT department_id, location_id FROM departments;
dept_rec3 c1%ROWTYPE;
BEGIN
dept_rec1 := dept_rec2; -- acceptable
-- dept_rec2 refers to the table, dept_rec3 refers to the cursor
-- dept_rec2 := dept_rec3; -- not allowed
END;
In this Oracle PL/SQL example, we declared the variables dept_rec1, dept_rec2 based on a table entry. We also declared the c1 cursor containing the department_id, location_id fields of the departments table.
Since the departments table is represented in the database by the fields department_id, department_name, manager_id, location_id, the assignment of dept_rec2 := dept_rec3 is unacceptable.
The following example shows how to assign a list of column values to a record using the SELECT instruction.
DECLARE
dept_rec departments%ROWTYPE;
BEGIN
SELECT * INTO dept_rec FROM departments
WHERE department_id = 30 and ROWNUM < 2;
END;
This example assigns a record value from the department’s table with department id equal to 30 to the dept rec variable.
Oracle pl sql tutorial; %TYPE and %ROWTYPE attributes
About Enteros
Enteros offers a patented database performance management SaaS platform. It proactively identifies root causes of complex business-impacting database scalability and performance issues across a growing number of clouds, RDBMS, NoSQL, and machine learning database platforms.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
Building Resilient BFSI Applications with Predictive AIOps and FinOps Intelligence
- 23 August 2026
- Database Performance Management
Introduction The Banking, Financial Services, and Insurance (BFSI) industry is undergoing a rapid digital transformation. Mobile banking, digital payments, online lending, insurance platforms, wealth management applications, and real-time financial services now depend on highly available and scalable IT infrastructure. Customers expect BFSI applications to be fast, secure, and available around the clock. Even a short … Continue reading “Building Resilient BFSI Applications with Predictive AIOps and FinOps Intelligence”
How AIOps and FinOps Enable Smarter Cloud Cost Optimization in Banking
Introduction Banking has entered an era where cloud technology is central to digital transformation. Mobile banking applications, digital payments, online lending, fraud detection, open banking APIs, wealth management platforms, and real-time financial services all depend on highly available and scalable IT infrastructure. Cloud adoption gives banks the flexibility to scale resources as demand changes, but … Continue reading “How AIOps and FinOps Enable Smarter Cloud Cost Optimization in Banking”
How to Improve Insurance Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability
Introduction Insurance companies operate some of the most data-intensive business processes in the financial services industry. Policy administration, underwriting, claims, billing, customer portals, fraud detection, actuarial analysis, and regulatory reporting all depend on reliable data infrastructure. The insurance industry is also undergoing rapid digital transformation. Customers increasingly expect instant policy quotes, digital claims, mobile applications, … Continue reading “How to Improve Insurance Operations with Enteros Database Software, AI-Powered Analytics, and Database Observability”
How to Optimize Healthcare Database Performance with Enteros Database Software, AI-Powered Analytics, and Database Observability
Introduction Healthcare organizations are becoming increasingly dependent on digital infrastructure. Electronic Health Records (EHRs), patient portals, telemedicine platforms, medical imaging, laboratory systems, pharmacy applications, revenue cycle systems, payer platforms, and AI-powered clinical applications all rely on databases to deliver information quickly and reliably. As healthcare organizations consolidate data and move more workloads to cloud and … Continue reading “How to Optimize Healthcare Database Performance with Enteros Database Software, AI-Powered Analytics, and Database Observability”