ttIsql

Use ttIsql to run SQL statements and call TimesTen built-in procedures from this utility. Additionally, you can run SQL interactively from the command line and call a TimesTen built-in procedure with call procedure-name.

The ttIsql command attempts to cancel an ongoing ODBC function when the user presses Ctrl-C.

On UNIX and Linux systems, this utility is supported for TimesTen Data Manager DSNs. Use ttIsqlCS for client/server DSNs.

The ttIsql utility starts with AUTOCOMMIT turned on, even when running a script. You can turn AUTOCOMMIT off and back on as necessary.

For a detailed description on running SQL from ttIsql, use the -helpfull option.

For more details on the ttIsql utility, see the chapter Using the ttIsql Utility in Oracle TimesTen In-Memory Database Operations Guide.

Required Privilege

This utility requires no privileges.

Usage in TimesTen Scaleout and TimesTen Classic

This utility is supported in both TimesTen Classic and TimesTen Scaleout.

Syntax

ttIsql {-h | -help | -? | -helpcmds | - helpfull}
ttIsql {-V | -version}
ttIsql [-f inputFile] [-v verbosity] [-e commands | sql_statement] 
[-interactive] [-N ncharEncoding] [-wait] {-connStr connection_string | DSN}

Options

ttIsql has the options:

Option Description

-connStr connection_string

An ODBC connection string that specifies a database location, driver, and optionally other connection attribute settings.

DSN

Specifies an ODBC data source name of the database to be connected.

-e commands

Specifies a semicolon separated list of ttIsql commands to run on startup.

-f filename

Read SQL statements from filename.

-h

-help

-?

Prints a usage message and exits.

-helpcmds

Prints a short list of the interactive commands.

-helpfull

Prints a full description of the interactive commands.

-interactive

Forces interactive mode. This is useful when running from an emacs comint buffer.

-N ncharEncoding

Specifies the character encoding method for NCHAR output.

Valid values are LOCALE or ASCII. LOCALE (the default) sets the output format to the locale-based setting.

If no value is specified, TimesTen uses the system's native language characters.

-V | -version

Prints the release number of ttIsql and exits.

-v verbosity

Specifies the verbosity level. One of:

0 - Shows error information only. If all commands succeed, there is no output.

1 - The basic output generated by commands is displayed.

2 (default) - Same as level 1, plus it shows more detailed results of commands.At this level simplified SQL error and information messages are displayed. In addition, ttIsql commands that are read from an external file are echoed to the display.

3 - Same as level 2, with more detailed error and information messages.

4 - Same as level 3, plus complete error and information messages are displayed. Also displayed are messages about prepared commands, "success" messages for each command that succeeded and content of XLA records.

-wait

Waits until successful connect.

Commands

Also see the list of ttIsql Set/Show Attributes.

Boolean commands can accept the values "ON" and "OFF" or "1" and "0".

ttIsql has the commands:

Command Description

accept variable[NUM[BER]| CHAR |BINARY_FLOAT | BINARY_DOUBLE] [DEF[AULT]default_value] [PROMPT prompt_text | NOPR[OMPT]] [HIDE]

Gets input from a user and DEFINES the variable. If a type is specified then it validates for that type. The default (enclosed in quotes) is assigned if the user just presses enter. The prompt is displayed before waiting for input (or can be suppressed). The HIDE option stops the terminal from displaying the entered text (for passwords).

The prompt is displayed before waiting for input, if specified without the HIDE option. The HIDE option stops the terminal from displaying the entered text.

allfunctions [[owner_name_pattern.] table_name_pattern]

Lists, in a single column, the names of all the PL/SQL functions that match the given pattern selected from SYS.ALL_OBJECTS. When a pattern is missing, the pattern defaults to "%".

If passthrough is enabled, lists PL/SQL functions matching the pattern in the Oracle database.

See the functions command.

allindexes [[owner_name_pattern.] table_name_pattern]

Describes the indexes that it finds on the tables that match the input pattern selected from SYS.ALL_OBJECTS. When a pattern is missing, the patterns default to "%".

If passthrough is enabled, lists indexes on tables matching the pattern in the Oracle database.

See the indexes command.

allpackages [[owner_name_pattern.] table_name_pattern]

Lists, in a single column, the names of all the PL/SQL packages that match the given pattern selected from SYS.ALL_OBJECTS. When a pattern is missing, the patterns default to "%".

If passthrough is enabled, lists PL/SQL packages matching the pattern in the Oracle database.

See the packages command.

allprocedures [[owner_name_pattern.] procedure_name_ pattern]

Lists, in a single column, the names of all the PL/SQL procedures that match the given pattern selected from SYS.ALL_OBJECTS. When a pattern is missing, the pattern defaults to "%".

If passthrough is enabled, lists PL/SQL procedures matching the pattern in the Oracle database.

See the procedures command.

allsequences [[owner_name_pattern.] table_name_pattern]]

Lists, in a single column, the names of all the sequences that match the given pattern selected from SYS.ALL_OBJECTS. When a pattern is missing, the pattern defaults to "%".

If passthrough is enabled, lists sequences on tables matching the pattern in the Oracle database.

See the sequences command.

allsynonyms [[schema_pattern.] object_pattern]]

Lists, in a single column, the names of all synonyms that match the given pattern. When a pattern is missing, the pattern defaults to "%".

If passthrough is enabled, lists synonyms on tables matching the pattern in the Oracle database.

See the synonyms command.

alltables [[owner_name_pattern.] table_name_pattern]]

Lists, in a single column, the names of all the tables that match the given pattern selected from SYS.ALL_OBJECTS. When a pattern is missing, the pattern defaults to "%".

If passthrough is enabled, lists tables matching the pattern in the Oracle database.

See the tables command.

allviews [[owner_name_pattern.] view_name_pattern]]

Lists, in a single column, the names of all the views that match the specified pattern selected from SYS.ALL_OBJECTS. When a pattern is missing, the pattern defaults to "%".

If passthrough is enabled, lists views matching the pattern in the Oracle database.

builtins [builtin_name_ pattern]

Lists, in a single column, the names of all the TimesTen built-in procedures that match the given pattern. When the pattern is missing, the pattern defaults to "%".

See the procedures command.

bye

exit

Exits ttIsql.

cachegroups [[cache_group_owner_pattern. cache_group_name_pattern]]

Reports information on cache groups defined in the currently connected data source, including the state of any terminated databases that contain autorefresh cache groups.

If the optional argument is not specified then information on all cache groups in the current data source is reported.

cachesqlget

[ASYNCONOUS_WRITETOUGH | INCREMENTAL_AUTOREFRESH] [[cache_group_owner.]cache_group_name] {INSTALL | UNINSTALL} [filename]

Generates an Oracle SQL*Plus compatible script for the installation or uninstallation of Oracle database objects associated with a readonly cache group, a user managed cache group with incremental autorefresh or an AWT cache group.

If INSTALL is specified, the Oracle SQL statement to install the Oracle database objects is generated.

If UNINSTALL is specified, the Oracle SQL statement used to remove the Oracle objects is generated. If a cache group is not specified with UNINSTALL, a SQL statement to remove all Oracle database objects in the autorefresh user's account is generated.

If the optional filename argument is included, the generated SQL statement is saved to the specified external file. If the external file exists, its contents are destroyed before writing to the file.

cd directory

Changes the current directory.

This is the equivalent of the cd command in interactive shells.

After changing to the directory directory, the define alias _CWD is be set to this directory.

Subsequent commands that rely on relative paths will use this directory as the starting point.

Examples of affected commands are spool, run, savehistory, host, and edit

clearhistory

Clears the history buffer. Also see history and savehistory.

clienttimeout

[timeeout seconds]

Sets the client timeout value in seconds for the current connection. If no value is specified, displays the current value.

See Choose SQL and PL/SQL Timeout Values in Oracle TimesTen In-Memory Database Operations Guide for information about the relationship between the client timeout, SQL timeout, and PL/SQL timeout.

close [connect_id.] command_id]

closeall

Closes the prepared command identified by connection name connect_id and command ID command_id. If command_id is not specified, closes the most recent command. If closeall is selected, closes all currently open prepared commands.

Use prepare to create the prepared command.

cmdcache [[by {sqlcmdid |querytext|owner}] query_subsstring]

Displays the contents of the TimesTen SQL command cache.

Specify the sqlcmdid, querytext or owner column and query substring to search for a specific portion of a SQL query. If no column is specified, searches the querytext column.

If passthrough is enabled, the command ID is not passed through to the Oracle database.

commit

Commits the current transaction (durably if Durability=1 for the connection).

commitdurable

Commits the current transaction durably.

compact

Compacts the database.

compare varA VarB

Compares the values of two variables and reports if they are different. The first difference is reported.

connect[connection_string |[[DSN][as]connid [adding] [connection_string | DSN][as connid]

Connects to the database with the specified ODBC connection_string.

If no password is supplied in this format, ttIsql prompts for the password.

If no user is given, ttIsql attempts to connect using the user name of the current user as indicated by the operating system.

If as connid is specified, you can explicitly name the connection. The connid must be only alphanumeric characters, is case sensitive, must start with an alpha character and can only be a maximum of 30 characters in length. The name of connid is automatically supplied to the ConnectionName general connection attribute. If the connect fails, the current connection is set to a special reserved connection named "none," which is never connected to anything.

When adding is specified, it refers to creating a new connection to the DSN specified by DSN or by the connection string.

createandloadfromoraquery [owner_name.]table_name [num_threads] query

Takes a table name, the number of threads for parallel load and an Oracle SELECT statement.

Creates the table in TimesTen if the table does not exist. Then, loads the table with the query result from the Oracle database. If the command creates the table, the table column names and types are derived from the query result.

Notes:

  • The specified TimesTen table cannot be a system table, a synonym, a view, a materialized view or a detail table of a materialized view, a global temporary table or a cache group table.

  • The query cannot have any parameter bindings.

  • Any unsupported column types result in a warning being logged. The output issues a comment for the unsupported column data type.

  • If you do not supply a value for num_threads, defaults to four threads.

  • For details and usage information, see Loading Data from an Oracle Database into a TimesTen Table in Oracle TimesTen In-Memory Database Operations Guide.

  • You must rollback or commit after runing this operation.

  • Also see the NOTES section in the description of the built-in procedure ttLoadFromOracle.

Required Privileges:

Requires INSERT privilege on the table specified. Also, requires the CREATE TABLE privilege if the table does not exist. The Oracle session user must have all required privileges to run the query on the Oracle database.

define name [= value]

Defines a string substitution alias.

If no value is provided, ttIsql displays the current definition for the specified name.

You must set define on to enable command substitution. See Set/Show Attributes.

describe [[owner_pattern.] name_pattern | procedure_name_pattern |sql_statement | [connect_id.]command_id |*]

List information on tables, synonyms, views, materialized views, sequences, cache groups, PL/SQL functions, PL/SQL procedures, PL/SQL packages and TimesTen built-in procedures in that order when the argument is [owner_pattern.]name_pattern. Otherwise lists the specific objects that match the given pattern.

Describes the parameters and results columns when the argument is sql_statement.

If passthrough is set to 3, lists information about the same types of objects in the Oracle database.

If * is specified, reports the prepared statements for all connections.

If the table or materialized view being described is in a TimesTen Scaleout database, this command reports the distribution scheme.

When describing cache groups, reports information on cache groups defined in the currently connected data source, including the state of any terminated databases that contain autorefresh cache groups.

If the command is describing a sequence in a TimesTen Scaleout database, displays the batch field.

The command alias is desc.

Use free to release the prepared command.

disconnect [all]

Disconnects from the database. If all is specified, disconnects and closes all connections. When disconnect finishes, the current connection is set to the reserved connection named "none."

dssize [k|m|g|t]

Prints size information in KB, MB, GB or TB. For TimesTen Scaleout, provides the size of the element.

The default is MB. The output indicates the unit returned.

e: msg

PROMPT msg

Echoes the specified messages, terminated by the end of the line. A semicolon is not required to end the line. Messages are not echoed if verbosity is set to 0.

edit [ file | !history_search_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.

If TimesTen does not find an exact file match for the specified file parameter, it searches for file.sql. If neither file exists, ttIsql starts the editor with the file file.

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.

If you run the ttIsql edit command with a history_search_command parameter, ttIsql runs the contents of the file after you exit the text editor. The contents of the file are 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.

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. If you do not specify a parameter or specify !!, the last ttIsql command is edited.

You can specify the default editor by defining the ttIsql _EDITOR define alias. The following example sets the default editor to vi:

Command> 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 UNIX and Linux systems and notepad.exe is used for Windows.

For more details, see Using the ttIsql Edit Command in Oracle TimesTen In-Memory Database Operations Guide.

exec [connect_id.] command_id] | PLSQLSTMT

Runs the prepared command command_id o

n connection connect_id or runs a PL/SQL statement.

The connect_id optionally names a ttIsql connection and command_id is an integer from 1 to 255.If PLSQLSTMT is supplied, ttIsql prepends the statement with BEGIN and appends the statement with END, thus allowing the PL/SQL statement to run.

If no argument is supplied, runs the most recent command.

Use free to release the prepared command.

execandfetch [connect_id.]command_id]

Runs and fetches all results from prepared command command_id on connection connect_id. If command_id is not specified, runs and fetches all results from the most recent command.

Use free to release the prepared command.

explain [plan for] {[ Connid.]ttisqlcmdid | sqlcmdid sqlcmdid | sqlstmt |!history}

Explains the plan for the specified SQL statement, including prepared ttIsql statements, specified in the ttisqlcmdid argument, or the sqlcmdid argument.

A digit that is not qualified with the sqlcmdid argument, is interpreted as a ttIsql prepared statement ID.

If passthrough is enabled, the command ID is not passed through to the Oracle database.

fetchall [connect_id.]command_id]

Fetches all results from prepared command command_id on connection connect_id.

If command_id is not specified, fetches all results from the most recent command. The command must already have been run using exec.

Use free to release the prepared command.

fetchnext num_rows [connect_id.]command_id]

Fetches up to num_rows rows from prepared command command_id on connection connect_id.

If command_id is not specified, fetches num_rows rows from the most recent command. The command must already have been run using exec.

Use free to release the prepared command.

fetchone [connect_id.]command_id]

Fetches one result from prepared command command_id on connection connect_id.

If command_id is not specified, fetches one result from the most recent command. The command must already have been run using exec.

Use free to release the prepared command.

free [[connect_name.]connect_id.] command_id]

Frees prepared command command_id on connection connect_id.

If no command is specified, frees the most recent command.

Use prepare to create the prepared command.

functions [object_name_pattern]

Lists, in a single column, the names of PL/SQL functions owned by the current user that match the given pattern. When a name pattern is missing, the pattern defaults to %.

If passthrough is enabled, lists PL/SQL functions matching the pattern in the Oracle database.

See the allfunctions command.

grid stmt

Performs that specified statement on a grid database.

grid monitor [optional_monitor_column]

Formats the contents of the SYS.GV$MONITOR table for easy viewing.

If the optional_monitor_column is specified, only that column is displayed.

This command is not supported in TimesTen Classic.

help [command [command ...]| all | comments | attributes]

Prints brief or detailed help information for commands.

If specific commands are given as arguments then detailed help for each command is printed.

If you do not know the exact name of a command, try typing just a few characters that may be part of the command name. ttIsql searches and displays help for any commands that include the characters.

If all is given as an argument then detailed help for all commands is printed.

If comments is given as an argument then information on using ttIsql comments within scripts is printed.

If attributes is given as an argument then information on the set/show attributes is printed.

If no argument is given then brief help information for all commands is printed.

history [-all] [-h] [-r] [num_commands]

ttIsql implements a csh-like command history.

Lists previously run commands. The num_commands parameter specifies the number of commands to list. If the num_commands parameter is omitted then the previous 10 commands are listed by default.

The output of this command omits consecutive duplicate commands. Use the -all option to include the consecutive duplicate commands.

Use the -h option to omit the command numbers.

Use the -r parameter to list the commands in reverse order.

The history list stores up to 100 of the most recently run commands.

See the savehistory and clearhistorycommand.

host os_command

Runs an operating system command. The command is run in the same console as ttIsql.

This command sets the environment variable TT_CONNSTR in the environment of the process it creates.

The value of the variable is the connection string of the current connection.

To see the exit status of the command, use the define command with _EXIT_STATUS.

if-then-else

The if-then-else command construct enables you to implement conditional branching logic in a ttIsql session. For more details, see Syntax for the IF-THEN-ELSE Command Construct.

indexes [table_name_pattern]

Describes the indexes that it finds on the tables owned by the current user that match the input pattern. When a name pattern is missing, the pattern defaults to %.

If passthrough is enabled, lists indexes on tables matching the pattern in the Oracle database.

See the allindexes command.

monitor [optional_monitor_column]

Formats the contents of the SYS.MONITOR table for easy viewing.

If the optional_monitor_column is specified, only that column is displayed.

packages [object_name_pattern]

Lists, in a single column, the names of PL/SQL packages owned by the current user that match the given pattern. When a name pattern is missing, the pattern defaults to %.

If passthrough is enabled, lists PL/SQL packages matching the pattern in the Oracle database.

See the allpackages command.

prepare [[connid.]command_id]SQL_Statement

Prepares the specified SQL statement. If the command_id argument is not specified the command_id is assigned automatically.

The command_id argument can take a value between 0 and 255 inclusive. If connid is specified, switches to the given connection ID. The connid must be only alphanumeric characters and are case insensitive.

Use free to release the prepared command.

print [variable]

Prints the value of the specified bind variable or all variables if no variable is specified. If the variable is a REF CURSOR, then the results are fetched and printed.

procedures [procedure_name_ pattern]

Lists, in a single column, the names of PL/SQL procedures owned by the current user that match the given pattern. When a name pattern is missing, the pattern defaults to %.

If passthrough is enabled, lists PL/SQL procedures matching the pattern in the Oracle database.

See the builtins and allprocedures commands.

quit

Exits ttIsql.

remark msg

Specifies that the message on the line should be treated as a comment. When rem or remark is the first word on the line, ttIsql reads the line and ignores it.

repschemes [[scheme_owner_pattern.] scheme_name_pattern]

Reports information on replication schemes defined in the currently connected data source. This information describes all elements associated with the replication schemes.

If the optional argument is not specified then information on all replication schemes defined in the current data source is reported.

retryconnect [0|1]

Disables(0) or enables(1) the wait for connection retry feature.

If the connection retry feature is enabled then connection attempts to a data source that initially fail due to a temporary situation are retried until the connection attempt succeeds. For example, if data source recovery is in progress when attempting to connect, the connection retry feature causes the connect command to continue to attempt a connection until the recovery process is complete.

If the optional argument is omitted then the connection retry feature is enabled by default.

rollback

Rolls back the current transaction. AutoCommit must be off. This command does not stop TimesTen Cache operations on the Oracle database, including passthrough statements, flushing, manual loading, manual refreshing, synchronous writethrough, propagating and dynamic loading.

rpad varname desiredlength paddingstring

The RPAD command acts like the SQL function RPAD()with some limitations:

  • The desired length is in bytes, not characters.

  • The padding string is not expanded for string literal escapes, such as unicode escapes.

  • The padding string can contain partial unicode characters or full unicode characters and it may split the padding string in the middle of a multibyte character or surrogate pair.

Only variables that are character based (CHAR, VARCHAR) can be padded with the RPAD command.

run filename [arguments]|

start filename [arguments...]|

@@ filename [arguments...]|

@ filename [arguments...]

Reads and runs SQL commands from filename. The run command can be nested up to five levels.

The @@ command is identical to the @ command only if the file is specified with an absolute path.

When you specify @ with a relative path, the path is relative to the startup directory of ttIsql. When you specify @@, the path is relative to the currently running input file. Therefore @@ is useful when used in a script that must call other scripts. It does not matter what directory the invoker of ttIsql is in when the script is run.

See Example Parameters of Command String Substitution for a description of arguments.

savehistory

[-all [-h] [-a | -f] outputfile

Writes the history buffer to the specified outputfile.

Consecutive duplicate commands are omitted.

Use the -all option to include the consecutive duplicate commands.

Use the -h option to omit the command numbers.

Use -a to append to an existing output file. Use -f to force the overwriting of an existing output file.

See the clearhistory and history commands.

sequences [sequence_name_pattern]

Lists, in a single column, the names of sequences owned by the current user that match the given pattern. When a name pattern is missing, the pattern defaults to %.

If passthrough is enabled, lists sequences on tables matching the pattern in the Oracle database.

See the allsequences command.

set attribute [value]

Sets the specified set/show attribute to the specified value.

If no value is specified, displays the current value of the specified attribute.

For a description of accepted attributes, see Set/Show Attributes.

setjoinorder tblNames [...]

Specifies the join order for the optimizer. AutoCommit must be off.

setuseindex index_name,correlation_name,

{0 | 1} [;...]

Sets the index hint for the query optimizer.

setvariable variable_name := value

Sets the value of a scalar bind variable or an element of an array bind variable. For example: setvariable myvar := 'TimesTen'; There must be a space on either side of the assignment operator (:=).

For more information, see Declaring and Setting Bind Variables in Oracle TimesTen In-Memory Database Operations Guide.

show {all | attribute}

Displays the value for the specified set/show attribute or displays all the attributes.

For a description of accepted attributes, see Set/Show Attributes.

showjoinorder {0 | 1}

Enables or disables the storing of join orders.

0 - Disables the storing of join orders

1 - Enables the storing of join orders.

Call the ttoptshowjoinorder built-in procedure explicitly to display the join order after SELECT, UPDATE, DELETE or MERGE SQL statements.

sleep [n] [ms]

Suspends operation for n seconds or n milliseconds, if the unit ms is included. If n is not specified, then operation is suspended for 1 second.

sleep;
sleep 60;
sleep 500 ms;

spool filename [option | OFF]

Writes a copy of the terminal output to the file filename.

If you do not provide an extension to filename, the file name has the extension .lst. The available options include:

CREATE - Creates a new file.

APPEND - Appends output to an existing file.

REPLACE (default) - Overwrites an existing file.

When you specify the value OFF, the spooling behavior is terminated and the output file is closed.

If you specify a spool command while one is running, the active spool is closed and a new files is opened.

sqlcolumns [owner_name_pattern.]table_name_pattern

Prints results of an ODBC call to SQLColumns.

sqlgetinfo infotype

Prints results of an ODBC call to SQLGetInfo.

sqlstatistics [[owner_name_pattern.]table_name_pattern]

Prints results of an ODBC call to SQLStatistics.

sqltables[[owner_name_pattern.]table_name_pattern]

Prints results of a call to SQLTables. The pattern is a string containing an underscore ( _ ) to match any single character or a percent sign (%) to match zero or more characters.

statsclear [[owner_name.]table_name]

Clears statistics for specified table (or all tables if no table is specified).

statsestimate [[owner_name.]table_name] {n rows | p percent}

Estimates statistics for specified table (or all tables if no table is specified).

If you estimate statistics with an empty table list, statistics on system tables are updated also, if you have privileges to update the system tables.

statsupdate [[owner_name_pattern.] table_name_pattern]

Updates statistics for specified table (or all tables if no table is specified).

If tblName is an empty string, statistics are estimated for all the current user's tables in the database.

synonyms [[schema_pattern.] object_pattern]]

Lists, in a single column, the names of synonyms owned by the current user that match the given pattern. When a name pattern is missing, the pattern defaults to %.

If passthrough to an Oracle database is enabled, lists synonyms on tables matching the pattern in the Oracle database.

See the allsynonyms command.

tables [table_name_pattern]]

Lists, in a single column, the names of tables owned by the current user that match the given pattern. When a name pattern is missing, the pattern defaults to %.

If passthrough to an Oracle database is enabled, lists tables matching the pattern in the Oracle database.

See the alltables command.

tablesize [[owner_name_pattern.] table_name_pattern]]

For each table that matches the pattern, lists the contents of the ALL_TAB_SIZES view.

See the ttComputeTabSizes built-in procedure.

undefine name

Undefines a string substitution alias.

unsetjoinorder

Clears join order advice to optimizer. AutoCommit must be off.

unsetuseindex

Clears the index hint for the query optimizer.

use [conn_id]

Displays the list of current connections and their IDs. If connid is specified, switches to the given connection ID.

To use the name of the first connection, you can specify con0 for the conn_id, rather than specifying the full original connection name. You cannot explicitly name a connection con0. If the first connection is disconnected, con0 refers to the connection none.

If use fails to locate the connection id, the current connection is set to the reserved connection named "none."

See the connect command.

variable [variable_name [data_type] [:= value]]

The syntax for binding multiple values to an array using the variable command is as follows:

variable array_name 
'[' array_size ']'
 data_type(n):= 
'[' value1, ... valuex ']'

Declares a bind variable that can be referenced in a statement or displays the definition of the variable if the type is missing. Type can be one of the following: (n), NUMBER, CHAR(n), NCHAR(n), VARCHAR2(n), NVARCHAR2(n), BLOB, CLOB, NCLOB, or REFCURSOR. If only (n) is supplied, it is assumed to be VARCHAR2 (n).

Assigns a value to a single variable or multiple values if the data type is an array. You can assign a value later with the setvariable command.

For more information, see Declaring and Setting Bind Variables in Oracle TimesTen In-Memory Database Operations Guide.

version

Reports version information.

views [table_name_pattern]

Lists, in a single column, the names of views owned by the current user that match the given pattern. When a name pattern is missing, the pattern defaults to "%".

If passthrough to an Oracle database is enabled, lists views matching the pattern in the Oracle database.

See the allviews command.

waitfor expected_result timeoutseconds sqlstatement

Runs the given statement once a second until the query returns the expected result or a timeout occurs. The query must have only one column and must return exactly one row. Any errors in the query terminate the loop.

waitforresult expected_result timeoutseconds searchrow searchcol sqlstatement

Similar to the waitfor command, except that the result can have 1 or more columns. Also, the result can return 0 rows.

Runs the given statement once a second until the query returns the expected result or a timeout occurs. The searchrow and searchcol arguments indicate the ordinal position (1..N) of which row or column should be considered. Use '*' in searchrow or searchcol to indicate any row or column of the result set could have the expected value. See the waitfor command.

whenever sqlerror

Provide direction on how to handle errors when in ttIsql. For more details, see Syntax for the WHENEVER SQLERROR Command.

xlabookmarkdelete id

Deletes a persistent XLA bookmark.

If a bookmark to delete is not specified then the status of all current XLA bookmarks is reported.

Also see ttXlaDeleteBookmark in Oracle TimesTen In-Memory Database C Developer's Guide.

Requires ADMIN privilege or object ownership.

Syntax for the IF-THEN-ELSE Command Construct

This section provides the syntax for the IF-THEN-ELSE construct. For more details on using the IF-THEN-ELSE command construct, see Conditional Control with the IF-THEN-ELSE Command Construct in the Oracle TimesTen In-Memory Database Operations Guide.

IF [NOT] 
   { Literal1 | :BindVariable1 } 
   { =  | IN } 
   { Literal2 | :BindVariable2 | SelectStatement } 
 THEN "ThenCommands" 
 [ ELSE "ElseCommands" ] ;

The ttIsql IF-THEN-ELSE command has the parameters:

Parameter Description

IF

The IF command must end in a semicolon (;).

The IF command fails if improper syntax is given, the BindVariables do not exist or the SELECT statement fails to run or does not return just a single column.

NOT

Using NOT reverses the desired result of the condition.

Literal1, Literal2

A value that can be part of a comparison.

BindVariable1, BindVariable2

A bind variable is equivalent to a parameter. You can use the :BindVariable1 notation for passing bind variables into this construct. The variable can be created and set using the variable or setvariable ttIsql commands.

= | IN

You can use the IN operator only with the SelectStatement. You can use the IN operator with zero or more returned rows. You can use the equal (=) operator only with a single returned row.

SelectStatement

A provided SELECT statement must start with SELECT. The SELECT statement can return only one column. In addition, it can return only one row when the equal (=) operator is provided.

The SelectStatement is not available if you are not connected to the database.

ThenCommands, ElseCommands

All commands in the THEN or ELSE clauses must be delimited by a semicolon and cannot contain embedded double quotes. These clauses can conditionally run ttIsql commands, such as host or run, which cannot be run through PL/SQL. You can use the CALL statement within the THEN or ELSE clauses. You cannot use PL/SQL blocks.

Restrictions for the IF-THEN-ELSE construct are as follows:

  • You cannot compare variables of the LOB data type.

  • The values are compared case-sensitive with strcmp. A character padded value might not match a VARCHAR2 because of the padding.

Syntax for the WHENEVER SQLERROR Command

Run the WHENEVER SQLERROR command to prescribe what to do when a SQL error occurs. For more details and examples on how to use the WHENEVER SQLERROR command, see Error Recovery with WHENEVER SQLERROR command in the Oracle TimesTen In-Memory Database Operations Guide.

WHENEVER SQLERROR { ExitClause | ContinueClause | SUPPRESS |
     SLEEP Number | ExecuteClause }

When you specify EXIT, always exit ttIsql if an error occurs. ExitClause is as follows:

EXIT [ SUCCESS | FAILURE | WARNING | Number | :BindVariable ]
 [ COMMIT | COMMIT ALL | ROLLBACK ]

When you specify CONTINUE, ttIsql continues to the next command, even if an error occurs. ContinueClause is as follows:

CONTINUE [ COMMIT | COMMIT ALL | ROLLBACK | NONE ]

Run specified commands before continuing. ExecuteClause is as follows:

EXECUTE "Cmd1;Cmd2;...;"

The WHENEVER SQLERROR command options are as follows:

  • EXIT: Always exit ttIsql if an error occurs. Specify what is performed before ttIsql exits with one of the following. SUCCESS is the default option for EXIT.

    • SUCCESS or FAILURE or WARNING: Return SUCCESS (value 0), FAILURE (value 1), or WARNING (value 2) to the operating system after ttIsql exits for any SQL error.

    • Number: Specify a number from 0 to 255 that is returned to the operating system as a return code. Once ttIsql exits, you can retrieve the error return code with the appropriate operating system commands. For example, use echo $status in the C shell (csh) or echo $? in the Bourne shell (sh) to display the return code.

      The return code can be retrieved and processed within batch command files to programmatically detect and respond to unexpected events.

    • :BindVariable: Returns the value in a bind variable that was previously created in ttIsql with the variable command. The value of the variable at the time of the error is returned to the operating system in the same manner as the Number option.

      Note:

      The bind variable used within the WHENEVER SQLERROR command cannot be defined as a LOB, REFCURSOR, or any array data type.

    In addition, you can specify whether to commit or rollback all changes before exiting ttIsql.

    • COMMIT: Runs a COMMIT and saves changes only in the current connection before exiting. The other connections exit with the normal disconnect processing, which rolls back any uncommitted changes.

    • COMMIT ALL: Runs a COMMIT and saves changes in all connections before exiting.

    • ROLLBACK: Before exiting, runs a ROLLBACK and abandons changes in the current connection and, by default, in all other connections. The other connections exit with the normal disconnect processing, which automatically rolls back any uncommitted changes.

  • CONTINUE: Do not exit if an error occurs. The SQL error is displayed, but the error does not cause ttIsql to exit. The following options enable you to specify what is done before continuing to the next ttIsql command:

    • NONE: This is the default. Take no action before continuing.

    • COMMIT: Runs a COMMIT and saves changes in the current connection before continuing.

    • COMMIT ALL: Runs a COMMIT and saves changes in all connections before continuing.

    • ROLLBACK: Before continuing, runs a ROLLBACK and abandons changes in the current connection and, by default, in all other connections. The other connections exit with the normal disconnect processing, which automatically rolls back any uncommitted changes.

  • SUPPRESS: Do not show any error messages and continue.

  • SLEEP: Sleep for a specified number of seconds before continuing.

  • EXECUTE: Run specified commands before continuing. Each command is separated from the other commands by a semicolon (;). If any command triggers additional errors, those errors may cause additional actions that could potentially result in a looping condition.

Set/Show Attributes

Also see the list of ttIsql Commands. Some commands appear here as attributes of the set command. In that case, you can use them with or without the set command.

Boolean attributes can accept the values "ON" and "OFF" or "1" and "0".

The ttIsql set command has the attributes:

Attribute Description

all

With show command only. Displays the setting of all the ttIsql commands.

autocommit [1|0]

Turns AutoCommit off and on. If no argument is given, displays the current setting.

autovariables [1|0]

Turns autovariables off and on. TimesTen creates an automatic bind variable with the same name as each column in the last fetched row. You can use an automatic bind variable in the same manner of any bind variable. For more information, see Automatically Creating Bind Variables for Retrieved Columns in the Oracle TimesTen In-Memory Database Operations Guide.

columnlabels [0 | 1]

Turns the columnlabels feature off (0) or on (1).

If no argument is specified, the current value of columnlabels is displayed.

The initial value of columnlabels is off (0) after connecting to a data source.

When the value is on (1), the column names are displayed before the SQL results.

You can also enable this attribute without specifying the set command.

connstr

Prints the connection string returned from the driver from the SQLDriverConnect call. This is the same string printed when ttIsql successfully connects to a database.

define [&|c|on|off]

Sets the character used to prefix substitution variables to c.

ON or OFF controls whether ttIsql scans commands for substitution variables and replaces them with their values. ON changes the value of c back to the default &. (It does not change it to the most recently used character.)

Default value for ttIsql is OFF (no variable substitution). See Example Parameters Using "variable" and "print" for an explanation of the default.

dynamicloadenable [1|0]

Enables or disables dynamic load of data from an Oracle database to a TimesTen dynamic cache group. By default, dynamic load of data from an Oracle database is enabled.

echo [on | off]

With the set command, prints the commands listed in a run, @ or @@ script to the terminal as they are run

If off, the output of the commands is printed but the commands themselves are not printed.

editline [0 | 1]

Turns the editline function off and on. By default, editline is on.

If editline is turned off, the backspace character deletes full characters, but the rest of editline capabilities are unavailable.

err | error |errors [objecttype [schema.]name]

With the show command, displays error information about the given PL/SQL object.If no object type or object name is supplied, ttIsql assumes the PL/SQL object that you last attempted to create and retrieves the errors for that object. If no errors associated with the given object are found, or there was no previous PL/SQL DDL, then ttIsql displays "No errors."

feedback [on | off] rows

Controls the display of status messages after running the statement.

When rows is specified, if the statement affected more than the specified number of rows, then the feedback indicates the number of affected rows. If the number of rows affected is less than the specified threshold, the number of rows is not printed. Feedback is not provided for tables, views, sequences, materialized views or indexes. It is available for PL/SQL objects.

isolation [{READ_COMMITTED | 1}| {SERIALIZABLE | 0}]

Sets isolation level. If no argument is supplied, displays the current value.

You can also enable this attribute without specifying the set command.

loboffset n

Specifies the offset into the LOB that ttIsql should use as the starting point when it prints the resulting value of a LOB. For example if the value of the LOB is ABCEDFG, and the offset is 4, ttIsql prints DEFG, skipping the first 3 bytes.

The behavior is the same as LOBOFFSET in SQL*Plus.

long n

Reports or controls the maximum number of characters for CLOB or BLOB data or the maximum number of bytes for BLOB data that are displayed when fetched or printed.

The default value is 80.

The command setting is valid for all connections in a session.

longchunksize n

Specifies the size of the chunk that ttIsql uses to get LOB data.

multipleconnections [1 | ON] mc [1 | ON]

Reports or enables handling of multiple connections.By default, ttIsql enables the user to have one open connection at a time.

If the argument 1 or ON is specified the prompt is changed to include the current connection and all multiple connection features are enabled.

If no value is supplied, the command displays the value of the multipleconnections setting.

You can also enable this attribute without specifying the set command.

ncharencoding [encoding]

Specifies the character encoding method for NCHAR output. Valid values are LOCALE or ASCII.

LOCALE sets the output format to the locale-based setting.

If no value is specified, TimesTen uses the system's native language characters.

You can also enable this attribute without specifying the set command.

nulldisplaystring "string"

Sets or shows the string to be displayed when the NULL value appears in a result set.

The option does not affect the SQL user, only the display of NULL in results sets.

optfirstrow [1|0]

Enables or disables First Row Optimization.

If the optional argument is omitted, First Row Optimization is enabled.

You can also enable this attribute without specifying the set command.

optprofile

Prints the current optimizer flag settings and join order.

This attribute cannot be used with the set command.

passthrough [0|1|2|3]

Sets the cache passthrough level for the current transaction. Because AutoCommit must be off to run this command, ttIsql temporarily turns off AutoCommit when setting the passthrough level.

0 - SQL statements are run only against TimesTen.

1 - Statements other than INSERT, DELETE or UPDATE and DDL are passed through if they generate a syntax error in TimesTen or if one or more tables referenced within the statement are not in TimesTen. All INSERT, DELETE and UPDATE statements are passed through if the target table cannot be found in TimesTen. DDL statements are not passed through.

2 - Same as 1, plus any INSERT, UPDATE and DELETE statement performed on READONLY cache group tables is passed through.

3 - All SQL statements, except COMMIT and ROLLBACK, and TimesTen built-in procedures that set or get optimizer flags are passed through. COMMIT and ROLLBACK are run on both TimesTen and the Oracle database.

If no optional argument is supplied, the current setting is displayed.

After the transaction, the passthrough value is reset to the value defined in the connection string or in the DSN or the default setting if no value was supplied to either.

You can also enable this attribute without specifying the set command.

Note: Some Oracle objects may not be described by ttIsql.

prefetchcount [prefetch_count_size]

Sets the prefetch count size for the current connection. If the optional argument is omitted, the current prefetch count size is reported. Setting the prefetch count size can improve result set fetch performance. The prefetch_count_size argument can take an integer value between 0 and 128 inclusive.

When you set the prefetch count to 0, TimesTen uses a default prefetch count. The default prefetch value is isolation level specific. In read committed isolation mode, the default value is 5. In serializable isolation mode, the default value is 128.

You can also enable this attribute without specifying the set command.

prompt [string]

Replaces the Command> prompt with the specified string.

To specify a prompt with spaces, you must quote the string. The leading and trailing quotes are removed.

A prompt can have a string format specifier (%c) embedded. The %c is expanded with the name of the current connection.

querythreshold [seconds]

With the show command, displays the value of the Query Threshold first connection attribute.

With the set command, modifies the value of the QueryThreshold first connection attribute that was set in the connection string or odbc.ini file.

Specify a value in seconds that indicates the number of seconds that a query can run before TimesTen writes a warning to the daemon log.

rowdelimiters [0|off] | [ {1|on} [begin [end [sep]]]]

Controls the row delimiters in result sets. When on, user queries have the row delimited with < and > unless begin and end are specified. If end is not specified, it is set to the same value as begin. If sep is not specified, then a default of "," applies. Not all result sets are affected by this control.

The default is on.

serveroutput [on | off]

With the set command set to on, after each run SQL statement, displays any available output. This output is available for debugging I/O purposes, if the PL/SQL DBMS_OUTPUT package is set to store the output so that it can be retrieved using this command.

The default is off, (no server output is displayed) as performance may be slower when using this command. If you set serveroutput to on, TimesTen uses an unlimited buffer size.

DBMS_OUTPUT.ENABLE is per connection, therefore set serveroutput on affects the current connection only.

This command is not supported in passthrough mode.

showcurrenttime [1|true|on] | [0|false|off]

Enable or disable printing of the current wall clock time.

showplan [0 | 1]

Enables (1) or disables (0) the display of plans for selects/updates/deletes in this transaction. If the argument is omitted, the display of plans is enabled. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

sqlquerytimeout [seconds]

Specifies the number of seconds to wait for a SQL statement to run before returning to the application for all subsequent calls.

If no time or 0 seconds is specified, displays the current timeout value.

The value of seconds must be equal to or greater than 0.This attribute does not stop cache operations on the Oracle database, including passthrough statements, flushing, manual loading, manual refreshing, synchronous writethrough, propagating, and dynamic loading.

You can also enable this attribute without specifying the set command.

See Choose SQL and PL/SQL Timeout Values in Oracle TimesTen In-Memory Database Operations Guide for information about the relationship between the client timeout, SQL timeout, and PL/SQL timeout.

timing [1|0]

Enables or disables printing of query timing.

You can also enable this attribute without specifying the set command.

tryhash [1|0]

Enables or disables use of hash indexes by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

trymaterialize [1|0]

Enables or disables materialization by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

trymergejoin [1|0]

Enables or disables use of merge joins by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

trynestedloopjoin [1|0]

Enables or disables use of nested loop joins by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

tryrowid [1|0]

Enables or disables rowID scan hint by the optimizer at the transaction level.

tryrowlocks [1|0]

Enables or disables use of row-level locking by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

tryserial [1|0]

Enables or disables use of serial scans by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

trytmphash [1|0]

Enables or disables use of temporary hashes by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

trytbllocks [1|0]

Enables or disables use of table-level locking by the optimizer at the transaction level. AutoCommit must be off.

You can also set this attribute without specifying the set command.

trytmptable [1|0]

Enables or disables use of temporary tables by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

trytmprange [1|0]

Enables or disables use of temporary range indexes by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

tryrange [1|0]

Enables or disables use of range indexes by the optimizer at the transaction level. AutoCommit must be off.

You can also enable this attribute without specifying the set command.

verbosity [level]

Changes the verbosity level. The verbosity level argument can be an integer value of 0, 1, 2, 3 or 4. If the optional argument is omitted then the current verbosity level is reported.

You can also enable this attribute without specifying the set command.

vertical [{0 | off} | {1 | on} | statement]

Sets or displays the current value of the vertical setting. The default value is 0 (off).

If statement is supplied, the command temporarily turns vertical on for the given statement. This form is only useful when the vertical flag is off.

The vertical setting controls the display format of result sets. When set, the result sets are displayed in a vertical format where each column is on a separate line and is displayed with a column label.

You can also enable this attribute without specifying the set command.

Comment Syntax

The types of comment markers are:

-- [comment_text]
/* [comment_text] */

The C-style comments, delineated by "/*" at the beginning and "*/" at the end, can span multiple lines.

The comments delimited by the

-

character should not span multiple lines. If a comment marker is encountered while processing a line, ttIsql ignores the remainder of the line.

'--' at the beginning of a line is considered a SQL comment. The line is considered a comment and no part of the line is included in the processing of the SQL statement. A line that begins with '--+' is interpreted as a segment of a SQL statement.

The comment markers can work in the middle of a line.

Example:

monitor; /*this is a comment after a ttIsql command*/

Command Shortcuts

By default, ttIsql supports keystroke shortcuts when entering commands. To turn this feature off, use:

Command> set editline=0;

The ttIsql keystroke shortcuts are:

Keystroke Action

Left Arrow

Moves the insertion point left (back).

Right Arrow

Moves the insertion point right (forward).

Up Arrow

Scroll to the command before the one being displayed. Places the cursor at the end of the line.

If the command being added to the history is identical to the most recently added command, it is skipped.

Up Arrow <RETURN>

Scrolls to the PL/SQL block before the one being displayed.

Down Arrow

Scrolls to a more recent command history item and puts the cursor at the end of the line.

If the command being added to the history is identical to the most recently added command, it is skipped.

Down Arrow <RETURN>

Scrolls to the next PL/SQL block after the one being displayed.

Ctrl-A

Moves the insertion point to the beginning of the line.

Ctrl-E

Moves the insertion point to the end of the line.

Ctrl-K

"Kill" - Saves and erases the characters on the command line from the current position to the end of the line.

Ctrl-Y

"Yank"- Restores the characters previously saved and inserts them at the current insertion point.

Ctrl-F

Forward character - move forward one character. (See Right Arrow.)

Ctrl-B

Backward character - moved back one character. (See Left Arrow.)

Ctrl-P

Previous history. (See Up Arrow.)

Ctrl-N

Next history. (See Down Arrow.)

Parameters

With dynamic parameters, you are prompted for input for each parameter on a separate line. Values for parameters are specified the same way literals are specified in SQL.

SQL_TIMESTAMP columns can be added using dynamic parameters. (For example, values like '1998-09-08 12:1212').

Parameter values must be terminated with a semicolon character.

The possible types of values that can be entered are:

  • Numeric literals. Example: 1234.5

  • Time, date or timestamp literals within single quotation marks. Examples:

    '12:30:00''2000-10-29''2000-10-29 12:30:00''2000-10-29 12:30:00.123456'
    
  • Unicode string literals within single quotation marks preceded by 'N'. Example: N'abc'

  • A NULL value. Example: NULL

  • The '*' character that indicates that the parameter input process should be stopped. Example: *

  • The '?' character prints the parameter input help information. Example: ?

Examples

Example Parameters of Command String Substitution

Command> select * from dual where :a > 100 and :b < 100;
Type '?' for help on entering parameter values.
Type '*' to end prompting and abort the command.
Type '-' to leave the parameter unbound.
Type '/;' to leave the remaining parameters unbound and execute the command.

Enter Parameter 1 'A' (NUMBER) > 110
Enter Parameter 2 'B' (NUMBER) > 99
< X >
1 row found.
Command> var a number;
         exec :a := 110;

PL/SQL procedure successfully completed.

Command> print a
A                    : 110
Command> var b number;
         exec :b := 99;

PL/SQL procedure successfully completed.

Command> select * from dual where :a > 100 and :b < 100;
< X >
1 row found.
Command> print
A                    : 110
B                    : 99
Command> select * from dual where :a > 100 and :b < 100 and :c > 0;
Enter Parameter 3 'C' (NUMBER) > 1
< X >
1 row found.

Default Options

You can set the default command-line options by exporting an environment variable called TTISQL. The value of the TTISQL environment variable is a string with the same syntax requirements as the TTISQL command line. If the same option is present in the TTISQL environment variable and the command line then the command line version always takes precedence.

Examples

Execute commands from ttIsql.inp.

% ttIsql -f ttIsql.inp

Enable all output. Connect to DSN RunData and create the database if it does not exist.

% ttIsql -v 4 -connStr "DSN=RunData;AutoCreate=1"

Print the interactive commands.

% ttIsql -helpcmds

Print the full help text.

% ttIsql -helpfull

Display the setting for all ttIsql set/show attributes:

Command> show all; 
Connection independent attribute values: 

autoprint = 0 (OFF)
columnlabels = 0 (OFF)
define = 0 (OFF)
echo 1 (ON)
FEEDBACK ON
multipleconnections =0 (OFF)
ncharencoding = LOCALE (US7ASCII)
prompt = 'COMMAND>'
timing = 0 (OFF)
verbosity = 2
vertrical = 0 (OFF)

Connection specific attribute values:

autocommit = 1 (ON)
Client timeout = 0
Connection String DSN=repdb1_1121;UID=timesten; DataStore=/DS/repdb1_1121;
 DatabaseCharacterSet=AL32UTF8; ConnectionCharacterSet=US7ASCII;
 DRIVER=/sw/tthome/install/lib/libtten.so; PermSize=20;TempSize=20; 
No errors.
isolation = READ_COMMITTED
Prefetch count = 5
Query threshold = 0 seconds (no threshold)
Query timeout = 0 seconds (no timeout)
serveroutput OFF

Current Optimizer Settings:
    Scan: 1
    Hash: 1
    Range: 1
    TmpHash: 1
    TmpTable: 1
    NestedLoop: 1
    MergeJoin: 1
    GenPlan: 0
    TblLock: 1
    RowLock: 1
    Rowid: 1
    FirstRow: 1
    IndexedOr: 1
    PassThrough: 0
    BranchAndBound: 1
    ForceCompile: 0
    CrViewSemCheck: 1
    ShowJoinOrder: 0
    CrViewSemCheck: 1
    UserBoyerMooreStringSearch: 0
    DynamicLoadEnable: 1
    DynamicLoadErrorMode: 0
    NoRemRowIdOpt: 0

Current Join Order:
    <>

Command

Prepare and execute an SQL statement.

% ttIsql -connStr "DSN=RunData"
ttIsql (c) 1996-2011, TimesTen, Inc. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
(Default setting AutoCommit=1)
Command> prepare 1 SELECT * FROM my_table;
         exec 1;
         fetchall;

Example vertical command:

Command> call ttlogholds;
< 0, 265352, Checkpoint , DS.ds0 >
< 0, 265408, Checkpoint , DS.ds1 >
2 rows found.

Command> vertical call ttlogholds;

 HOLDLFN:       0

 HOLDLFO:       265352
 TYPE:          Checkpoint
 DESCRIPTION:   DS.ds0
 HOLDLFN:       0

 HOLDLFO:       265408
 TYPE:          Checkpoint
 DESCRIPTION:   DS.ds1
 2 rows found.

Command>

To create a new user, use single quotes around the password name for an internal user:

% ttIsql -connStr "DSN=RunData"
ttIsql (c) 1996-2000, TimesTen, Inc. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
(Default setting AutoCommit=1)
Command> CREATE USER terry IDENDTIFIED BY `secret';

To delete the XLA bookmark mybookmark, use:

% ttIsql -connStr "DSN=RunData"
ttIsql (c) 1996-2000, TimesTen, Inc. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql. (Default setting
AutoCommit=1) 
Command> xlabookmarkdelete;
XLA Bookmark: mybookmark
 Read Log File:  0
 Read Offset:    268288
 Purge Log File: 0
 Purge Offset:   268288
 PID:            2004
 In Use:         No
1 bookmark found.

Command> xlabookmarkdelete mybookmark;

Command> xlabookmarkdelete;

0 bookmarks found.

To run a SELECT query until the result "X" is returned or until the query times out at 10 seconds, use:

% ttIsql -connStr "DSN=RunData"
ttIsql (c) 1996-2000, TimesTen, Inc. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql. (Default setting
AutoCommit=1) 
Command> waitfor X 10 select * from dual;

Example of Managing XLA Bookmarks

You can use the xlabookmarkdelete command to both check the status of the current XLA bookmarks and delete them. This command requires XLA privilege or object ownership.

For example, when running the XLA application, 'xlaSimple', you can check the bookmark status by entering:

Command> xlabookmarkdelete;

XLA Bookmark: xlaSimple
  Read Log File: 0
  Read Offset: 630000
  Purge Log File: 0
  Purge Offset: 629960
  PID: 2808
  In Use: No
1 bookmark found.

To delete the bookmark xlaSimple, enter:

Command> xlabookmarkdelete xlaSimple;

Example Parameters Using "variable" and "print"

Substitution in ttIsql is modeled after substitution in SQL*Plus. To enable the substitution feature, use set define on or set define substitution_char'. The substitution character when the user specifies 'on' is '&'. It is disabled with 'set define off'. By default, substitution is off. The default is off because the & choice for substitution character conflicts with TimesTen's use of ampersand as the BIT AND operator. When enabled, the alphanumeric identifier following the substitution character is replace by the value assigned to that identifier. When disabled, the expansion is not performed. New definitions can be defined even when substitution is off. You can use the define command to list the definitions ttIsql predefines.

Command> show define
define = 0 (OFF)
Command> define
DEFINE            _PID = "9042" (CHAR)
DEFINE      _O_VERSION = "TimesTen Release 11.2.1.0.0" (CHAR)
Command> select '&_O_VERSION' from dual;
< &_O_VERSION >
1 row found.
Command> set define on
         SELECT '&_O_VERSION' FROM DUAL;
< TimesTen Release 11.2.1.0.0 >
1 row found.

If the value is not defined, ttIsql prompts you for the value. When prompting with only one substitution character specified before the identifier, the identifier is defined only for the life of the one statement. If two substitution characters are used and the value is prompted, it acts as if you have explicitly defined the identifier.

Command> SELECT '&a' FROM DUAL;
Enter value for a> hi
< hi >
1 row found.
Command> define a
symbol a is UNDEFINED
The command failed.
Command> SELECT '&&a' FROM DUAL;
Enter value for a> hi there
< hi there >
1 row found.
Command> define a
DEFINE               a = "hi there" (CHAR)

Additional definitions are created with the define command:

Command> define tblname = sys.dual
         define tblname
DEFINE         tblname = "sys.dual" (CHAR)
Command> select * from &tblname;
< X >
1 row found.

Arguments to the run command are automatically defined to '&1', '&2', ... when you add them to the run or @ (and @@) commands: Given this script:

CREATE TABLE &1 ( a INT PRIMARY KEY, b CHAR(10) );
INSERT INTO &1 VALUES (1, '&2');
INSERT INTO &1 VALUES (2, '&3');SELECT * FROM &1;

Use the script:

Command> SET DEFINE ON
Command> @POPULATE mytable Joe Bob;

CREATE TABLE &1 ( a INT PRIMARY KEY, b CHAR(10) );
INSERT INTO &1 VALUES (1, '&2');
1 row inserted.

INSERT INTO &1 VALUES (2, '&3');
1 row inserted.

SELECT * FROM &1;
< 1, Joe        >
< 2, Bob        >
2 rows found.

This example uses the variable command. It deletes an employee from the employee table. Declare empid and name as variables with the same data types as employee_id and last_name. Delete the row, returning employee_id and last_name into the variables. Verify that the correct row was deleted.

Command> VARIABLE empid NUMBER(6) NOT NULL;
         VARIABLE name VARCHAR2(25) INLINE NOT NULL;
         DELETE FROM employees WHERE last_name='Ernst'
         RETURNING employee_id, last_name INTO :empid,:name;
1 row deleted.
Command> PRINT empid name;
EMPID                : 104
NAME                 : Ernst

Notes

The ttIsql utility supports only generic REF CURSOR variables, not specific REF CURSOR types.

The ttIsql utility command line accepts multiline PL/SQL statements, such as anonymous blocks, that are terminated with the "/" on it's own line. For example:

Command> set serveroutput on
         BEGIN
         dbms_ouput.put_line ('Hi There');
         END;
         /
Hi There

PL/SQL block successfully executed.

Command>

For UTF-8, NCHAR values are converted to UTF-8 encoding and then output.

For ASCII, those NCHAR values that correspond to ASCII characters are output as ASCII. For those NCHAR values outside of the ASCII range, the escaped Unicode format is used. For example:

U+3042 HIRAGANA LETTER A

is output as

Command> SELECT c1 FROM t1;
< a\u3042 >

NCHAR parameters must be entered as ASCII N-quoted literals:

Command> prepare SELECT * FROM t1 WHERE c1 = ?; 
         exec;

Type '?;' for help on entering parameter values. Type '*;' to stop the parameter entry process.

Enter Parameter 1> N'XY';

On Windows, this utility is supported for all TimesTen Data Manager and Client DSNs.