HP c-tree-SQL ISQL and Tools manual Example 3-3 Customizing Format of Numeric Column Displays

Models: c-tree-SQL ISQL and Tools

1 99
Download 99 pages 4.83 Kb
Page 33
Image 33

ISQL Statements

Example 3-3: Customizing Format of Numeric Column Displays

ISQL> column order_value format "$99,999,999.99"

ISQL> column; -- Show all the COLUMN statements now in effect: column CUSTOMER_NAME format "A19" heading "CUSTOMER_NAME" column CUSTOMER_CITY format "A19" heading "CUSTOMER_CITY" column ORDER_VALUE format "$99,999,999.99" heading "ORDER_VALUE"

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;

ORDER_ID

ORDER_VALUE

CUSTOMER_NAME

CUSTOMER_CITY

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

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

--------

-----------

Aerospace Enterpris

Scottsdale

13

$3,000,000.00

Aerospace Enterpris

Scottsdale

14

$1,500,000.00

Chemical Constructi

Joplin

11

$3,000,000.00

Chemical Constructi

Joplin

12

$7,500,000.00

Luxury Cars Inc.

North Ridgeville

21

$6,000,000.00

Luxury Cars Inc.

North Ridgeville

20

$5,000,000.00

.

 

 

 

.

 

 

 

.

 

 

 

3.4.2Summarizing Data with DISPLAY, COMPUTE, and BREAK State- ments

Now that the query displays the rows it returns in a more acceptable format, you can use DIS- PLAY, COMPUTE, and BREAK statements to present order summaries for each customer.

All three statements rely on a break specification to indicate to ISQL when it should perform associated processing. There are four types of breaks you can specify:

Column breaks are processed whenever the column associated with the break changes in value

Row breaks are processed after display of each row returned by the query

Page breaks are processed at the end of each page (as defined by the SET PAGESIZE state- ment)

Report breaks are processed after display of all the rows returned by the query

While DISPLAY and COMPUTE statements specify what actions ISQL takes for a particular type of break, the BREAK statement itself controls which type of break is currently in effect. A consequence of this behavior is that DISPLAY and COMPUTE statements don't take effect until you issue the BREAK statement with the corresponding break specification.

Also, keep in mind that there can be only one type of break in effect at a time. This means you can format a particular query for a single type of break.

In our example, we are interested in a column break, since we want to display an order sum- mary for each customer. In particular, we want to display the name of the customer along with the number and total value of orders for that customer. And, we want this summary displayed

FairCom Corporation

3-7

Page 33
Image 33
HP c-tree-SQL ISQL and Tools manual Example 3-3 Customizing Format of Numeric Column Displays, Ordervalue