Skip to main content
← PL/SQL Topics

Language Basics

Explain PL/SQL records (user-defined and %ROWTYPE)

PL/SQL Records

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

A record groups related fields under one name; %ROWTYPE builds a record shaped like a table row or cursor.

How it works

A record is a composite variable holding named fields of possibly different types — like a row in memory. Declare one from a table or cursor with %ROWTYPE, or define a custom shape with TYPE ... IS RECORD. You can assign one whole record to another of the same type, pass records to subprograms, and use a record directly in INSERT ... VALUES rec and UPDATE ... SET ROW = rec.

How it works
DECLARE
  TYPE emp_summary_t IS RECORD (
    id        employees.employee_id%TYPE,
    full_name VARCHAR2(120),
    annual    NUMBER
  );
  r_emp emp_summary_t;
BEGIN
  SELECT employee_id, first_name || ' ' || last_name, salary * 12
    INTO r_emp
    FROM employees
   WHERE employee_id = 100;
  DBMS_OUTPUT.PUT_LINE(r_emp.full_name || ' earns ' || r_emp.annual);
END;
/

Related questions

GroundingGenerated

Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.

Have a follow-up, or a different question?

Continue in Ask Oracle AI