Previous Topic: Sample PRINT QueryNext Topic: Basic Syntax Diagram


PRINT Statement

Purpose

Use the PRINT statement to show the information produced from your query in a report-like format. The values of the columns and keys you specify in the PRINT statement appear in columns. Each column has a standard heading which can be specified by you as the name of the column. Names used in a PRINT statement are first evaluated as columns, then as keys if no column is found with the specified name. The PRINT statement allows you to:

CA Dataquery also allows you to specify in the PRINT statement the accumulation of numeric columns. For those columns which you want to accumulate, enclose the column name in parentheses. The column to be accumulated can be a specific column within a table or a result from a SET statement in the query.

Operation

If you specify control breaks in a SORT statement within your query, the columns you want totals on are subtotaled according to the control breaks designated there. You can specify up to ten levels of control break totals in the report. A grand total of the columns to be totaled is provided automatically at PRINT time.

Before CA Dataquery sends the PRINT output to your terminal, it edits the data for errors relating to how it is presented.

If CA Dataquery encounters an error in a column being edited before it presents the output, a special error code surrounded by asterisks is reported in place of the column in the report. See the Message Guide for a list of PRINT and DISPLAY error codes if you receive one of these errors.

If you have specified control breaks in the SORT statement and accumulation columns in the PRINT statement, totals can be viewed several ways. See the CA Dataquery User Guide for more information.

Syntax Diagram

The following syntax shows the most complex version of the PRINT statement.

►►─ PRINT ─┬────────────────────────────────────┬─────────────────────────────►
           └─┬─ TITLE1 ─┬─ ' report-heading1 ' ─┘
             └─ TITLE ──┘

 ►─┬────────────────────────────┬─┬────────┬──────────────────────────────────►
   └─ TITLE2 'report-heading2' ─┘ └─ FROM ─┘

 ►─┬─────────────────────────────┬─┬─────┬─┬─ key-name ────┬─┬─────┬──────────►
   └─ table-name ─┬────────────┬─┘ └─ ( ─┘ └─ column-name ─┘ └─ ) ─┘
                  └─ (status) ─┘

 ►─┬─────────────────────────────────┬─┬──────────────────────────┬───────────►◄
   └─ 'heading1 ─┬─────────────┬─ ' ─┘ └─ PICture 'edit-pattern' ─┘
                 └─ /heading2 ─┘

Caution! To simplify discussion, this document divides the PRINT statement into its important elements and discusses them in the following sections.

Basic statement

Next section.

For output headings

Headings Syntax Diagram

For edit patterns

PICTURE Clause