Formatting Output of ISQL QueriesFormatting of database query results makes the output of a database query more presentable and understandable. The formatted output of an ISQL database query can be either displayed on the screen, written to a file, or spooled to a printer to produce a hard copy of the report. ISQL includes several statements that provide simple formatting of c-treeSQL queries. The following table summarizes the ISQL query-formatting statements.
The rest of this section provides an extended example that illustrates how to use the statements together to improve formatting. All the examples use the same ISQL query. The query retrieves data about outstanding customer orders. The query joins two tables, CUSTOMERS and ORDERS. The examples for the TABLE statement on "HOST or SH or !" 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 Unformatted Query Display from ISQL
from customers c, orders o where o.customer_id = c.customer_id order by c.customer_name;
------------- ------------- 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 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 summaries for each customer. "Summarizing Data with DISPLAY, COMPUTE, and BREAK Statements" 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 "Adding Beginning and Concluding Titles with the TITLE Statement". 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. |
|||||||||||||||||||||