Using the ttIsql edit Command

You can use the ttIsql edit command to edit a file or edit ttIsql commands in a text editor.

The ttIsql edit command starts a text editor such as emacs, gedit, or vi. See Changing the Default Text Editor for the ttIsql edit Command.

The syntax for the ttIsql edit command is as follows:

Command> edit [ file | !history_search_command ]

You can only use one parameter at a time. The history_search_command parameter is defined as the ! character followed by the number of the command or a search string. If you do not specify a ! character, the ttIsql edit command interprets the parameter as file. file is the name of the file that you want to edit. If you do not specify a parameter or specify !!, the last ttIsql command is edited.

When you specify a file parameter, the editor edits the specified file. If TimesTen does not find an exact file match for the specified file parameter in the current working directory, it searches for file.sql. If neither file exists, the editor creates the specified file in the current working directory. You can specify a path in the file parameter.

The following example edits the new.sql file:

edit new.sql;

The following example edits the new.sql file in the /scripts directory:

edit /scripts/new.sql;

If you run the ttIsql edit command with a file parameter, ttIsql does not run the contents of the file after you exit the editor.

You can edit a SQL statement that is stored in the history list of the current ttIsql session. When calling the ttIsql edit command specify the ! character followed by the number of the command or a search string. The editor opens the ttIsql command in a temporary file that you can save in a preferred location. For more information on using the ttIsql history command, see Using the ttIsql Command History.

The following example edits ttIsql command 2:

edit !2;

The following example searches for and edits the last ttIsql command that contains the search string create:

edit !create;

The following example runs a CREATE TABLE statement and then uses the edit command to edit the CREATE TABLE statement in a text editor:

Command> CREATE TABLE t1 
(c1 VARCHAR(10) NOT INLINE NOT NULL, c2 VARCHAR(144) INLINE NOT NULL);
Command> edit;

The prior example is equivalent to using the ttIsql edit command with the !! parameter:

Command> CREATE TABLE t1 
(c1 VARCHAR(10) NOT INLINE NOT NULL, c2 VARCHAR(144) INLINE NOT NULL);
Command> edit !!;

If you run the ttIsql edit command with a history_search_command parameter, ttIsql runs the contents of the file after you exit the editor. The contents of the file run as a single ttIsql command. If you do not want to run the contents of the file, delete the contents of the file and save the file before you exit the editor.

Changing the Default Text Editor for the ttIsql edit Command

You can specify the default editor by defining the ttIsql _EDITOR define alias.

The following example sets the default editor to vi.

DEFINE _EDITOR=vi

If you do not define the _EDITOR define alias, ttIsql uses the editor specified by the VISUAL environment variable. If the _EDITOR define alias and the VISUAL environment variables are not set, ttIsql uses the editor specified by the EDITOR environment variable. When _EDITOR, VISUAL, and EDITOR are not set, vi is used for Linux and UNIX and notepad.exe is used for Windows.