Programming Guide



FORMAT

Formats CATQUERY values

Synopsis

DBMS [ WITH CURSOR cursor ] FORMAT [ [ column ] format 
[, [ column] format ... ] ]

Arguments

WITH CURSOR cursor
Name of declared SELECT cursor. If the clause is not used, Panther uses the default SELECT cursor.

column
Name of selected column. The case of column should match the setting of the case flag for the database engine. If columns are not named, the formats are applied by position.

format
Specifies how Panther should format the value. format is either a Panther variable or a quoted precision edit.

Description

Use DBMS FORMAT to format CATQUERY values before writing them to a variable or a text file. The options are explained below.

If format is a Panther variable, Panther formats the column value as if it were writing to the field. In particular, the following characteristics affect the formatting:

For more information about formatting select results, refer to "Format of Select Results" in Application Development Guide.

format can also be a precision edit. A precision edit is a quoted string beginning with a percent sign. It supplies the length of the value, and optionally, a decimal precision for numeric values.

A precision is given in the form

"%width"
"%width.precision"

To turn off formatting on the default or named cursor, execute DBMS FORMAT with no arguments.

Example

// use column "title_id" and "copy_num" exactly as returned
// format column "due_back" with the LDB variable "today",
// format column "price" to width 5 with 2 decimal places
// format column "rental_comment" to width 25 and truncate.
proc tapes_due
DBMS CATQUERY TO FILE rentlist
DBMS FORMAT due_back today, price "%5.2", \
rental_comment "%25"
DBMS QUERY SELECT title_id, copy_num, due_back, price, \
rental_comment FROM rentals
return