How To Retrieve Values from Data Fields in RECORD Variables

Q

How To Retrieve Values from Data Fields in RECORD Variables? - Oracle DBA FAQ - Working with Database Objects in PL/SQL

✍: FYIcenter.com

A

If a variable is a RECORD variable with data fields assigned values, you can retrieve those values out of its data fields by using fields names prefixed with variable name as "variable.field_name". Here is a sample script showing you how to retrieve field values from RECORD variables:

CREATE OR REPLACE PROCEDURE HELLO AS
  TYPE student IS RECORD (
    id NUMBER(5),
    first_name VARCHAR(80),
    last_name VARCHAR(80)
  );
  best_student student;
  another_student student;
  class_name VARCHAR2(80);
BEGIN
  class_name := 'FYI Center 2006';
  best_student.first_name := 'The';
  best_student.last_name := 'Best';
  DBMS_OUTPUT.PUT_LINE('Best student = ' || 
    best_student.first_name || ' ' 
    || best_student.last_name);
END;
/
Best student = The Best

2007-04-27, 4401👍, 0💬