Intermediate

Q:

5-8.

The statements are:

  1. Valid. This reason, along with (c) and (e), is an excellent reason to define your own record TYPE and then declare records from that TYPE. With programmer-defined records, you can rely on any and all native PL/SQL datatypes. You are not restricted to the definitions of existing tables or cursors. And, in a record TYPE you can declare another record TYPE, or even a collection TYPE (index-by table, nested table, variable array).

  2. Invalid. Using programmer-defined records does not, on the other hand, result in PL/SQL code that is independent of Oracle and can be ported to SQL Server. PL/SQL is a language proprietary to Oracle.

  3. Valid.

  4. Invalid. This reason may reflect a real concern (“fear” may be a better word) in your development organization, but the solution to this problem is not an avoidance of the %ROWTYPE attribute. Perhaps a round of mud wrestling will do the trick.

  5. Valid.

Q:

5-9.

All these statements are true. A programmer-defined record takes its definition from a TYPE statement in which each field in the record (its name and datatype) is defined explicitly (kind of like a CREATE TABLE statement inside PL/SQL). To declare a programmer-defined record:

  • Use the TYPE statement to declare a record type: a general record structure that can be shared by multiple record instances.

  • Use the record type as a basis for declarations of actual records having that structure.

Here is an example of both these steps:

DECLARE TYPE summer_fun_rt IS RECORD ( favorite_ice_cream_flavor ...

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.