Skip to Content
Oracle in a Nutshell
book

Oracle in a Nutshell

by Rick Greenwald, David C. Kreines
December 2002
Intermediate to advanced
928 pages
85h 29m
English
O'Reilly Media, Inc.
Content preview from Oracle in a Nutshell

Using Records

Individual fields of records are referenced via dot notation:

                  record_name.field_name

Individual fields within a record can be read from or written to. They can appear on either the left or right side of the assignment operator. An entire record can be assigned to another record of the same type, but one record cannot be compared to another record via Boolean operators. For example, the following is a valid assignment:

shipto_address_rec := customer_address_rec

But the next example is not a valid comparison (you must compare the individual fields of the record instead):

IF shipto_address_rec = customer_address_rec
THEN
...
END IF;

Values can be assigned to records or to the fields within a record in four different ways:

  • You can use the assignment operator to assign a value to a field:

    new_emp_rec.hire_date := SYSDATE;
  • You can SELECT INTO a whole record or the individual fields:

    SELECT emp_id,dept,title,hire_date,college_recruit
      INTO new_emp_rec
      FROM emp
     WHERE surname = 'LI'
  • You can FETCH INTO a whole record or the individual fields:

    FETCH emp_cur INTO new_emp_rec;
    FETCH emp_cur INTO new_emp_rec.emp_id, 
       new_emp_rec.name;
  • You can assign all of the fields of one record variable to another record variable of the same type:

    IF rehire THEN
     new_emp_rec := former_emp_rec;
    ENDIF;

    This aggregate assignment technique works only for records declared with the same TYPE statement.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Oracle

Oracle

Guy Harrison
Oracle Built-in Packages

Oracle Built-in Packages

Steven Feuerstein, Charles Dye, John Beresniewicz

Publisher Resources

ISBN: 0596003366Errata Page