Share via


Arrays and SELECT - SQL

Use the SELECT - SQL Command - INTO or TO Clause to query tables and direct query results to an array.

If an array does not exist and the SQL SELECT Statement returns one or more records, the command creates an array. An existing array is re-created to accommodate the query results.

Note   If the SQL SELECT statement does not return any records, an existing array remains unchanged and may contain previous results. If an array does not exist, the command does not create one. Consider using the _TALLY System Variable to determine if a SQL SELECT statement returns any records.

Example

In the following example, SELECT - SQL directs its query results to an array named RESULTS:

SELECT DISTINCT a.cust_id, a.company, b.amount ;
FROM customer a, payments b ;
WHERE a.cust_id = b.cust_id INTO ARRAY results

DISPLAY MEMORY LIKE results

RESULTS   Priv A            TEST
  ( 1, 1)   C  "000004"
  ( 1, 2)   C  "Stylistic Inc."
  ( 1, 3)   N    13.91  (    13.91000000)
  ( 2, 1)   C  "000008"
  ( 2, 2)   C  "Ashe Aircraft"
  ( 2, 3)   N    4021.98  (  4021.98000000)
  ( 3, 1)   C  "000010"
  ( 3, 2)   C  "Miakonda Industries"
  ( 3, 3)   N     9.84  (   9.84000000)

See Also

Concepts

Data Transfer from a Table to an Array

Data Transfer from an Array to a Table

Reference

SELECT - SQL Command

Other Resources

Data Transfer and Arrays

Data Manipulation