Purpose
This command helps the interactive user to display a numbered list, re-submit an item from the list, and manage the list; of previously entered BTEQ commands and SQL requests, within the same invocation.
Syntax
Command | Shorthand |
---|---|
COMMANDHISTORY | CH |
Option | Shorthand | Option | Shorthand | Option | Shorthand | Option | Shorthand |
---|---|---|---|---|---|---|---|
CLEAR | C | DISPLAY | D | TOP | T | ITEM | I |
RESET | RS | SIZE | S | TRIM | T | SUBMIT | S |
where the following is true:
- no option
- When no option is provided, displays up to 20 latest items from the list. The default display count can be changed using COMMANDHISTORY SET DISPLAY option.
- CLEAR
- Clears all items from the list. Item number is reset to 0, and the next entry will be stored as item #1.
- DISPLAY
- When no number is provided, displays up to 20 latest items from the list. The default display count can be changed using COMMANDHISTORY SET DISPLAY option.
- RESET
- Resets the COMMANDHISTORY controls back to their original default values:
- SET
-
- SIZE n: Sets the maximum size the list can grow up to, after which every new command/request will lead to removal of one oldest item. The default value is set to 200 at invocation time. The value of n can range from 1 to 500.
- DISPLAY n: Sets the default number of items to display when COMMANDHISTORY is used by itself, or COMMANDHISTORY DISPLAY is used without a number. The default value is set to 20 at invocation time. The value of n can range from 1 to 500.
- TRIM n: Sets the default number of lines after which, the display of request text from a history item that spans multiple lines, will be trimmed. The default is set to 0, meaning no trimming. The value of n can range from 0 to 4294967295.
- SUBMIT n
- Submits the request text stored in the n-th item if the item exists in the list. The value of n can range from 1 to 4294967295.
Usage Notes
Users are encouraged to use the shorthand syntax CH for the COMMANDHISTORY command as well as its options.
This command is available on all supported platforms starting with BTEQ 20.00.00.07.
When running in interactive mode, BTEQ will maintain a list of all entered commands and SQL requests as history items. Any new item gets added at the end of the list, and if the list is full, the oldest item gets deleted from the beginning.
Every entry in the list is assigned an item number, which persists unless the history is cleared. This enables a command to be re-submitted using its persisting item number, as long as that item is available in the list.
An item also contains metadata about it being a BTEQ command or a SQL request, which is indicated when the list is displayed.
For example, for the following set of commands and requests entered in interactive mode:
.LOGON tdpid/username (password entered in interactive masked mode) .REMARK 'A single-line BTEQ command' SELECT /* A multi-line SQL request */ * FROM dbc.dbcinfo WHERE InfoKey = 'Release'; SELECT /* A single-line SQL request */ date;
Following is the output of the COMMANDHISTORY command:
BTEQ -- Enter your SQL request or BTEQ command: .COMMANDHISTORY .COMMANDHISTORY -- Item# 1, Type# Command .LOGON tdpid/username -- Item# 2, Type# Command .REMARK 'A single-line BTEQ command' -- Item# 3, Type# Request SELECT /* A multi-line SQL request */ * FROM dbc.dbcinfo WHERE InfoKey = 'Release'; -- Item# 4, Type# Request SELECT /* A single-line SQL request */ date; BTEQ -- Enter your SQL request or BTEQ command:
The usage of COMMANDHISTORY command is not stored as a history item.
The COMMANDHISTORY command cannot follow any other command within the same instruction. When used, it must be the only command in the instruction.
If a shorthand syntax is used in the input, its expanded form gets stored as the corresponding history item.
The WIDTH setting affects the display of request text in the history items.
A request text submitted via COMMANDHISTORY SUBMIT n, gets added as a new history item.
The COMMANDHISTORY command is valid in an SQL macro.
The DEFAULTS command does not affect the COMMANDHISTORY controls. They can be managed using COMMANDHISTORY SET option.
When TRIM is set to a non-0 value, the output of COMMANDHISTORY DISPLAY will indicate that trimming has occurred for those items whose request text spans more than allowed number of lines. However, when using COMMANDHISTORY DISPLAY ITEM n option to display a specific item, that item is displayed without trimming its request text, irrespective of TRIM value.
For example, the following commands are entered after the previous input:
.COMMANDHISTORY SET TRIM = 2 .COMMANDHISTORY .COMMANDHISTORY DISPLAY 3
As a result, the following is the output.
BTEQ -- Enter your SQL request or BTEQ command: .COMMANDHISTORY SET TRIM = 2 .COMMANDHISTORY SET TRIM = 2 *** History item's TRIM limit set to 2 line(s). BTEQ -- Enter your SQL request or BTEQ command: .COMMANDHISTORY .COMMANDHISTORY -- Item# 1, Type# Command .LOGON tdpid/username -- Item# 2, Type# Command .REMARK 'A single-line BTEQ command' -- Item# 3, Type# Request SELECT /* A multi-line SQL request */ * FROM ... (trimmed) -- Item# 4, Type# Request SELECT /* A single-line SQL request */ date; BTEQ -- Enter your SQL request or BTEQ command: .COMMANDHISTORY DISPLAY ITEM 3 .COMMANDHISTORY DISPLAY ITEM 3 -- Item# 3, Type# Request SELECT /* A multi-line SQL request */ * FROM dbc.dbcinfo WHERE InfoKey = 'Release'; BTEQ -- Enter your SQL request or BTEQ command:
SHOW CONTROLS COMMANDHISTORY indicates the current settings (maximum list size, default display and trim values) that are in effect, as well as the number of history items currently stored in the list.
For example, the following commands are entered after the previous input:
.SHOW CONTROLS COMMANDHISTORY
As a result, the following is the output.
BTEQ -- Enter your SQL request or BTEQ command: .SHOW CONTROLS COMMANDHISTORY .SHOW CONTROLS COMMANDHISTORY COMMANDHISTORY MAXSIZE = 200 COMMANDHISTORY ITEMS = 4 COMMANDHISTORY DISPLAY = 20 COMMANDHISTORY TRIM = 2 BTEQ -- Enter your SQL request or BTEQ command: