2-5. Creating Your Own Records to Receive Query Results

Problem

You want to query the database, return several columns from one or more tables, and store them into local variables of a code block for processing. Rather than placing the values of the columns into separate variables, you want to create a single variable that contains all the values.

Solution

Create a database RECORD containing variables to hold the data you want to retrieve from the database. Since a RECORD can hold multiple variables of different datatypes, they work nicely for grouping data that has been retrieved as a result of a query.

In the following example, the database is queried for the name and position of a player. The data that is returned is used to populate a PL/SQL ...

Get Oracle and PL/SQL Recipes: A Problem-Solution Approach 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.