SQL/MP Report Writer Guide
Table Of Contents
- What’s New in This Manual
- About This Manual
- 1 Introduction to the NonStop SQL/MP Report Writer
- 2 Using SQLCI and the Report Writer
- 3 Selecting Data for a Report
- 4 Customizing a Report
- Defining the Layout
- Specifying the Items in a Detail Line
- Naming Select List and Detail Line Items
- Organizing Rows Into Break Groups
- Labeling Information
- Formatting Data Values
- Formatting Dates and Times
- Using TACL to Pass Parameters
- Conditional Printing of Items or Line Entries
- Redefining Special Characters
- Calculating Totals
- Calculating Subtotals
- Printing Double-Byte Characters
- A Comparison of the Report Writer and the Enform Language
- Index
Selecting Data for a Report
HP NonStop SQL/MP Report Writer Guide—527213-001
3-26
Using Views
To prepare the SELECT command enter the following command:
>> OBEY SELPREP;
( PREPARE command is displayed here.)
.
.
--- SQL command prepared.
To execute the prepared SELECT command for each report and print the report, enter
the following command:
>> OBEY PRINTREP;
Using Views
A view is a logical table derived by projecting a subset of the columns or selecting a
subset of the rows from one or more tables or from another view. You specify the
definition of the view by using a SELECT command.
By defining a view, you can provide a way in which other users can retrieve values
without specifying complicated queries. For example, the following commands define a
view named CUSTORD to be used to print invoices and reports that summarize order
information. The view columns are specified in parentheses following the view name.
The rest of the command specifies the selection of columns and rows for the view.
>> VOLUME SALES;
>> CREATE VIEW CUSTORD
+> ( CUSTNUM, CUSTNAME,
+> STREET, CITY, STATE, POSTCODE,
+> CREDIT,
+> ORDERNUM, ORDER_DATE, DELIV_DATE,
+> SALESREP,
+> PARTNUM, UNIT_PRICE, QTY_ORDERED )
+> AS SELECT
+> C.CUSTNUM, CUSTNAME,
+> STREET, CITY, STATE, POSTCODE,
+> CREDIT,
+> O.ORDERNUM, ORDER_DATE, DELIV_DATE,
+> SALESREP,
+> PARTNUM, UNIT_PRICE, QTY_ORDERED
+> FROM SALES.CUSTOMER C,
+> SALES.ORDERS O,
+> SALES.ODETAIL OD
+> WHERE C.CUSTNUM = O.CUSTNUM
+> AND O.ORDERNUM = OD.ORDERNUM ;
With the CUSTORD view defined, you can select data for an invoice by entering a
simple SELECT command:
>> SELECT * FROM SALES.CUSTORD ;