HP c-tree-SQL ISQL and Tools manual Example 3-1 Unformatted Query Display from Isql

Models: c-tree-SQL ISQL and Tools

1 99
Download 99 pages 4.83 Kb
Page 31
Image 31

ISQL Statements

All the examples use the same ISQL query. The query retrieves data on outstanding customer orders. The query joins two tables, customers and orders. The examples for the TABLE state- ment on Section 3.7.13 "HOST or SH or !" on page 3-31 show the columns and data types for these sample tables.

The following example shows the query and an excerpt of the results as ISQL displays them without the benefit of any query-formatting statements:

Example 3-1: Unformatted Query Display from ISQL

ISQL> select c.customer_name, c.customer_city, o.order_id, o.order_value from customers c, orders o

where o.customer_id = c.customer_id order by c.customer_name;

CUSTOMER_NAME

CUSTOMER_CITY

-------------

-------------

ORDER_ID ORDER_VALUE

--------

-----------

Aerospace Enterprises Inc.

Scottsdale

13

3000000

Aerospace Enterprises Inc.

Scottsdale

14

1500000

Chemical Construction Inc.

Joplin

11

3000000

Chemical Construction Inc.

Joplin

12

7500000

Luxury Cars Inc.

North Ridgeville

21

6000000

Luxury Cars Inc.

North Ridgeville

20

5000000

Although this query retrieves the correct data, the formatting is inadequate:

The display for each record wraps across two lines, primarily because of the column defini- tions for the text columns customer_name and customer_city. ISQL displays the full col- umn width (50 characters for each column) even though the contents don't use the entire width.

It's not clear that the values in the order_value column represent money amounts.

The next section shows how to use the COLUMN statement to address these formatting issues.

In addition, you can use DISPLAY, COMPUTE, and BREAK statements to present order sum- maries for each customer. Section 3.4.2 "Summarizing Data with DISPLAY, COMPUTE, and BREAK Statements" on page 3-7 shows how to do this. Finally, you can add text that ISQL displays at the beginning and end of query results with the TITLE statement, as described in Section 3.4.3 "Adding Beginning and Concluding Titles with the TITLE Statement" on page 3- 9.

All of these statements are independent of the actual query. You do not need to change the query in any way to control how ISQL formats the results.

FairCom Corporation

3-5

Page 31
Image 31
HP c-tree-SQL ISQL and Tools Example 3-1 Unformatted Query Display from Isql, Customername Customercity Orderid Ordervalue