Chapter 5. Records

Beginner

Q:

5-1.

The statements are:

  1. False. A record is not a scalar datatype, meaning that it contains only one piece of information. The whole point of a record is to contain multiple pieces of information: it is a composite datatype whose structure is much like a row in a database table.

  2. True.

  3. False. A record is not designed specifically to hold sounds, but you could (in Oracle8 and above) easily define a record with a LOB (large object) field that contains a sound file.

  4. False. It doesn’t make any sense to define a record based on a tablespace. You can, on the other hand, define a record that resembles a row in a table or row fetched by a cursor.

  5. True.

Q:

5-2.

Only the format shown in (c), called dot notation, can reference a field in a record. In general, you refer to an individual field in a record as record_name.field_name. You must always use the fully qualified name of a field when referencing that field.

Q:

5-3.

To define a table-based record, use the %ROWTYPE declaration attribute:

DECLARE
   ceo_rec ceos%ROWTYPE;

Q:

5-4.

The statements are:

  1. False. A table-based record takes its definition from the structure of a table: each field has the same name and datatype as each and every column in its associated table (not just the nonnumeric fields). To define a table-based record, declare it with the %ROWTYPE attribute (you can only use %TYPE with scalar variable declarations). Suppose the emp table is defined as follows:

    CREATE TABLE emp ( empno NUMBER, ename VARCHAR2(30), hiredate ...

Get Oracle PL/SQL Programming: A Developer's Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.