Please enable JavaScript to view this site.

ESL Documentation

Inquiry Command

Return the width of each column selected.

widths SELECT_STATEMENT 

SELECT_STATEMENT 

A TRANSACT_SQL select statement.

Description

This command causes the SQL executable to parse the select statement and deliver an informational message describing the maximum possible width of each column selected. The message has the form:

INFO_STRING set F1 WIDTH set F2 WIDTH ... set Fn WIDTH
 

For each column in the select statement, a set command appears on the information message line. The message is terminated with a newline.

The widths values are positive values for columns with TRANSACT-SQL data types int, smallint, tinyint, float, bit, and money, and DB/2 data types float, decimal, int, and smallint. For other data types, the widths are negative.

The ESL program may respond to this command by stripping off the leading information string and resubmitting the line as a command, followed by submitting the SELECT_STATEMENT as a command. This has the effect of columnarizing the output for this query, with all numeric columns right-justified and all character columns left-justified, since the output width for each column is set to the maximum length of data for that column, as determined by the data type for that column.

Oracle Only

Absolute maximum widths are returned for each datatype except for character variable datatypes, in which case the program returns the column width defined when the table was created.

Example

response to OrgQuery
   copy "select * from org\n" to QueryString
   send "widths " QueryString to SQL
 

response to line "INFO: " from SQL

   extract from input
      skip by 7 # Skip over INFO string
      take to last SetCommand
 

   send SetCommand "\n" to SQL
   send QueryString to SQL

See Also

maxwidth Command

set Command