0% found this document useful (0 votes)
1 views128 pages

Interactive SQL

The document is the Interactive SQL Guide for SAP IQ 16.0 SP 10, detailing how to start Interactive SQL, connect to databases, and navigate the user interface. It includes sections on customizing SQL behavior, building and executing queries, and managing result sets. The guide serves as a comprehensive resource for users to effectively utilize Interactive SQL features.

Uploaded by

ad048053
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views128 pages

Interactive SQL

The document is the Interactive SQL Guide for SAP IQ 16.0 SP 10, detailing how to start Interactive SQL, connect to databases, and navigate the user interface. It includes sections on customizing SQL behavior, building and executing queries, and managing result sets. The guide serves as a comprehensive resource for users to effectively utilize Interactive SQL features.

Uploaded by

ad048053
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 128

PUBLIC

SAP IQ 16.0 SP 10
Document Version: 1.0 – 2015-07-07

Interactive SQL Guide


Content

1 Start Interactive SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6


1.1 Starting Interactive SQL from the Windows Start Menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
1.2 Starting Interactive SQL from a Command Prompt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Interactive SQL Command Line Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2 Connect to a Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.1 Connect Using a Connection Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.2 Connect Window Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.3 Connecting Using an ODBC Data Source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.4 Connecting to a Running Database on this Computer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.5 Connecting to a Running Database on Another Computer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
2.6 Connecting to a Logical Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2.7 Starting and Connecting to a Database on this Computer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.8 Starting and Connecting to a Database on Another Computer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.9 Connecting with a Connection String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Connection Parameters for Interactive SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.10 Connecting to the Utility Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36

3 Disconnect from a Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .37

4 User Interface Navigation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .38

5 Keyboard Shortcuts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

6 Customize Interactive SQL Behavior. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41


6.1 Changing the Number of Spaces that are Indented. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .41
6.2 Configuring Clearing of the SQL Statements Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41
6.3 Configuring the Query Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
6.4 Configuring the Execute Statements Button. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.5 Creating a Header or Footer for Printed Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
6.6 Setting Quiet Mode Prerequisites. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .44
6.7 Disabling Warning Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
6.8 Disabling Table Editing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.9 Setting Interactive SQL as the Default Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.10 Configuring Text Completion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

7 Build and Execute Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47


7.1 Using Text Completion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Text Completion Keyboard Shortcuts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

PUBLIC Interactive SQL Guide


2 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Content
7.2 Comments in SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .48
Converting Statements to Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
Removing Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
7.3 Indent SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .50
Adding or Increasing Indentation of SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Removing or Decreasing Indentation of SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.4 Text Editing Keyboard Shortcuts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
7.5 Look Up Tables, Views, Columns, and Procedures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Looking Up Table Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
Looking Up Table Column Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
Looking Up View Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .54
Looking Up View Column Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
Looking Up Procedure Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .55
7.6 Clearing the SQL Statements Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56
7.7 Execute Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Executing All Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
Executing Selected Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Executing Queries One at a Time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .59
7.8 Recall Previously Executed Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Scrolling Through Previously Executed Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60
Use Execution History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
7.9 Executing COMMIT and ROLLBACK Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

8 Result Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65


8.1 Showing Multiple Result Sets (UNIX). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65
8.2 Showing Multiple Result Sets (Windows). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
8.3 Edit Result Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
Editing Table Values in the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
Inserting a New Row into the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
Inserting a New Row Using the INPUT Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
Deleting Rows from the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71
Copying Rows from the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
Copying Columns from the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Copying Cells from the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73
Sorting Columns in the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.4 Generating SQL Statements from Result Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75
8.5 Printing SQL Statements and Result Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

9 Favorites List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
9.1 Showing or Hiding the Favorites Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
9.2 Creating a Connection Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
9.3 Creating a SQL Statements Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .78

Interactive SQL Guide PUBLIC


Content © 2015 SAP SE or an SAP affiliate company. All rights reserved. 3
9.4 Creating a .sql File Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
9.5 Deleting a Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
9.6 Renaming a Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
9.7 Using a Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
9.8 Editing a Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81
9.9 Exporting a Favorites List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
9.10 Importing a Favorites List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
9.11 Creating a Folder in the Favorites Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.12 Adding a Favorite to a Favorites Folder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83
9.13 Removing a Favorite from a Favorites Folder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
9.14 Reordering the Favorites List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

10 Build Queries with the Query Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85


10.1 Creating a SELECT Query Using the Query Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
10.2 Configuring the Query Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

11 View Query Execution Plans. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89


11.1 Starting the Plan Viewer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
11.2 Generating a Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
11.3 Customizing the Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
11.4 Saving a Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91
11.5 Opening a Saved Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
11.6 Printing a Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92
11.7 Customizing the Query Pane in the Plan Viewer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

12 Source Control Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94


12.1 Configuring Interactive SQL to Use Source Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Configuring Source Control Integration on Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
Configuring Source Control Systems with a Command Line Interface. . . . . . . . . . . . . . . . . . . . .95
Exporting Custom Source Control Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .96
Importing Custom Source Control Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
12.2 Opening Source Control Projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
12.3 Checking Out Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
12.4 Checking In Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
12.5 Additional Source Control Actions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

13 Troubleshooting Hints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100


13.1 Only the First Line of a Multiline Statement Is Executed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

14 Appendix: SQL Statements and Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101


14.1 SQL Statements for Interactive SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
CLEAR Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
CONFIGURE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

PUBLIC Interactive SQL Guide


4 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Content
CONNECT Statement [ESQL] [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
DISCONNECT Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
OUTPUT Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107
PARAMETERS Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111
READ Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .112
SET CONNECTION Statement [ESQL] [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
SET OPTION Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116
START DATABASE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117
START ENGINE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119
STOP DATABASE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120
STOP ENGINE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121
14.2 SQL Options for Interactive SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
DEFAULT_ISQL_ENCODING Option [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123
ON_ERROR Option [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
QUERY_PLAN_TEXT_ACCESS Option. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

Interactive SQL Guide PUBLIC


Content © 2015 SAP SE or an SAP affiliate company. All rights reserved. 5
1 Start Interactive SQL

There are several ways to start Interactive SQL.

1.1 Starting Interactive SQL from the Windows Start Menu

Start Interactive SQL from the Windows Start menu.

Procedure

For:

Operating System Action

Windows XP Select Start Programs SAP SAP IQ 16.0 Interactive SQL .

Windows 7 Select Start All Programs SAP SAP IQ 16.0 Interactive SQL .

1.2 Starting Interactive SQL from a Command Prompt

Start Interactive SQL from the Windows or UNIX command prompt.

Context

Note
Interactive SQL does not accept @filename parameters. Exit codes are 0 (success) or nonzero (failure).

Procedure

For:

PUBLIC Interactive SQL Guide


6 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Start Interactive SQL
Table 1:
Operating System Action

UNIX In a command shell, type:

dbisql [ <options> ] [ <dbisql-command> | <command-file> ]

Windows Do one of:


○ In a command shell, type:

dbisql [ <options> ] [ <dbisql-command> | <command-


file> ]

○ Select Start Run and type:

dbisql [ <options> ] [ <dbisql-command> | <command-


file> ]

Note
If the options specified do not include user ID and password, the Connect window opens, allowing you to
enter the required information.

Example
This command runs the command file mycom.sql against the current default server, using the user ID DBA
and the password sql. If there is an error in the command file, the process terminates.

dbisql -c "uid=DBA;pwd=sql" -onerror exit mycom.sql

This command adds user joe to the current default database with the password mypwd:

dbisql -c "uid=DBA;pwd=sql" grant connect to joe identified by mypwd

This command connects to the database on host 10.123.5.789, port 1111. Since the command does not
include logon credentials, the Connect window opens, prompting you to enter the user ID and password.

dbisql -c "host=10.123.5.789:1111"

Related Information

Only the First Line of a Multiline Statement Is Executed [page 100]

Interactive SQL Guide PUBLIC


Start Interactive SQL © 2015 SAP SE or an SAP affiliate company. All rights reserved. 7
1.2.1 Interactive SQL Command Line Options

Specify options when invoking Interactive SQL from a command prompt.

Table 2:

Option Description

-c< "keyword=value; ..."> Specifies connection parameters. If you do not specify this option, the environment
variable SQLCONNECT is used.

Depending on the connection parameters specified, if Interactive SQL cannot con­


nect, an error message appears in the command shell or Interactive SQL starts and
displays an error message or the Connect window opens. If the Connect window
opens, you can adjust the parameters and retry the connection.

Note
Always specify connection parameters for Interactive SQL instead of relying on
defaults to prevent unintended connections. If you start more than one database
on a server, for example, specify the database name, and in a network with sub­
nets, specify the communications protocol parameter with host number.

-d <delimiter> Specifies a command delimiter. Quotation marks around the delimiter are optional,
except when the command shell itself interprets the delimiter in some special way.

Command delimiters are used for all connections in the current Interactive SQL ses­
sion, regardless of the setting stored in the database (for either the user or the PUB­
LIC setting).

-d1 Echoes all statements that Interactive SQL executes to the Command window
(stdout). This feedback might be useful when you are debugging SQL scripts, or
when Interactive SQL is processing a long SQL script.

Note
The final character of the option is the number 1, not a lowercase L.

-datasource <dsn-name> Specifies an ODBC data source to connect to. You need not be using the SAP SQL
Anywhere 16 JDBC driver to use this option. However, if the data source to which you
are connecting is not configured to use TCP/IP, you must use the SAP SQL Any­
where 16 JDBC driver to connect. By default, SAP IQ data sources are configured to
use TCP/IP.

-f <file name> Opens (but does not run) the file called <file name>. You must enclose the file
name in quotes if the file name contains any space characters; otherwise, quotation
marks are optional. If the file does not exist, or if it is a directory instead of a file, In­
teractive SQL prints an error message to the console and quits. If the file name does
not include a full drive and path specification, the file is assumed to be relative to the
current directory.

-host <host name> Specifies the host name or IP address of the computer on which the database server
is running. You can use the name localhost to represent the current machine.

PUBLIC Interactive SQL Guide


8 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Start Interactive SQL
Option Description

-nogui Runs Interactive SQL in a command-prompt mode, without a graphical user inter­
face. This is useful for batch operations. If you specify either <dbisql-command> or
<command-file>, then -nogui is assumed.

In -nogui mode, Interactive SQL sets the program exit code to indicate success or
failure. On Windows operating systems, the environment variable ERRORLEVEL is
set to the program exit code. Exit codes are:

0 success.
1 general failure. At some point, a SQL or Interactive SQL statement did not exe­
cute successfully and the you chose to stop executing SQL statements. Alterna­
tively, Interactive SQL noted an internal error.
5 user terminated Interactive SQL. When an error occurs during execution, you
are prompted to ignore the error, stop, or exit Interactive SQL. If you opt to exit,
the program returns code 5. The program also returns code 5 if an error occurs
and the Interactive SQL option ON_ERROR is set to EXIT.
9 unable to connect.
255 bad command. The command line contained incomplete or invalid switches.

Note
In -nogui mode, any SQL text you enter at the command prompt is executed
when you press Enter, even if you specify a command delimiter using the -d
switch. Ensure the SQL command is complete before you press Enter.

-onerror [CONTINUE | EXIT] Controls what happens if an error is encountered while reading statements from a
command file. This option overrides the ON_ERROR setting. This option is useful
when using Interactive SQL in batch operations.

-port <portnumber> Specifies the port number on which the database server is running. The default port
number for SAP IQ is 2638.

-q Runs in quiet mode, that is, does not display output messages. This option is useful
only if you start Interactive SQL with a command or command file. Specifying this op­
tion does not suppress error messages.

Note
If the data extraction commands (primarily setting the option TEMP_EX­
TRACT_NAME1 to an output file) are contained in a command file, you must ena­
ble the Show all result sets option before using the -q option. See Set­
ting Quiet Mode Prerequisites.

-version Displays the version number of Interactive SQL.

-x Scans commands but does not execute them. You may find this option useful for
checking long command files for syntax errors.

Related Information

Setting Quiet Mode Prerequisites [page 44]

Interactive SQL Guide PUBLIC


Start Interactive SQL © 2015 SAP SE or an SAP affiliate company. All rights reserved. 9
Only the First Line of a Multiline Statement Is Executed [page 100]
Setting Quiet Mode Prerequisites [page 44]

PUBLIC Interactive SQL Guide


10 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Start Interactive SQL
2 Connect to a Database

The Connect window supports several methods of connecting to a database. The settings in this window are
preserved for the current Interactive SQL session only.

Choose SQL Connect or press F11 to open the Connect dialog.

2.1 Connect Using a Connection Favorite

You can use a connection favorite to connect to a database. The favorite stores connection details, including
password.

Procedure

1. If the Connect window appears while you are starting Interactive SQL, click Cancel.
2. In the Favorites list, click the connection link.

Note
○ If the Favorite list is hidden, click Favorites Show Favorites .
○ If Interactive SQL cannot establish a connection, you see an error message.
○ If the favorite is missing connection information, you see the Connect window.

Related Information

Creating a Connection Favorite [page 77]

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 11
2.2 Connect Window Tools

You can manage and test your connection with the Tools button in the Connect window.

Table 3:
Tool Description

Test Connection Tests whether the provided information results in a suc­


cessful connection.

Copy Connection String to Clipboard Creates a connection string from the options you have
specified, and copies the string onto your clipboard.

Save As ODBC Data Source Saves the new data source to your list of ODBC user data
sources.

2.3 Connecting Using an ODBC Data Source

Connect to a database using an ODBC data source.

Procedure

1. From the Authentication list, select one of:

○ Database, and then enter a user ID and case-sensitive password for the connection.
○ Windows Integrated Login. Your Windows user ID and password are supplied to the SAP IQ
integrated login mechanism.
2. In the Action list, select Connect with an ODBC Data Source.
3. Do one of:

○ Select ODBC Data Source name and the name to connect to the database. In Windows, you can click
Browse to view a list of available data sources.
○ Select ODBC Data Source name and click Open The ODBC Data Source Administrator. Select an
ODBC data source from the list of available data sources, create a new data source, or configure an
existing data source.
○ Select ODBC Data Source file and the ODBC data source file name for the connection. File data
sources hold the same information as ODBC data sources that are stored in the registry.

Tip
Information that you enter in the Connect window, such as the user ID or password, is used instead of
any parameters that are stored in an ODBC data source or an ODBC data source file.

4. Click Connect.

PUBLIC Interactive SQL Guide


12 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
Related Information

DatabaseFile (DBF) Connection Parameter [page 22]


DatabaseName (DBN) Connection Parameter [page 24]
DataSourceName (DSN) Connection Parameter [page 26]
FileDataSourceName (FILEDSN) Connection Parameter [page 28]
Password (PWD) Connection Parameter [page 31]
Userid (UID) Connection Parameter [page 35]

2.4 Connecting to a Running Database on this Computer

Connect to a database that is already running on the current computer.

Procedure

1. From the Authentication list, select one of:

○ Database, and then enter a user ID and case-sensitive password for the connection.
○ Windows Integrated Login. Your Windows user ID and password are supplied to the SAP IQ
integrated login mechanism.
2. In the Action list, select Connect to a running database on this computer.
3. In the Server name field, enter the name of the server that you are connecting to, or choose a recently
used server name from the list.
4. In the Database name field, enter the name of the database that you are connectiong to, or choose a
recently used database name from the list.
5. Click Connect.

Related Information

DatabaseName (DBN) Connection Parameter [page 24]


Password (PWD) Connection Parameter [page 31]
ServerName (Server) Connection Parameter [page 32]
Userid (UID) Connection Parameter [page 35]

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 13
2.5 Connecting to a Running Database on Another
Computer

Connect to a database that is already running on another computer.

Procedure

1. From the Authentication list, select one of:

○ Database, and then enter a user ID and case-sensitive password for the connection.
○ Windows Integrated Login. Your Windows user ID and password are supplied to the SAP IQ
integrated login mechanism.
2. In the Action list, select Connect to a running database on another computer.
3. In the Host field, specify the name of the computer where the database is running, or click Recent and
choose a recently used host and port combination.
4. (Optional) Click Ping to verify that a computer with the given host name exists on your network.
5. In the Port field, specify the port your database is using.
6. In the Server name field, enter the name of the server that you are connecting to, or choose a recently
used server name from the list.
7. (Optional) Click Find to see a list of running local and network servers.
8. In the Database name field, enter the name of the database that you are connectiong to, or choose a
recently used database name from the list.
9. Click Connect.

Related Information

Host Connection Parameter [page 29]


Password (PWD) Connection Parameter [page 31]
ServerName (Server) Connection Parameter [page 32]
Userid (UID) Connection Parameter [page 35]

PUBLIC Interactive SQL Guide


14 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
2.6 Connecting to a Logical Server

Connect to a database on a logical server.

Context

The connection fails if the current node is not a member of any logical server that is assigned to the user's
login policy, or if the current login policy assigns:

● SERVER as the logical server, and the user lacks sufficient system privilege.
● NONE as the as logical server.
● COORDINATOR as the logical server, and the user connects to a secondary server without enabling login
redirection.

Procedure

1. From the Authentication list, select one of:

○ Database, and then enter a user ID and case-sensitive password for the connection.
○ Windows Integrated Login. Your Windows user ID and password are supplied to the SAP IQ
integrated login mechanism.
2. In the Action List, select Connect to a logical server.
3. In the Logical server field, select the node type of the logical server.
4. In the Host field, specify the computer name where the logical server is running or click Recent to choose
a recently-used host and port combination.
5. (Optional) Click Ping to verify that a computer with the given host name exists on your network.
6. In the Port field, specify the port number of one of the nodes associated with the logical server.
7. Click Connect.

Related Information

Host Connection Parameter [page 29]


Password (PWD) Connection Parameter [page 31]
Userid (UID) Connection Parameter [page 35]

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 15
2.7 Starting and Connecting to a Database on this
Computer

Start and connect to a database running on the current computer.

Procedure

1. From the Authentication list, select one of:

○ Database, and then enter a user ID and case-sensitive password for the connection.
○ Windows Integrated Login. Your Windows user ID and password are supplied to the SAP IQ
integrated login mechanism.
2. In the Action list, select Start and connect to a database on this computer.
3. In the Database file field, enter the full path and name of the database file, (for example, C:\demo
\sample.db), choose a recently used database file from the list, or click Browse to search for the
database file. If you do not specify a full path, the path used is relative to the working directory of the
database server.
4. In the Encryption key field, if the database file is encrypted, you must supply a key to the database server
every time the database starts.
5. In the Database name field, enter the name of the database that you are starting and connectiong to, or
choose a recently used database name from the list.
6. In the Server name field, enter the name of the server that you are starting and connecting to, or choose a
recently used server name from the list. .
7. (Optional) In the Start line field, enter a command to start the database server on your computer or
choose a recently used start line from the dropdown list.

Use this field to:


○ Employ any advanced server features
○ Control protocol options
○ Provide diagnostic or troubleshooting messages
○ Set permissions
○ Set database parameters (including encryption)
8. (Optional) Select Stop database after last disconnect to automatically shut down the database after the
last user disconnects.
9. Click Connect.

Related Information

AutoStop (ASTOP) Connection Parameter [page 19]


DatabaseFile (DBF) Connection Parameter [page 22]
DatabaseKey (DBKEY) Connection Parameter [page 23]

PUBLIC Interactive SQL Guide


16 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
Password (PWD) Connection Parameter [page 31]
ServerName (Server) Connection Parameter [page 32]
StartLine (START) Connection Parameter [page 33]
Userid (UID) Connection Parameter [page 35]
Connecting to the Utility Database [page 36]

2.8 Starting and Connecting to a Database on Another


Computer

Start and connect to a database on another computer.

Procedure

1. From the Authentication list, select one of:

○ Database, and then enter a user ID and case-sensitive password for the connection.
○ Windows Integrated Login. Your Windows user ID and password are supplied to the SAP IQ
integrated login mechanism.
2. In the Action list, select Start and connect to a database on another computer.
3. In the Database file field, enter the full path and name of the database file, (for example, C:\demo
\sample.db), choose a recently used database file from the list, or click Browse to search for the
database file. If you do not specify a full path, the path used is relative to the working directory of the
database server.
4. In the Encryption key field, if the database file is encrypted, you must supply a key to the database server
every time the database starts.
5. In the Database name field, enter the name of the database that you are starting and connectiong to, or
choose a recently used database name from the list. A database name is optional if you specify a server
name and there is only one database running on the server. Each database running on a server is identified
by a unique database name.
6. In the Server name field, enter the name of the server that you are starting and connecting to, or choose a
recently used server name from the list.
7. (Optional) Click Find to see a list of running local and network servers.
8. In the Host field, specify the name of the computer where the database is running, or click Recent and
choose a recently used host and port combination.
9. (Optional) Click Ping to verify that a computer with the given host name exists on your network.
10. In the Port field, specify the port your database is using.
11. (Optional) Select Stop database after last disconnect to automatically shut down the database after the
last user disconnects.
12. Click Connect.

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 17
Related Information

AutoStop (ASTOP) Connection Parameter [page 19]


DatabaseFile (DBF) Connection Parameter [page 22]
DatabaseKey (DBKEY) Connection Parameter [page 23]
Host Connection Parameter [page 29]
Password (PWD) Connection Parameter [page 31]
ServerName (Server) Connection Parameter [page 32]
Userid (UID) Connection Parameter [page 35]

2.9 Connecting with a Connection String

Connect to a database using a connection string.

Procedure

1. From the Authentication list, select one of:

○ Database, and then enter a user ID and case-sensitive password for the connection.
○ Windows Integrated Login. Your Windows user ID and password are supplied to the SAP IQ
integrated login mechanism.
2. In the Acton dropdown list, select Connect with a connection string.
3. In the Parameters field, enter the required connection parameters. You can use connection parameters
with an ODBC data source or ODBC data source file. Enter the connection parameters in a semicolon
delimited list of parameter=value pairs.

parameter1=value1;parameter2=value2;...

For example:

DSN="SAP IQ 16 Demo"; Server=Sampleserver;

Tip
Any information you enter in the Parameters field, such as the user ID or database name, takes
precedence over the parameters stored in an ODBC data source or an ODBC data source file.

4. Click Connect.

PUBLIC Interactive SQL Guide


18 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
2.9.1 Connection Parameters for Interactive SQL

When no database is connected, you must enter connection parameters, either in the Connect window, or on
the command line, using the -c option. Information you enter in the Connect window is not preserved between
sessions.

To connect to a single database, enter the user ID and password only if the server was started on the local
machine with IQTMP16 environment variable set. If there are multiple databases running on the database
server, you must specify additional connection parameters, such as the server or database name.

2.9.1.1 AutoStop (ASTOP) Connection Parameter

Controls whether a database stops when there are no more open non-HTTP connections.

Syntax

{ AutoStop | ASTOP }={ YES | NO }

Default

YES

Description

By default, any database server that is started from a connection string stops when there are no non-HTTP
connections to it. Also, any database that is loaded from a connection string is unloaded when there are no
more non-HTTP connections to it. This behavior is equivalent to AutoStop=YES.

If a connection uses AutoStop=NO, any database started remains running when there are no more non-HTTP
connections to it. As a result, the database server remains operational as well.

If AutoStop=NO and the only connection to the database is an HTTP connection, the database does not stop
automatically when the HTTP connection disconnects. If AutoStop=NO and a database has an HTTP
connection, and a command sequence or TDS connection, when the last command sequence or TDS
connection disconnects, the database stops, and any HTTP connections are dropped.

The AutoStop (ASTOP) connection parameter is used only if you are connecting to a database that is not
currently running. It is ignored if the database is already started.

If .NET applications use the AutoStop connection parameter with caution. Closing a connection closes it as far
as the application is concerned, but active connections remain open when connection pooling is enabled. As a
result the server does not shut down, even though you may expect it to do so.

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 19
2.9.1.2 CommLinks (LINKS) connection parameter

Specifies client-side network protocol options.

Syntax

{ CommLinks | LINKS }={ [ SharedMemory | SHMEM ] | ALL | [ TCPIP | TCP ] } [, ... ] <string>

Allowed Values

SharedMemory (SHMEM) (default) connect using the shared memory protocol for same-computer
communication. The client tries shared memory first if it is included in a list of protocols specified by the
CommLinks(LINKS) connection parameter, regardless of the order in which protocols appear.
ALL connect using the shared memory protocol first, followed by TCP/IP.
TCPIP (TCP) connect using the TCP/IP communication protocol. TCP/IP is supported on all operating
systems. You can specify additional network protocol options for TCPIP.

Usage

Can be used for connections to a network database server.

Default

SharedMemory (SHMEM)

Description

Note
SAP recommends that you only use the CommLinks (LINKS) connection parameter if you need to specify
TCP/IP protocol options other than HOST or ServerPort (PORT). Otherwise, use the Host connection
parameter.

You cannot specify both CommLinks and Host in a connection string.

When you use the CommLinks (LINKS) connection parameter for a TCP/IP connection, a server name
should be specified using the ServerName (Server) connection parameter.

PUBLIC Interactive SQL Guide


20 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
If you do not specify a Host or a CommLinks (LINKS) connection parameter, the client searches for a database
server on the current computer only, and only using a shared memory connection. This is the default behavior,
and is equivalent to CommLinks=SHMEM. The shared memory protocol is the fastest communication link
between a client and database server running on the same computer, as is typical for applications connecting
to a personal database server.

If you specify both TCPIP and SharedMemory or CommLinks=ALL, then shared memory is attempted first,
followed by TCP/IP if the database server cannot be found over shared memory. For example, in the following
connection string, shared memory is attempted first:

"UID=DBA;PWD=sql;Server=demo;DBN=demo;LINKS=TCPIP,SHMEM"

The TCP/IP communication protocol is enabled on the database server using the -x option.

Example

The following connection string fragment attempts to connect to the database server named iqdemo running
on the current subnet:

CommLinks=tcpip;Server=iqdemo;UID=DBA;PWD=sql;

The following connection string fragment attempts to connect to the database server named iqdemo. It first
attempts to connect over shared memory. If the database server cannot be located using shared memory, it
attempts to connect using TCP/IP.

CommLinks=tcpip,shmem;Server=iqdemo;UID=DBA;PWD=sql

The following connection string attempts to connect to the server named iqdemo running on the host named
kangaroo.

CommLinks=tcpip(HOST=kangaroo);Server=iqdemo;UID=DBA;PWD=sql

Alternatively, you could use the Host connection parameter to connect to the server named iqdemo running
on the host named kangaroo.

Host=kangaroo;Server=iqdemo;UID=DBA;PWD=sql

Related Information

Host Connection Parameter [page 29]


ServerName (Server) Connection Parameter [page 32]

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 21
2.9.1.3 DatabaseFile (DBF) Connection Parameter

Indicates which database file you want to load and connect to when starting a database that is not running.

Syntax

{ DatabaseFile | DBF }=<filename>

Allowed Values

filename specifies the path and file name of a database to start.

If the file name does not include an extension, SAP IQ looks for a file with the .db extension.

The path of the file is relative to the working directory of the database server. If you start the database
server at a command prompt, the working directory is one form which you run the command. If you start
the database server from an icon or shortcut, the working directory is specified by the icon or shortcut. As
a best practice, you should supply a complete path and file name.

UNC file names are supported.

Default

None

Description

If you are unsure whether a database is running, you can use the DatabaseFile (DBF) connection parameter to
start the database and connect to it.

If you specify both the DatabaseFile and DatabaseName (DBN) connection parameters, an attempt is made to
connect to a running database with the specified database name (DatabaseFile is ignored). If that fails, an
attempt is made to start the database automatically using the path indicated by DatabaseFile and assign it the
name specified by DatabaseName.

If you specify DatabaseFile, but not DatabaseName, an attempt is made to connect to a running database with
the same name as the file specified (the path and extension are removed). If that attempt fails, an attempt is
made to start the database automatically using the path indicated by DatabaseFile.

A database cannot be automatically started on a network server unless this behavior is explicitly permitted by
the -gd database server option.

For deployed applications, SAP recommends that you specify a database server name using the ServerName
(Server) parameter when attempting to start a database file automatically if it is not running. Otherwise, the

PUBLIC Interactive SQL Guide


22 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
application might connect to a server other than the one intended. For example, the database server might
connect to a different version of the SAP IQ database server that is part of an embedded application and
already running.

Caution
The database file must be on the same computer as the database server. Starting a database file that is
located on a network drive can lead to file corruption.

Example

The DatabaseFile (DBF) connection parameter in the following example loads and connects to the sample
database, demo.db:

"DBF=%IQDIR16%\demo.db"

The following two examples assume that you have started a database file named cities.db, and renamed the
database Kitchener as follows:

dbeng16 cities.db -n Kitchener

To successfully start and connect to a database and name it Kitchener specify the following DBN and DBF
connection parameter values:

DBN=Kitchener;DBF=cities.db

Related Information

DatabaseName (DBN) Connection Parameter [page 24]

2.9.1.4 DatabaseKey (DBKEY) Connection Parameter

Starts an encrypted database with a connection request.

Syntax

{ DatabaseKey | DBKEY }=<key>

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 23
Allowed Values

key the encryption key is a string, including mixed cases, numbers, letters, and special characters.
Database keys cannot include leading spaces, trailing spaces, or semicolons.

Default

None

Description

You must specify this parameter when you start an encrypted database with a connection request.

To secure communication packets between client applications and the database server, use the -ec server
option and Transport-Layer Security (TLS).

Example

This connection parameter fragment specifies an encryption key to start the iqdemo database.

"UID=DBA;PWD=sql;Server=myeng;DBKEY=V3moj3952B;DBF=%ALLUSERSPROFILE%\SYBASEIQ
\demo\iqdemo.db"

2.9.1.5 DatabaseName (DBN) Connection Parameter

Identifies a running database or assigns a name to a database that is starting.

Syntax

{ DatabaseName | DBN }=<database-name>

Allowed Values

database-name specifies the name of a database that is already running on a database server, or names a
database that is starting.

PUBLIC Interactive SQL Guide


24 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
Default

None

Description

Whenever a database starts, it is assigned a name, either by the administrator by using the -n option, or by the
database server by using the base of the file name with the extension and path removed.

Connect to a Running Database if the database is already running, use the DatabaseName (DBN)
connection parameter. A connection occurs only if the name of the running database matches
<database-name>. To connect to the utility database, use the database name utility_db. To prevent
an attempt to start the database if it is not already running, use DatabaseName rather than DatabaseFile.
Start a Database That Is Not Running if you specify both DatabaseName and DatabaseFile, an attempt is
made to connect to a running database with the specified database name (DatabaseFile is ignored), and if
that fails, an attempt is made to start the database automatically using the path indicated by the
DatabaseFile and assign it the name specified by DatabaseName. DatabaseName is recommended for
naming databases, rather than using the DatabaseSwitches (DBS) connection parameter with the -n
option or the START connection parameter with the -n option.

Example

To start a database named cities.db and name the database Kitchener, use the following connection string:

"DBF=cities.db;DBN=Kitchener;UID=DBA;PWD=sql"

To connect to a running database named Kitchener, use the following connection string:

"DBN=Kitchener;UID=DBA;PWD=sql"

Related Information

DatabaseFile (DBF) Connection Parameter [page 22]

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 25
2.9.1.6 DataSourceName (DSN) Connection Parameter

Tells the ODBC driver manager or embedded SQL library where to look in the registry or the system
information file (named .odbc.ini by default) to find ODBC data source information.

Syntax

{ DataSourceName | DSN }=<data-source-name>

Allowed Values

data-source-name specifies the name of the ODBC data source that contains connection information for
your database.

Default

None

Description

Usually, ODBC applications send only a data source name to ODBC. The ODBC driver manager and ODBC
driver locate the data source, which contains the remainder of the connection parameters.

Example

The following parameter uses a data source name:

DSN=My Database

PUBLIC Interactive SQL Guide


26 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
2.9.1.7 EncryptedPassword (ENP) Connection Parameter

Provides a password, stored in an encrypted format in a data source.

Syntax

{ EncryptedPassword | ENP }=<password-string>

Allowed Values

password-string an encrypted password for the database you are connecting to.

Default

None

Description

Every user of a database has a password. The password must be supplied for the user to connect to the
database.

The EncryptedPassword (ENP) connection parameter is used to specify an encrypted password. An


application may include the encrypted password in the connection string. If both the EncryptedPassword and
Password (PWD) connection parameters are specified0, Password takes precedence.

Caution
When creating a data source, do not include the password as part of the definition as including this
information poses a security risk.

You can encrypt a password that is stored in an ODBC data source by using the -pe option with the Data
Source utility (iqdsn).

On UNIX, data source information is stored in a system information file (which is, by default,
named .odbc.ini).

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 27
Related Information

Password (PWD) Connection Parameter [page 31]

2.9.1.8 FileDataSourceName (FILEDSN) Connection


Parameter

Tells the client library there is an ODBC file data source holding information about the database to which you
want to connect.

Syntax

{ FileDataSourceName | FILEDSN }=<file-data-source-name>

Allowed Values

file-data-source-name specifies the name of the file data source that contains connection information for
your database.

Default

None

Description

File data sources hold the same information as ODBC data sources stored in the registry. You can easily
distribute file data sources to end users, preventing connection information from having to be reconstructed
on each computer. `Both ODBC and Embedded SQL applications can use file data sources.

PUBLIC Interactive SQL Guide


28 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
2.9.1.9 Host Connection Parameter

Accepts a host name or IP address and optional port number that tells the client where to find the database
server.

Syntax

Host={ <hostname> | <ip-address> }[ :<port-number> ] ...

Allowed Values

hostname the name of the computer where the database server is running. The list of host values is a
comma-separated list, which can optionally include a port number (separated by a colon). You can use
localhost to identify the current computer.
ip-address must be specified in the standard form of an IP address and can optionally include a port
number (separated by a colon). The list of IP addresses is a comma-separated list. For IPv6 addresses
that include a port number, you must enclose the address in either square brackets or parentheses. For
example, Host=[fd77:ab34:2238::3894]:8933, where 8933 is the port number.
port-number used by the database server. The default port number is 2638.

Default

None

Description

The Host connection parameter specifies one or more host names (or IP addresses) and optional port
numbers that tell the client where a database server is running.

The Host connection parameter identifies one or more computer systems running database servers.

If a computer system is running more than one database server and you do not specify a port, use the
ServerName connection parameter to identify which database server to connect to. SAP recommends that
you always use the ServerName parameter, particularly for embedded applications.

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 29
Table 4:
Option Description

Specify server and port


host=myhost:1234;
servername=myserver

A connection is made only to a database server listening on


the specified port and with the specified server name.

Specify server, but not port


host=myhost;
servername=myserver

A connection is made to the database server with the speci­


fied server name.

Specify neither server nor port


host=myhost

A connection is attempted to a database server listening on


port 2638.

When multiple addresses are specified, the addresses are attempted in the following order:

1. The specified addresses are checked against the database server address cache (sasrv.ini). If a match
is found, then this address in the database server cache is attempted first.
2. The addresses are attempted in the order in which they are specified.

When you use the Host parameter, no UDP packets are sent if enough information is given to uniquely identify
the server (a host name and a port number). If neither a port number nor database server name is given, the
port number is assumed to be 2638 and the client does not perform a broadcast. However, if the client has a
host name and database server name but no port number, it sends a UDP packet to port 2638 on the specified
host to find the port number.

You cannot specify the LocalOnly protocol option with the HOST protocol option or the Host connection
parameter.

Note
The Host connection parameter disables shared memory. To use the Host connection parameter to
connect to a personal database server, use the -x option to enable the TCP/IP communication protocol on
the database server. Also, you must use the host name localhost when connecting to a personal database
server using TCP/IP.

SAP recommends that you only use the CommLinks (LINKS) connection parameter if you need to specify
TCP/IP protocol options other than HOST or ServerPort (PORT).

You cannot specify both CommLinks and Host in a connection string.

Related Information

CommLinks (LINKS) connection parameter [page 20]


ServerName (Server) Connection Parameter [page 32]

PUBLIC Interactive SQL Guide


30 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
2.9.1.10 Password (PWD) Connection Parameter

Provides a password for a connection.

Syntax

{ Password | PWD }=<password-string>

Allowed Values

password-string passwords have a maximum length of 255 bytes and are case-sensitive. Passwords
cannot include leading spaces, trailing spaces, or semicolons.

Default

None

Description

Every user of a database has a password. The password must be supplied for the user to be allowed to connect
to the database.

The Password (PWD) connection parameter is not encrypted. An application can include the password in the
connection string. If both the Password and the EncryptedPassword (ENP) connection parameters are
specified, Password takes precedence.

Caution
When creating a data source, do not include the password as part of the definition as including this
information poses a security risk.

On UNIX, data source information is stored in a system information file (which is, by default,
named .odbc.ini).

Related Information

EncryptedPassword (ENP) Connection Parameter [page 27]

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 31
2.9.1.11 ServerName (Server) Connection Parameter

Specifies the name of a running database server to which you want to connect.

Syntax

{ ServerName | Server }=<database-server-name-string>

Allowed Values

database-server-name-string

if you are automatically starting a database server, provide a server name.

The server name is interpreted according to the character set of the client computer. Do not use non-
ASCII characters in server names.

Names must be valid identifiers. Database server names cannot:

● Begin with white space, single quotes, or double quotes


● End with white space
● Contain semicolons, forward slashes (/), or backslashes (\)
● Be longer than 250 bytes
● Contain spaces when they are running on UNIX

Long database server names are truncated to different lengths depending on the protocol.

Default

The default local database server.

Description

EngineName and ENG are still accepted, but these variations have been deprecated.

When a database server starts, it attempts to become the default database server on the computer on which it
is installed. The first database server to start when there is no default server becomes the default database
server. Shared memory connection attempts on that computer that do not explicitly specify a database server
name connect to the default server.

ServerName is not needed to connect to the default local database server.

PUBLIC Interactive SQL Guide


32 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
If you use the Host connection parameter, ServerName is not required if both the host name and port are
provided or if there is only one server using the default port.

In the Connect window, the ServerName connection parameter is the Server Name field.

Note
Include the ServerName parameter in connection strings for deployed applications. Doing so ensures that
the application connects to the correct server when a computer is running multiple SAP IQ database
servers, and can help prevent timing-dependent connection failures.

Use the -xd option for database servers being used by deployed applications, and also make user that all
clients use the ServerName parameter to explicitly specify the name of the database server to which they
must connect. Doing so ensures that the application connects to the correct database server when a host is
running multiple SQL Anywhere database servers.

Example

Connect to a server named Guelph:

Server=Guelph

Related Information

Host Connection Parameter [page 29]

2.9.1.12 StartLine (START) Connection Parameter

Starts a local database server running from an application.

Syntax

{ StartLine | START }=<local-database-server-command>

Allowed Values

local-database-server-command by default, SAP IQ attempts to connect to a running database server. If


no server can be found with the specified connection parameters, SAP IQ automatically starts a new local

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 33
database server using the value you enter here. The database server does not automatically start if you
specify the Host connection parameter, or if the CommLinks (LINKS) connection parameter includes
TCPIP.

Usage

Local database servers

Default

None

Description

The StartLine connection parameter starts a database server only if a connection cannot be made to the
specified database server.

For example, suppose you start a database server running a database as follows:

iqsrv16 c:\mydb.db

Connect another database (without using the ServerName connection parameter to specify a database server
name):

dbisql -c "START=iqsrv16 -x none -c 8M;DBN=seconddb;DBF=c:


\myseconddb.db;UID=DBA;PWD=sql"

In this case, the database server is not started. Instead, the database server, which started mydb.db, starts
and connects to myseconddb.db.

However, if you had specified Server=myserver, and a database server named myserver was not running, the
database server myserver would have started.

Note
To specify the database name, database file, or server name, use the DatabaseName (DBN), DatabaseFile
(DBF), and ServerName(Server) connection parameters, rather than specifying the database server
options in the StartLine connection parameter.

This is the recommended syntax:

START=iqsrv16 -c 8M;Server=myserver;DBF=c:\sample.db;DBN=mydb

PUBLIC Interactive SQL Guide


34 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
Related Information

CommLinks (LINKS) connection parameter [page 20]


Host Connection Parameter [page 29]
ServerName (Server) Connection Parameter [page 32]
DatabaseFile (DBF) Connection Parameter [page 22]
DatabaseName (DBN) Connection Parameter [page 24]

2.9.1.13 Userid (UID) Connection Parameter

Specifies the user ID used to log in to the database.

Syntax

{ Userid | UID }=<userid>

Allowed Values

userid user IDs cannot:

● Begin with white space, single quotes, or double quotes


● End with white space
● Contain semicolons

Default

None

Description

You must always supply a user ID when connecting to a database, unless you are using an integrated or
Kerberos login.

Interactive SQL Guide PUBLIC


Connect to a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 35
Example

This connection string fragment supplies the user ID DBA and the password sql:

UID=DBA;PWD=sql

2.10 Connecting to the Utility Database

Connecting to the utility database allows you to execute database file administration statements, query
connection and server properties, and connect to a running database server when user databases are
nonexistent or unavailable.

Prerequisites

The -su database server option specifies the password for the utility database. To connect to a utility
database on a server that was started using the -su option, you need the password that was set by the -su
option.

On a network server, if the -su database server option was not specified, then you cannot connect to the utility
database.

Context

The utility database is a phantom database with no database files or data. When you are connected to the
utility database, executing REVOKE CONNECT FROM DBA disables future connections to the utility database.
No future connections can be made to the utility database unless you use a connection that existed before the
REVOKE CONNECT was done, or restart the database server.

Procedure

1. Select Database from the Authentication list.


2. In the User ID and Password fields, type DBA and SQL respectively.
3. In the Action list, select Connect to a running database on this computer.
4. In the Server name field, enter the name of the server that you are connecting to, or choose a recently
used server name from the list.
5. In the Database Name field, type utility_db.
6. Click Connect.

PUBLIC Interactive SQL Guide


36 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Connect to a Database
3 Disconnect from a Database

When you are finished working, disconnect from the database.

Any uncommitted transactions are rolled back upon disconnecting.

To commit all transactions, select SQL Commit or press Ctrl+Shift+C.

To disconnect, select SQL Disconnect or press F12.

Interactive SQL Guide PUBLIC


Disconnect from a Database © 2015 SAP SE or an SAP affiliate company. All rights reserved. 37
4 User Interface Navigation

The Interactive SQL window is divided into three panes.

SQL Statements pane enter SQL statements in this pane to query and modify your database.
Results pane displays either the results of executed SQL statements, or messages from the database
server about their execution. Click the applicable tab at the bottom of the pane to toggle the display. You
can edit the output in the Results tab, which updates the database.
Favorites pane

(optional) allows you to store frequently used SQL command files in a favorites list that are specific to your
user login. Your favorites list cannot be seen by other users.

Related Information

Build and Execute Queries [page 47]


Result Sets [page 65]
Favorites List [page 77]

PUBLIC Interactive SQL Guide


38 © 2015 SAP SE or an SAP affiliate company. All rights reserved. User Interface Navigation
5 Keyboard Shortcuts

There are many keyboard shortcuts available in Interactive SQL.

These keyboard shortcuts are available regardless of which pane has the focus:

Table 5:
Shortcut Key Description

Alt+F4 Exits Interactive SQL.

Ctrl+A Selects all text in the active pane.

In the Results pane, if the results are not the entire result set, you are prompted to fetch the
remaining rows. Otherwise the currently fetched results are selected.

Ctrl+C Copies the selected text in the active pane to the clipboard.

Ctrl+End Moves to the bottom of the active pane.

Ctrl+H Displays the history of your executed SQL statements.

Ctrl+Home Moves to the top of the active pane.

Ctrl+N Clears the contents of the SQL Statements and Results panes.

Ctrl+P Prints the contents of the SQL Statements or Results pane.

Ctrl+Q Displays the Query Editor.

Ctrl+S Saves the contents of the SQL Statements pane.

Ctrl+Shift+C Executes a COMMIT statement.

Ctrl+Shift+R Executes a ROLLBACK statement.

F5 Executes all text in the SQL Statements pane.

F7 Displays the Lookup Table Name dialog.

F8 Displays the Lookup Procedure Name dialog.

F11 Connect to a database.

F12 Disconnect from a database.

Home Moves the cursor to the start of the current line or to the first word on the current line.

PgDn Moves a page down in the current pane.

PgUp Moves a page up in the current pane.

These keyboard shortcuts are available when the SQL Statements pane has the focus:

Table 6:
Shortcut Key Description

Ctrl+Backspace Deletes the word to the left of the cursor.

Ctrl+Del Deletes the word to the right of the cursor.

Interactive SQL Guide PUBLIC


Keyboard Shortcuts © 2015 SAP SE or an SAP affiliate company. All rights reserved. 39
Shortcut Key Description

Ctrl+G Opens the Go To dialog, in which you can specify the number of the line you want to move to.

Ctrl+L Deletes the current line and places it onto the clipboard.

Ctrl+Shift+L Deletes the current line.

Ctrl+Shift+U Changes the selection to uppercase characters.

Ctrl+U Changes the selection to lowercase characters.

Enter Accepts the selection and closes the text completion window.

F3 Finds the next occurrence of the selected text when the Find/Replace window is closed.

F9 Executes the text that is selected in the SQL Statements pane. If no text is selected, all of the
statements are executed.

Shift+F3 Finds the previous occurrence of the selected text when the Find/Replace window is closed.

Shift+Home Extends the selection to the start of the text on the current line.

Tab Accepts the selection and closes the text completion window.

These keyboard shortcuts are available when the Results pane has the focus:

Table 7:
Shortcut Key Description

F2 Edits the selected value in the Results pane.

PUBLIC Interactive SQL Guide


40 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Keyboard Shortcuts
6 Customize Interactive SQL Behavior

Configure options that control Interactive SQL behavior.

6.1 Changing the Number of Spaces that are Indented

Change the default indent size.

Context

Select Tools > Options. Choose Editor and then click the Tabs tab. Type a new number in the Indent Size field.

Procedure

1. Select Tools Options Editor Tabs .


2. Enter a new number in the Columns between indent stops field.

6.2 Configuring Clearing of the SQL Statements Pane

You can configure the Esc key to clear the SQL Statements pane and close any open results sets.

Context

By default, the Esc key leaves the contents of the SQL Statements pane unchanged.

Procedure

1. Select Tools Options Compatibility .

Interactive SQL Guide PUBLIC


Customize Interactive SQL Behavior © 2015 SAP SE or an SAP affiliate company. All rights reserved. 41
2. Select Pressing The Esc Key Clears SQL Statements And Closes Result Sets.
3. Click OK.

6.3 Configuring the Query Editor

You can customize some Query Editor behavior.

Procedure

1. Select Tools Options SAP Sybase IQ Query Editor .

Note
You can also access the Query Editor configuration page by clicking Options in the Query Editor.

2. Adjust the settings:

Table 8:
Setting Description

Fully qualify table and col­ Use fully qualified table and column names when constructing SELECT statements.
umn names

Quote names Enclose the names of identifiers in double quotation marks when constructing SELECT
statements.

Get list of tables on startup (Default) Automatically populate the list of tables when the Query Editor opens.

Caution
If you are connected to a database with a large number of tables or have a slow
communications link, you may want to disable this option to speed up the opening
of the Query Editor.

3. Click OK.

PUBLIC Interactive SQL Guide


42 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Customize Interactive SQL Behavior
6.4 Configuring the Execute Statements Button

You can configure the Execute Statements button on the toolbar to execute only selected SQL statements or
all statements.

Context

By default, the Execute Statements toolbar button executes all SQL statement that appear in the SQL
Statements pane.

Procedure

1. Select Tools Options Toolbar .


2. Select the desired behavior.
3. Click OK.

6.5 Creating a Header or Footer for Printed Output

You can define a header or footer to appear on all printed output.

Procedure

1. Select Tools Options Editor Print .


2. In the Header and Footer fields, specify the text to appear. Click the button to the right of the field to
include predefined variables in the output.
3. Click OK.

Interactive SQL Guide PUBLIC


Customize Interactive SQL Behavior © 2015 SAP SE or an SAP affiliate company. All rights reserved. 43
6.6 Setting Quiet Mode Prerequisites

You must enable the Show all result sets option if you are using Interactive SQL with the -q option (quiet
mode), and if data extraction commands (primarily setting the option TEMP_EXTRACT_NAME1 to an output file)
are contained in a command file.

Context

Caution
The data extraction output file is not created if this option is not set.

Procedure

1. Select Tools Options SAP Sybase IQ Results .


2. In the Results Processing area, select Show all results sets.
3. Click OK.

6.7 Disabling Warning Messages

You can disable some warning messages that appear in Interactive SQL. For example, you can suppress the
warning that appears when you exit Intearactive SQL with unsaved text in the SQL Statements pane.

Procedure

1. Select Tools Options Messages .


2. Unselect the Show column for any warning you do not want to see.
3. Click OK.

PUBLIC Interactive SQL Guide


44 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Customize Interactive SQL Behavior
6.8 Disabling Table Editing

You can disable the ability to edit values in the Results tab.

Procedure

1. Select Tools Options SAP Sybase IQ .


2. Under Style, select Scrollable Table, then Disable Editing.
3. Click OK.
4. Execute a query in the SQL Statements pane.

Note
You must execute a new query for the setting to take effect.

6.9 Setting Interactive SQL as the Default Editor

You can make Interactive SQL the default editor for saved SQL statements (.sql) and query plan (.saplan)
files.

Procedure

1. Select Tools Options General .


2. Under File Association, click Make Interactive SQL The Default Editor For SQL Files And Plan Files.
3. Click OK.

Interactive SQL Guide PUBLIC


Customize Interactive SQL Behavior © 2015 SAP SE or an SAP affiliate company. All rights reserved. 45
6.10 Configuring Text Completion

You can configure the Text Completion feature to automatically open, automatically complete, or
automatically add closing brackets and quotation marks as you type in the SQL Statement pane or in the SQL
pane in the Plan Viewer.

Procedure

1. Select Tools Options Editor Text Completion .


2. Select any:

○ Open Automatically
○ Complete Automatically
○ Add closing brackets and quotation marks
3. Click OK.

PUBLIC Interactive SQL Guide


46 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Customize Interactive SQL Behavior
7 Build and Execute Queries

Use the tools in Interactive SQL to help you build and execute queries.

7.1 Using Text Completion

The text completion feature supplies you with complete keywords and object names as you type.

For example, typing the letters IQ opens a text completion window that includes a list of possible keywords or
object names beginning with the letters SA. The more characters you type, the more narrow the list.

Text completion is available in the SQL Statements pane or Query Plan viewer and is, by default, enabled. You
can configure text completion behavior from the Tools Options window. Highlight the object name and
press Enter to insert it in the SQL pane.

When enabled, the text completion window opens only if the key sequence typed is not recognized as the
beginning of a valid keyword or object name.

7.1.1 Text Completion Keyboard Shortcuts

Keyboard shortcuts that are available when the text completion list is open.

Table 9:
Key Description

Ctrl+A Shows a complete list of database objects.

Ctrl+Double quote (") (or Ctrl+Shift+') Completes the name, and enclose it in quotation marks, re­
gardless of the setting of the quoted_indentifier op­
tion.

Ctrl+Asterisk (*) (or Ctrl+Shift+8) For tables, inserts a comma-separated list of columns, in­
cluding data types. For stored procedures, inserts the pro­
cedure name, followed by a comma-separated list of param­
eter names and their data types.

Ctrl+C Changes the contents of the text completion list to show or


hide columns.

Ctrl+F Changes the contents of the text completion list to show or


hide SQL functions.

Ctrl+P Changes the contents of the text completion list to show or


hide stored procedures and functions.

Interactive SQL Guide PUBLIC


Build and Execute Queries © 2015 SAP SE or an SAP affiliate company. All rights reserved. 47
Key Description

Ctrl+Plus Sign (+) (or Ctrl+Shift+=) For tables, inserts a comma-separated list of columns. For
stored procedures, inserts the procedure name, followed by
a comma-separated list of parameter names.

Ctrl+S Changes the contents of the text completion list to show or


hide system objects.

Ctrl+Shift+Space or Ctrl+Space Opens the text completion window.

Ctrl+T Changes the contents of the text completion list to show or


hide tables.

Ctrl+V Changes the contents of the text completion list to show or


hide views.

Esc Closes the text completion window without adding any text.

Tab Accepts the selection and closes the text completion win­
dow.

7.2 Comments in SQL Statements

Use comments to attach explanatory text to SQL statements or statement blocks.

7.2.1 Converting Statements to Comments

You can convert existing lines of text, SQL statements, or statement blocks to comments, which are not
executed.

Context

Note
You can add comments in statements in both the SQL Statements pane and the Query Plan Viewer.
However, the steps described here are supported only in the SQL Statements pane. In the Query Plan
Viewer, you must manually type the comment syntax at the beginning of each line.

Interactive SQL supports these types of comments:

● -- (double hyphen)
● // (double slash)
● /* ... */ (slash-asterisk)

PUBLIC Interactive SQL Guide


48 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build and Execute Queries
Note
There is no key sequence in Interactive SQL to automatically insert the slash-asterisk comment type. You
must manually type the /* key sequence around the text being commented.

Procedure

1. To:

Table 10:
Task Action

Comment a single line of text. Position the cursor anywhere on the line to be com­
mented; you need not select any text.

Comment multiple lines of text. Select at least one character on each sequential line of
text to be commented.

2. Insert the comment type:

Table 11:
Comment Type Action

Double hyphen (--) Press Ctrl+minus sign (-).

Double forward slash (//) Press Ctrl+forward slash (/).

7.2.2 Removing Comments

You can convert commented text to text, SQL statements, or statement blocks.

Context

Note
You can remove comments from statements in both the SQL Statements pane and the Query Plan Viewer.
However, the steps described here are supported only in the SQL Statements pane. In the Query Plan
Viewer, you must manually remove the comment syntax from the beginning of each line being commented.

Interactive SQL Guide PUBLIC


Build and Execute Queries © 2015 SAP SE or an SAP affiliate company. All rights reserved. 49
Procedure

1. To:

Table 12:
Task Action

Uncomment a single line text. Position the cursor somewhere on the line to be uncom­
mented; it is not necessary to select the text.

Uncomment multiple lines of text. Select at least one character on each sequential line of
text to be uncommented.

2. Remove the comment type:

Table 13:
Comment Type Action

Double hyphen (--) Press Ctrl+minus sign (-).

Double forward slash (//) Press Ctrl+forward slash (/).

7.3 Indent SQL Statements

Increase or decrease indentation of SQL statements, or change the default number of spaces indented.

7.3.1 Adding or Increasing Indentation of SQL Statements

Add indentation to a SQL statement or increase the indentation of an already-indented SQL statement.

Context

Procedure

1. Select the text in the SQL Statements pane that you want to indent. If no text is selected, the indentation is
applied to the current line.
2. Press Ctrl+Shift+period to indent one level.

PUBLIC Interactive SQL Guide


50 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build and Execute Queries
Related Information

Changing the Number of Spaces that are Indented [page 41]

7.3.2 Removing or Decreasing Indentation of SQL


Statements

Remove indentation from a SQL statement or decrease the indentation of an already-indented SQL statement.

Procedure

1. Select the text in the SQL Statements pane that you want to decrease the indentation. If no text is
selected, the indentation is applied to the current line.
2. Press Ctrl+Shift+comma to reduce the indent on level.

Related Information

Changing the Number of Spaces that are Indented [page 41]

7.4 Text Editing Keyboard Shortcuts

Keyboard shortcuts available when editing text in the SQL Statement pane.

Table 14:
Key Task

Ctrl+A Select all text in pane (also available in the SQL pane of the Plan viewer)

Ctrl+Backspace Deletes the word to the left of the cursor.

Ctrl+comma Select current line

Ctrl+Del Deletes the word to the right of the cursor.

Ctrl+down arrow Select next complete statement

Ctrl+End Moves to the bottom of the active pane.

Ctrl+F Find and replace text

Ctrl+forward slash (/) Add or remove double-slash comments

Ctrl+Home Moves to the top of the active pane.

Interactive SQL Guide PUBLIC


Build and Execute Queries © 2015 SAP SE or an SAP affiliate company. All rights reserved. 51
Key Task

Ctrl+minus (-) Add or remove double-hyphen comments

Ctrl+period Select complete statement

Ctrl+up arrow Select previous complete statement

Ctrl+G Go to specified line number

Ctrl+Shift+comma Decrease line indent one level

Ctrl+Shift+L Deletes the current line.

Ctrl+Shift+period Increase line indent one level

Ctrl+Shift+U Changes the selection to uppercase characters.

Ctrl+U Changes the selection to lowercase characters.

Ctrl+Y Redo

Ctrl+Z Undo

F3 Find next instance of text when Find/Replace window is closed.

PgDn Moves a page down in the current pane.

PgUp Moves a page up in the current pane.

7.5 Look Up Tables, Views, Columns, and Procedures

While you are building SQL statements in queries, you can look up the names of tables, views, columns, or
procedures stored in the current database and insert them at your cursor position.

7.5.1 Looking Up Table Names

As you build a SQL statement, you can look up the names of tables stored in the database and insert them at
your cursor position.

Context

Note
The lookup feature is not available in the Query Plan Viewer.

PUBLIC Interactive SQL Guide


52 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build and Execute Queries
Procedure

1. Select Tools Lookup Table Name or press F7.


2. Select Show tables, Show system tables, or both.
3. (Optional) Select Show owner names to include the name of the owner of the table in the list and when
you insert the table name into the SQL statement.
4. Type the first few letters of the table you are looking for. The list is narrowed to include only those items
that start with the text you entered.
5. Highlight a table name.

Note
You can only insert one table name at a time.

6. Click OK to insert the table name into the SQL Statements pane at the current cursor position.

7.5.2 Looking Up Table Column Names

As you build a SQL statement, you can look up the names of columns on a table and insert it at your cursor
position.

Context

Note
The lookup feature is not available in the Query Plan Viewer.

Procedure

1. Select Tools Lookup Table Name or press F7.


2. Select Show tables, Show system tables, or both.
3. (Optional) Select Show owner names to include the name of the owner of the table in the list.
4. Type the first few letters of the table containing the column you are looking for. The list is narrowed to
include only those items that start with the text you entered.
5. Highlight the table name and click Show Columns.
6. Highlight a column name.

Note
You can only insert one column name at a time.

Interactive SQL Guide PUBLIC


Build and Execute Queries © 2015 SAP SE or an SAP affiliate company. All rights reserved. 53
7. Click OK to insert the column name into the SQL Statements pane at the current cursor position.

7.5.3 Looking Up View Names

As you build a SQL statement, you can look up the names of views in the database and insert them at your
cursor position.

Context

Note
The lookup feature is not available in the Query Plan Viewer.

Procedure

1. Select Tools Lookup Table Name or press F7.


2. Select Show views.
3. (Optional) Select Show owner names to include the name of the owner of the view in the list and when you
insert the view name into the SQL statement.
4. Type the first few letters of the view you are looking for. The list is narrowed to include only those items
that start with the text you entered.
5. Highlight a view name.

Note
You can only insert one view name at a time.

6. Click OK to insert the view name into the SQL Statements pane at the current cursor position.

PUBLIC Interactive SQL Guide


54 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build and Execute Queries
7.5.4 Looking Up View Column Names

As you build a SQL statement, you can look up the names of columns on a view and insert it at your cursor
position.

Context

Note
The lookup feature is not available in the Query Plan Viewer.

Procedure

1. Select Tools Lookup Table Name or press F7.


2. Select Show views.
3. (Optional) Select Show owner names to include the name of the owner of the view in the list.
4. Type the first few letters of the view you are looking for. The list is narrowed to include only those items
that start with the text you entered.
5. Highlight the view name and click Show Columns.
6. Highlight a column name.

Note
You can only insert one column name at a time.

7. Click OK to insert the column name into the SQL Statements pane at the current cursor position.

7.5.5 Looking Up Procedure Names

As you build a SQL statement, you can look up the names of procedures stored in the database and insert the
name at your cursor position. You can include system procedures and user-defined procedures in the list.

Context

Note
The lookup feature is not available in the Query Plan Viewer.

Interactive SQL Guide PUBLIC


Build and Execute Queries © 2015 SAP SE or an SAP affiliate company. All rights reserved. 55
Procedure

1. Select Tools Lookup Procedure Name or press F8.


2. Select Show system objects to include system procedures and user-defined objects in the list.
3. (Optional) Select Show owner names to include the name of the owner of the procedure in the list and
when you insert the procedure name into the SQL statement.
4. (Optional) Click More >> to display the contents of the procedure.
5. Type the first few letters of the procedure you are looking for. The list is narrowed to include only those
items that start with the text you entered.
6. Highlight a procedure name.

Note
You can only insert one procedure name at a time.

7. Click OK to insert the procedure name into the SQL Statements pane at the current cursor position.

7.6 Clearing the SQL Statements Pane

You can quickly clear the SQL Statements pane when you finish working with the SQL code.

Procedure

Position the cursor in the SQL Statements pane and do one of:

○ (If configured) Press Esc.


○ Select Edit Select Select All , then press Delete.
○ Press Ctrl+A, then Delete.

Results

Note
Pressing Esc also clears the Results pane; pressing Delete does not.

Related Information

Configuring Clearing of the SQL Statements Pane [page 41]

PUBLIC Interactive SQL Guide


56 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build and Execute Queries
7.7 Execute Queries

You can execute all or select queries in the SQL Statements pane.

7.7.1 Executing All Queries

If there are multiple queries in the SQL statements pane, you can execute all statements at once.

Context

A query can contain multiple SQL statements. The semicolon identifies the end of a query. If you execute a
single query, and it returns multiple results sets, each set appears in its own numbered Results tab, while all
messages appear in a single Messages tab. However, if you execute multiple queries, the results set of each
successive query replaces the previous results set; only the last results sets of the last query executed
appears.

The following query contains two SELECT statements. It executes as a single query because no semicolon
separates the two statements. It generates two results sets, one for each SELECT statement.

SELECT * FROM aTable1


SELECT * FROM aTable2

This query contains the same two SELECT statements, but includes a semicolon at the end of the first SELECT
statement, which means it executes as two separate queries. When execution completes, only the results set
for the second query are shown.

SELECT * FROM aTable1;


SELECT * FROM aTable2

SELECT * FROM aTable1;


SELECT * FROM aTable2

Procedure

With your queries entered in the SQL Statements pane, do one of:

○ Press F5.
○ Select SQL Execute .
○ (If configured) Click the Execute all statement(s) icon on the Interactive SQL toolbar.

Interactive SQL Guide PUBLIC


Build and Execute Queries © 2015 SAP SE or an SAP affiliate company. All rights reserved. 57
Related Information

Configuring the Execute Statements Button [page 43]

7.7.2 Executing Selected Queries

You can execute one or more selected queries in the SQL Statements pane.

Context

A query can contain multiple SQL statements. The semicolon identifies the end of a query. If you execute a
single query, and it returns multiple results sets, each set appears in its own numbered Results tab, while all
messages appear in a single Messages tab. However, if you execute multiple queries, the results set of each
successive query replaces the previous results set; only the last results sets of the last query executed
appears.

The following query contains two SELECT statements. It executes as a single query because no semicolon
separates the two statements. It generates two results sets, one for each SELECT statement.

SELECT * FROM aTable1


SELECT * FROM aTable2

This query contains the same two SELECT statements, but includes a semicolon at the end of the first SELECT
statement, which means it executes as two separate queries. When execution completes, only the results set
for the second query are shown.

SELECT * FROM aTable1;


SELECT * FROM aTable2

SELECT * FROM aTable1;


SELECT * FROM aTable2

If no query is selected, all queries in the SQL Statements pane are executed.

Procedure

1. Type your queries in the SQL Statements pane and select the queries to run.

Note
The queries must be selectable as a single block.

2. Do one of:

PUBLIC Interactive SQL Guide


58 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build and Execute Queries
○ Press F9.
○ Select SQL Execute Selection .
○ (If configured) Click the Execute selected statement(s) icon on the Interactive SQL toolbar.

Results

If the selected queries return multiple results sets, each set appears in its own numbered Results tab, while all
messages appear in the same Messages tab.

Related Information

Configuring the Execute Statements Button [page 43]

7.7.3 Executing Queries One at a Time

If there are multiple queries in the SQL Statements pane, you can step through their execution in sequence.
This is useful when debugging.

Context

A query can contain multiple SQL statements. The semicolon identifies the end of a query. If you execute a
single query, and it returns multiple results sets, each set appears in its own numbered Results tab, while all
messages appear in a single Messages tab. However, if you execute multiple queries, the results set of each
successive query replaces the previous results set; only the last results sets of the last query executed
appears.

The following query contains two SELECT statements. It executes as a single query because no semicolon
separates the two statements. It generates two results sets, one for each SELECT statement.

SELECT * FROM aTable1


SELECT * FROM aTable2

This query contains the same two SELECT statements, but includes a semicolon at the end of the first SELECT
statement, which means it executes as two separate queries. When execution completes, only the results set
for the second query are shown.

SELECT * FROM aTable1;


SELECT * FROM aTable2

SELECT * FROM aTable1;


SELECT * FROM aTable2

Interactive SQL Guide PUBLIC


Build and Execute Queries © 2015 SAP SE or an SAP affiliate company. All rights reserved. 59
As you step through each query, the next sequential query to run is highlighted.

Procedure

1. Type your queries in the SQL Statements pane. Ensure each query ends with a semicolon.
2. Place your cursor somewhere in the first query that you want to execute; it does not need to be at the
beginning of the query.

3. Select SQL Single Step or press Shift+F9.


The selected query executes and the next sequential query is selected.
4. Press Shift+F9 again to run the next query in sequence.

7.8 Recall Previously Executed Commands

When you execute a command, Interactive SQL automatically saves it in a history list that persists between
sessions. You can also log your executed commands to a log file.

Interactive SQL maintains a record of up to 50 of the most recent commands. You can view the entire list of
commands in the Command History window. The most recent commands appear at the bottom of the list.

7.8.1 Scrolling Through Previously Executed Commands

You can scroll forward and backward though previously executed commands.

Context

If a previous execution included multiple statements in a single execute command, all associated statements
appear together in the SQL Statements pane.

Procedure

1. Position the cursor in the SQL Statements pane.


2. To display the previous command executed, either:

○ Press Alt+Left Arrow, or


○ Select SQL Previous SQL .
3. To display the next command executed, either:

PUBLIC Interactive SQL Guide


60 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build and Execute Queries
○ Press Alt+Right Arrow, or
○ Select SQL Next SQL .

7.8.2 Use Execution History

You can view the entire list of commands executed in the History window. The most recent commands appear
at the bottom of the list.

7.8.2.1 Accessing the History Window

Open the History window to view up to the last 50 commands executed.

Procedure

Do one of:

○ Press Ctrl+H.

○ Select SQL History .

○ Click the Open a list of past SQL statements icon on the toolbar.

7.8.2.2 Inserting Executed Commands from the History


Window

You can insert commands in the History window into the SQL Statements pane.

Context

The contents of the SQL Statements pane is cleared before the command is inserted.

Procedure

1. Open the History window.


2. Scroll through the list, and select a command.

Interactive SQL Guide PUBLIC


Build and Execute Queries © 2015 SAP SE or an SAP affiliate company. All rights reserved. 61
3. Click OK.

7.8.2.3 Copying Executed Commands from the History


Window

You can copy selected executed commands from the History window to the Windows clipboard for use in
other applications.

Procedure

1. Open the History window.


2. Select the commands to be copied.
Use Shift+click or Control+click to select multiple commands.
3. Press Ctrl+C or click Copy.
4. Click Cancel to close the History window.

Caution
Do not click OK to close the window or the current contents of the SQL Statements pane is cleared and
the selected commands inserted.

7.8.2.4 Saving Executed Commands from the History


Window

Save all executed commands in the History window in a .sql file.

Procedure

1. Open the History window.


2. Click the Save History As SQL File button or press Ctrl+S.
3. In the Save As window, specify a location and name for the file. The history file has a .sql extension.
4. Click Save.

PUBLIC Interactive SQL Guide


62 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build and Execute Queries
7.8.2.5 Removing Executed Commands from the SQL
History Window

Clear select commands or all commands from the History window.

Context

Caution
You cannot undo this action.

Procedure

1. Open the History window.


2. To:

Table 15:
Task Action

Remove select commands. 1. Select one or more commands. Use Shift+click or Control+click to select
multiple commands.
2. Press the Delete key or click the Delete button.

Remove all commands. Click Clear History.

7.8.2.6 Logging SQL Statement Execution

You can record commands as you execute them, and store them in a log file.

Context

The logging option applies to the Interactive SQL session, not the database connection. Once enabled, logging
remains active until you disable it, or until you exit Interactive SQL.

The log file records commands executed, execution time, and any messages associated with the execution.
The log file does not record the database name the command was executed against or the user ID executing
the command.

Interactive SQL Guide PUBLIC


Build and Execute Queries © 2015 SAP SE or an SAP affiliate company. All rights reserved. 63
Procedure

1. Select SQL Start Logging .


2. In the Save As window, specify a location and name for the log file.
3. Click Save.
4. Execute commands.

5. Select SQL Stop Logging .

7.9 Executing COMMIT and ROLLBACK Statements

There are multiple ways to execute COMMIT and ROLLBACK statements.

You can execute a COMMIT statement by:

● Selecting SQL Commit .


● Pressing Ctrl+Shift+C.
● Typing Commit in the SQL Statements pane, and then executing the statement.

You can execute a ROLLBACK statement by:

● Selecting SQL Rollback .


● Pressing Ctrl+Shift+R.
● Typing Rollback in the SQL Statements pane, and then executing the statement.

Note
Executing a COMMIT or ROLLBACK using the SQL menu or a keyboard shortcut does not impact the contents
of the SQL Statements pane. However, the Results tab in the Results pane is cleared and the Messages tab
appears.

PUBLIC Interactive SQL Guide


64 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build and Execute Queries
8 Result Sets

You can work with the result sets of commands that you execute.

8.1 Showing Multiple Result Sets (UNIX)

By default, Interactive SQL shows the first result set of the most-recently executed statement, but you can
change this setting to display all result sets.

Procedure

1. If running Interactive SQL as a command line program (-nogui mode):


a. Navigate to your $HOME directory and locate the file .isqlPreferences16.
b. Change the line:
<entry key="SybaseIQ.showMultipleResultSets">0</entry>

to:

<entry key="SybaseIQ.showMultipleResultSets">1</entry>
c. Save the changes to the file .isqlPreferences16.
2. If using GUI mode:

a. Click Tools Options SAP Sybase IQ .


b. Select the Results tab.
c. Under Results Processing, select Show All Result Sets.
d. Click OK.

Interactive SQL Guide PUBLIC


Result Sets © 2015 SAP SE or an SAP affiliate company. All rights reserved. 65
8.2 Showing Multiple Result Sets (Windows)

By default, Interactive SQL shows the first result set of the most-recently executed statement, but you can
change this setting to display all result sets.

Procedure

1. Select Tools Options SAP Sybase IQ .


2. Select the Results tab.
3. Under Results Processing, select Show all Result Sets.
4. Click OK.

8.3 Edit Result Sets

Once you execute a query in Interactive SQL, you can sort and edit the result set to modify the database. You
can also select rows from the result set and copy them for use in other applications.

Interactive SQL supports editing, inserting, and deleting rows. Editing the result set has the same effect as
executing UPDATE, INSERT, and DELETE statements. After you edit a result set, the equivalent INSERT,
UPDATE, and DELETE statements are added to the Interactive SQL executed commands history.

You must have sufficient privileges on the object to edit a row or value in the result set. For example, to delete
a row, you must have DELETE object-level privilege for the table containing the row.

You cannot edit a result set if:

● The columns in the result set do not include at least all the primary-key columns in the table.
● The result set is the result of a JOIN.
● Table editing is disabled.

Editing the result set fails if you:

● Attempt to edit a row or column you do not have privilege on.


● Enter an invalid value (for example, a string in a numeric column, or a NULL in a column that does not allow
NULLs).

When editing fails, you see an error message and database table values remain unchanged.

For character data types only, you can use an Edit window, which lets you move between columns or rows and
save and load data from a file.

PUBLIC Interactive SQL Guide


66 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Result Sets
Related Information

Disabling Table Editing [page 45]

8.3.1 Editing Table Values in the Result Set

You can change any or all of the values in the result provided that you have UPDATE object-level privilege on
the columns being modified, and that table editing is enabled.

Procedure

1. Execute a query.
2. Do one of:

○ Right-click the value you want to change and select Edit Row.
○ Left-click the value you want to change and press F2.

With either method, a blinking cursor and an ... (ellipsis) button appears in the table cell containing the
value.
3. To:

Table 16:
Task Action

Modify value Do one of:


○ Type the new value directly in the table cell.
○ (Optional for character data fields only) Click the ...
button and select Edit in Window open a text editor
window. Type the new value and click OK. See Use
Results Set Text Editor.

Convert value to NULL Click the ... button and select Set to NULL.

Note
The Set to NULL option appears only if the column al­
lows NULL values.

Move to the next sequential value in the table. Press Tab or Shift+Tab.

Cancel all changes made to the selected cell. Press Esc.

4. To update the database when you finish, press Enter. The cursor moves to the row number at the
beginning of the row.
5. Do one of:

○ Execute a COMMIT to make the change permanent.


○ Execute a ROLLBACK to reverse all changes since the last COMMIT.

Interactive SQL Guide PUBLIC


Result Sets © 2015 SAP SE or an SAP affiliate company. All rights reserved. 67
Related Information

Use Results Set Text Editor [page 68]

8.3.1.1 Use Results Set Text Editor

For character data fields only, you can use a text editor to modify values. This makes it easier to see and edit
fields containing large quantities of data.

You can copy the contents of a field to the clipboard or save it to a file.

The Previous Row and Next Row buttons allow you to move between rows in the result set without leaving the
editor. You are prompted to save any changes made to a field before advancing to the next row. The text editor
validates the change and displays an error if the change is invalid.

Similarly, the Previous Column and Next Column buttons allow you to move between columns in the result set
while remaining in the editor.

Note
The Previous Column and Next Column buttons are available only if the next or previous column is a
character data type.

8.3.1.2 Inserting a NULL or Default Value in a Column

When you add a value in a column that has a default value, the cell editor contains the option Set to DEFAULT.
Similarly, if a column accepts NULL values, Set to NULL appears in the list.

Procedure

To:
○ To override a (NULL) value, position the cursor in the column and enter the new value. There is no need to
remove (NULL) first.
○ To change a column back to (NULL), position the cursor in the column, click the ... (ellipsis) button and
select Set to NULL.
○ To restore the default value in a column, click the ... (ellipsis) button and select Set to DEFAULT.
○ To override a default value, position the cursor in the column and enter the new value. There is no need to
remove (DEFAULT) first.

PUBLIC Interactive SQL Guide


68 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Result Sets
8.3.1.3 Inserting a Value When the Result Set Contains a
Computed Column

If the result set contains a computed column and you do not specify a value for the computed column, the
value is calculated when the database is updated. However, if you specify a value for the computed column,
the database is updated with the specified value, and a value is not calculated for the computed column.

8.3.2 Inserting a New Row into the Result Set

You can add a new row to a table that appears in the Results tab. You must have INSERT object-level privilege
on the table to add a new row.

Context

You cannot insert a row if:

● The columns in the result set do not include at least all the primary-key columns in the table.
● The result set is the result of a JOIN.
● Table editing is disabled.

An insert fails if:

● You enter an invalid value (for example, you enter a string in a numeric column, or a NULL in a column that
does not allow NULLs) in at least one column in the row.
● The query that generated the result set references a table that contains a column that does not allow
NULL values, and that column is excluded from the result set.
For example, the result set includes three of four columns in TableA. The excluded column does not allow
NULL values. When you insert a row in a result set, every column in the row must be populated, even
excluded columns. By default, excluded columns are automatically populated with NULL values. If at least
one excluded column does not allow NULL values, the row insert fails.

Procedure

1. Right-click in the Results pane and select Add Row.


A new row appears. (NULL) appears in any column that allows NULL values. (DEFAULT) appears in any
column with a default value defined.
2. Enter a value in the field and press Tab to move to the next column.
○ To override a (NULL) or (DEFAULT) value, begin typing in the field. There is no need to remove the
field contents first.
○ You cannot enter invalid data types into a column. For example, you cannot enter a string into a
column that accepts the INT data type.
○ Once (DEFAULT) is removed from the field, it cannot be restored. Manually enter the value of the
default in the field.

Interactive SQL Guide PUBLIC


Result Sets © 2015 SAP SE or an SAP affiliate company. All rights reserved. 69
3. Repeat step 2 [page 69] until you have made entries into all the columns that require values.
4. Press Enter to update the database.
You see an Update Row error message if any column value in the new row is invalid. The error message
can apply to multiple columns in the row, and may not necessarily apply to the current column.

For example, you insert a row into a five column table. Each column has a size of 1. You enter the values 1,
22, 3, 44, 5 in each column, respectively. With the cursor resting in column 5, you press Enter. An error
message appears indicating the row could not be updated. The error applies to columns 2 and 4 even
though the cursor is resting in column 5.

8.3.3 Inserting a New Row Using the INPUT Statement

You can add rows to a table using the INPUT statement with the PROMPT clause.

Procedure

1. In the SQL Statements pane, enter:

INPUT INTO <table_name> PROMPT;

2. Specify the value for each column when prompted.

Note
By default, the Interactive Input window does not display (NULL) or (DEFAULT). Entries are not
validated at time of entry.

3. Do one of:

○ Click Add to add the current row and continue adding rows.
○ Click Done to add the row and close the Interactive Input window.

You see an error message if any of the entries are invalid.

PUBLIC Interactive SQL Guide


70 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Result Sets
8.3.4 Deleting Rows from the Result Set

Deleting rows in the result set deletes the rows from the database table. You must have DELETE object-level
privilege on the table to delete rows.

Context

Note
You cannot delete a column from a result set.

Procedure

1. Select the rows to delete:

Table 17:
Selection Type Action

Consecutive rows Do one of:


○ Press and hold the Shift key while clicking consecutive rows or pressing the
Up or Down arrow.
○ Click the first row to be selected, press and hold the Shift key, and click the
last row to be selected.

Individual rows Click the first row to be selected, press and hold the Ctrl key, and click each addi­
tional row to be selected.

2. Do one of:

○ Press Delete.
○ Right-click and select Delete Row.

Caution
There is no prompt to confirm the deletion.

3. Do one of:

○ Execute a COMMIT to make the change permanent.


○ Execute a ROLLBACK to reverse all changes since the last COMMIT.

Interactive SQL Guide PUBLIC


Result Sets © 2015 SAP SE or an SAP affiliate company. All rights reserved. 71
8.3.5 Copying Rows from the Result Set

You can copy rows from the result set and paste them into other applications. Pasted output includes comma-
delimited column names, and character data enclosed in single quotation marks with trailing spaces added to
pad each field to its maximum size.

Procedure

1. Select the rows you want to copy:

Table 18:
Selection Type Action

Consecutive rows Do one of:


○ Press and hold the Shift key while clicking consecutive rows or pressing the
Up or Down arrow.
○ Click the first row to be selected, press and hold the Shift key, and click the
last row to be selected.

Individual rows Click the first row to be selected, press and hold the Ctrl key, and click each addi­
tional row to be selected.

2. Do one of:

Table 19:
Copy Type Action

Single row Do one of:

○ Right-click one of the selected rows and select Copy Data Rows .
○ Press Ctrl+C.

Multiple rows Press Ctrl+C.

Caution
If you select Copy Data Rows only the last selected row of data is copied.

PUBLIC Interactive SQL Guide


72 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Result Sets
8.3.6 Copying Columns from the Result Set

You can copy columns from the result set and then paste them into other applications. All rows within each
selected column are copied.

Context

Pasted output includes comma-delimited column names, and character data enclosed in single quotation
marks with trailing spaces added to pad each field to its maximum size.

Procedure

1. Select the columns you want to copy:

Table 20:
Selection Type Task

Consecutive columns Do one of:


○ Press and hold the Shift key while clicking the next consecutive column or
pressing the Left and Right arrow.
○ Click the first column to be selected, press and hold the Shift key, and click
the last column to be selected.

Individual columns Click the first column to be selected, press and hold the Ctrl key, and click each ad­
ditional column to be selected.

2. Do one of:

○ Right-click one of the selected columns and select Copy Data Columns .
○ Press Ctrl+C.

8.3.7 Copying Cells from the Result Set

Copying individual cells copies only the data to the clipboard. Pasted output includes comma-delimited
columns, but does not include column names or character data enclosed in quotation marks.

Context

Additional cells are automatically selected if the selection crosses both columns and rows with respect to any
of the previously selected cells. The additional selections are required to preserve the row and column layout

Interactive SQL Guide PUBLIC


Result Sets © 2015 SAP SE or an SAP affiliate company. All rights reserved. 73
of the pasted data. For the same reason, unselecting a cell can automatically unselect other cells. Consider the
following. You have a three-column, three-row table.

1 2 3
4 5 6
7 8 9

You select 1 and 3. Since the selections cross columns but not rows, additional cells are not selected. Pasted
output would be:

1,3

You then select 6. Since this selection crosses both columns and rows from 1 and 3, 4 is automatically
selected. This additional selection is required to preserve the columnar layout. Without the additional
selections, the pasted output would be:

1,3
6

It appears that 1 and 6 reside in the same column in the table. Automatically selecting 4 ensures the pasted
output appears as:

1,3
4,6

Procedure

1. Select the cells you want to copy:

Table 21:
Selection Type Task

Consecutive cells Do one of:


○ Press and hold the Shift key while clicking the next consecutive cell or press­
ing the Up, Down, Left, or Right arrow.
○ Click the first cell to be selected, press and hold the Shift key, and click the
last cell to be selected.

Individual rows Click the first row to be selected, press and hold the Ctrl key, and click each addi­
tional row to be selected.

Note
Additional cells may become automatically selected.

2. Do one of:

○ Right-click one of the selected columns and select Copy Data Cells .
○ Press Ctrl+C.

PUBLIC Interactive SQL Guide


74 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Result Sets
8.3.8 Sorting Columns in the Result Set

You can sort the results set by a specified column. You cannot subsort on additional columns.

Procedure

1. Click a column header in the Results tab.


2. (Optional) Click again to reverse the sort order.

8.4 Generating SQL Statements from Result Sets

You can create INSERT, DELETE, and UPDATE statements for selected rows in the result set.

Procedure

1. Select the rows you want to generate a statement for:

Table 22:
Selection Type Action

Consecutive rows Do one of:


○ Press and hold the Shift key while clicking consecutive rows or pressing the
Up or Down arrow.
○ Click the first row to be selected, press and hold the Shift key, and click the
last row to be selected.

Individual rows Click the first row to be selected, press and hold the Ctrl key, and click each addi­
tional row to be selected.

2. Right-click one of the selected rows, select Generate, and then select INSERT Statement, DELETE
Statement, or UPDATE Statement. The statement is copied to the clipboard.

Interactive SQL Guide PUBLIC


Result Sets © 2015 SAP SE or an SAP affiliate company. All rights reserved. 75
8.5 Printing SQL Statements and Result Sets

You can print the contents of the SQL Statements pane or results set. You can also configure a header and
footer for the printed output.

Procedure

1. Do one of:

○ Press Ctrl+P.
○ Select File Print .
2. Select SQL statements or Results.
3. Click OK.

Related Information

Creating a Header or Footer for Printed Output [page 43]

PUBLIC Interactive SQL Guide


76 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Result Sets
9 Favorites List

You can store frequently used SQL script files, queries, and database connections in a favorites list. The
favorites list is specific to a single user and cannot be seen by other users.

9.1 Showing or Hiding the Favorites Pane

You can show or hide the list of favorites.

Context

The option to show or hide the favorites list is a toggle switch. Each press turns the option on or off.

Procedure

Select Favorites Show Favorites .

9.2 Creating a Connection Favorite

You can store frequently used database connections, including password, as a favorite.

Prerequisites

You must be connected to the database the favorite references.

Procedure

1. Do one of:

Interactive SQL Guide PUBLIC


Favorites List © 2015 SAP SE or an SAP affiliate company. All rights reserved. 77
○ Select Favorites Add To Favorites .
○ Press Ctrl+D.
2. (Only if there is content in the SQL Statements pane or Results tab) Select Add the current connection.
3. Select Save the connection password.

Note
If you do not select this option, only the User ID is saved.

When you select the favorite to connect, you must specify Action connection information as well as the
password to connect to the database.
4. In the Name field, enter a name for the connection. The favorite name must be unique. You must delete an
existing favorite before you can create a new one with the same name.
5. (Option) Select a folder in the Favorites list in which to store the connection favorite.
6. Click OK.

9.3 Creating a SQL Statements Favorite

You can store frequently used queries in a favorites list.

Context

Note
Each single-query favorite can be a maximum of 16384 characters.

Procedure

1. In the SQL Statements pane, enter the query you want to add to your favorites.
2. Do one of:

Table 23:
Action Task

Save all text in the SQL Statements 1. Select Favorites Add To Favorites or press Ctrl+D.
pane.
2. Select Add SQL statements.

PUBLIC Interactive SQL Guide


78 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Favorites List
Action Task

Save select text in the SQL Statements 1. Select the text to be saved as a favorite.
pane.
2. Select Favorites Add To Favorites or press Ctrl+D.
3. Select Add SQL statements.
4. (Only if text is selected in the SQL Statements pane) Select Add only
the currently selected statements.

3. In the Name field, enter a name for the favorite. The favorite name must be unique. You must delete an
existing favorite before you can create a new one with the same name.
4. Click OK.

9.4 Creating a .sql File Favorite

You can store frequently used SQL command files in a favorites list.

Context

There is no limit on the size of .sql file that you can save as a favorite.

Procedure

1. Select File Open .


2. Select the command file that you want to add to your favorites.
3. Do one of:

Table 24:
Action Task

Save all text in the SQL Statements 1. Select Favorites Add To Favorites or press Ctrl+D.
pane.
2. (Only if a .sql file is open in the SQL Statements pane) Select Add
the open file <file name>.

Save select text in the SQL Statements 1. Select the text to be saved as a favorite.
pane.
2. Select Favorites Add To Favorites or press Ctrl+D.
3. Select Add SQL statements.
4. (Only if text is selected in the SQL Statements pane) Select Add only
the currently selected statements.

4. In the Name field, enter a name for the .sql file. The favorite name must be unique. You must delete an
existing favorite before you can create a new one with the same name.

Interactive SQL Guide PUBLIC


Favorites List © 2015 SAP SE or an SAP affiliate company. All rights reserved. 79
5. Click OK.

9.5 Deleting a Favorite

Delete a favorite from the favorites list.

Procedure

Do one of:

○ Right-click the favorite in the Favorites pane and select Delete.


○ Select Favorites Organize Favorites . Select the favorite and click Delete.

9.6 Renaming a Favorite

Rename a favorite on the favorites list.

Procedure

1. Do one of:

○ Right-click the favorite in the Favorites pane and select Rename.


○ Select Favorites Organize Favorites . Select the favorite and click Rename.
2. Type a new name for the favorite. Favorite names must be unique.
3. Click OK.

PUBLIC Interactive SQL Guide


80 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Favorites List
9.7 Using a Favorite

When using a SQL statement or .sql file favorite, the content of the SQL Statement pane is cleared before the
favorite is loaded. When using a connection favorite, the existing connection is disconnected before the new
connection is established.

Procedure

Do one of:

○ Left-click the favorite in the Favorites pane.


○ Right-click the favorite and select Open.
○ Select Favorites from the menu, and click the favorite in the list.

9.8 Editing a Favorite

Edit the contents of a favorite.

Procedure

1. Do one of:

○ Right-click the favorite in the Favorites pane and select Edit.


○ Select Favorites Organize Favorites . Select the favorite and click Edit.
2. For:

Table 25:
Favorite Type Action

Connection Enter the new connection information and click OK.

SQL Statements Modify the SQL statements and click Save.

.sql File Select a new .sql file and click Select.

Interactive SQL Guide PUBLIC


Favorites List © 2015 SAP SE or an SAP affiliate company. All rights reserved. 81
9.9 Exporting a Favorites List

Export your favorites list to a .fav file.

Context

The favorites list is specific to a single user and cannot be seen by other users. However, if you export a copy of
user's current favorites list, you can then import it into other user's instances of Interactive SQL.

Procedure

1. Select Favorites Export Favorites .


2. Specify a file name for the .fav file and then click Export.

9.10 Importing a Favorites List

Import favorites from a .fav file.

Context

If, when you import favorites, there are duplicates, you can:

Table 26:
Type Resolution Options

Folder ● Merge the contents of the imported duplicate folder with the existing folder.
● Rename the imported duplicate folder.
● Replace the items in the existing folder with those in the duplicate folder.
● Not import the duplicate folder.

Favorite ● Rename the imported duplicate favorite.


● Replace the existing favorite with the duplicate favorite.
● Not import the duplicate favorite.

PUBLIC Interactive SQL Guide


82 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Favorites List
Procedure

1. Select Favorites Import Favorites .


2. Browse to the .fav file and then click Import.
3. Resolve duplicate entries, if prompted.

9.11 Creating a Folder in the Favorites Pane

You can create folders in the Favorites pane to help you organize your favorites.

Procedure

1. Select Favorites Organize Favorites .


2. Click New Folder.
3. Enter a name for the folder. Folder names must be unique.
4. Click OK.

9.12 Adding a Favorite to a Favorites Folder

You can move a favorite from the Favorites pane to a folder.

Context

Note
You cannot use the Organize Favorites menu option to add a favorite to a favorites folder.

Procedure

Left-click a favorite in the Favorites pane and drag it to a folder.


The favorite appears as a child of the folder.

Interactive SQL Guide PUBLIC


Favorites List © 2015 SAP SE or an SAP affiliate company. All rights reserved. 83
9.13 Removing a Favorite from a Favorites Folder

You can move a favorite from a folder to the Favorites pane.

Context

Note
You cannot use the Organize Favorites menu option to remove a favorite from a favorites folder.

Procedure

1. In the Favorites pane, expand the folder, if necessary.


2. Left-click the favorite and drag it from the folder to the Favorites pane.

9.14 Reordering the Favorites List

You can move a favorite's position on the list up and down or into a folder.

Procedure

Do one of:

○ In the Favorites pane, left-click and drag a favorite to a new location.


○ Select Favorites Organize Favorites , highlight the favorite, and do one of:

Table 27:
Reposition on list Click Move Up and Move Down to reposition the favorite.

Add to folder Click Move and select the folder into which to move the favorite.

PUBLIC Interactive SQL Guide


84 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Favorites List
10 Build Queries with the Query Editor

Use the Query Editor to build SELECT statements.

Build SELECT statements in the Query Editor, or import existing ones from the SQL Statement pane into the
Query Editor to edit them. When you finish building a query, click OK to export it to the SQL Statement pane to
execute.

You do not need to write SQL code to build queries with the Query Editor. As you define the components of the
query in the Query Editor tabs, the corresponding SQL code is written in the background for you. The Query
Results pane displays the results of the query as it is built. Click SQL at the bottom of the window to see the
SQL code for the query. You can directly edit the SQL code and the Query Editor updates the corresponding
components.

The Query Editor is not designed to create UPDATE statements or other non-SELECT SQL statements. It is not
designed to create views, although you can create them in Interactive SQL and reference them in the Query
Editor. It does not build unions or intersections of SELECT statements.

The Query Editor does not support Transact-SQL® syntax.

10.1 Creating a SELECT Query Using the Query Editor

Use the Query Editor tools and tabs to write a SELECT statement.

Context

The editor can build only one SELECT statement at a time. When you start the Query Editor, the editor
attempts to parse any content in the SQL Statements pane as a valid SELECT statement. If it cannot, you see
an error message, and can open the editor without the text.

If there are multiple SELECT statements in the SQL Statements pane, you can import only one of them by
highlighting the complete statement before starting the Query Editor.

Procedure

1. To:
In this table, a recognizable SELECT statement is a statement that can be successfully parsed by the
Query Editor. It does not have to be able to return valid output or run without error.

Interactive SQL Guide PUBLIC


Build Queries with the Query Editor © 2015 SAP SE or an SAP affiliate company. All rights reserved. 85
Table 28:
Task Action

Import an existing SELECT statement into If there is only one recognizable SELECT statement in the SQL State­
the Query Editor. ments pane, proceed to the next step. If there are multiple statements
in the SQL Statements pane, select one.

Build a new SELECT statement in the Query Ensure the SQL Statements pane is empty or does not contain a single
Editor. recognizable SELECT statement.

2. Do one of:

○ Select Tools Edit Query .


○ Press Ctrl+Q.
3. If the Query Editor cannot parse the input, select Yes to open the Query Editor without any text.
4. Build or modify your SELECT statement.

Table 29: Query Editor Tabs


Tab Description

Tables Lists the tables in the database you can use in your query.
○ Specify a table or owner pattern or table type to filter the list.
○ Select a table in the left pane and click Right to add the table to the query. You
can only add one table at a time.
○ Select a table in the right pane and click Left to remove the table from the
query.
○ To use a derived table in the query, click Create a derived table or press Alt+D.

Joins Specifies a join strategy for combining the data in the tables.
○ If you include more than one table in your query, the Query Editor suggests au­
tomatically suggests a join strategy for combining the data in the tables. If there
is a foreign key relationship between the tables, it generates a join condition
based on that relationship, or it suggests a cross product.
○ If you import a SELECT statement that contains a join strategy, the Query Edi­
tor accepts exactly the join strategy that you specified (and an unspecified JOIN
is not defaulted to KEY JOIN).
○ Modify the join strategy as need.
○ Click Add to create a new join strategy.
○ To delete a join, left-click the dot at the beginning of the join line and click
Delete.

Columns Specifies the columns in your result set. If you do not select any columns, they are
all used.
○ The left pane lists the tables that are already selected for the query under the
Tables tab.
○ Expand a table in the left pane to display the available columns. Select a column
in the left pane and click Right to add the column to the query. You can only add
one column at a time.
○ To remove a column from the query, select a column in the right pane and click
Left.
○ To reorder the column in the query output, highlight a column in the right pane
and click Up and Down.
○ To use a derived column in the query, click Add a computed column, or press
Alt+C.

PUBLIC Interactive SQL Guide


86 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build Queries with the Query Editor
Tab Description

INTO Assign results to variables.

WHERE Specifies conditions for restricting the rows in your result set. Type the WHERE
clause in the Criteria pane, click Build WHERE expression or press Alt+C.

GROUP BY Group rows in the result set.


○ The left pane lists the tables already selected for the query under the Tables
tab.
○ To group by all columns on a table, select a table name in the left pane, and click
Right.
○ To group by select columns, in the left pane, expand a table name, select a col­
umn, and click Right; the column appears in the right pane. You can only add
one column at a time.
○ To remove a column from the GROUP BY clause, select a column in the right
pane and click Left.
○ To reorder the columns in the GROUP BY clause, highlight a column in the right
pane and click Up and Down.
○ To use a derived column in the GROUP BY clause, click Add a computed
column, or press Alt+C.

HAVING Restricts the rows in your result set based on group values. Type the HAVING clause
in the Criteria pane, click Build HAVING expression or press Alt+C.

ORDER BY Sorts the rows.


○ The left pane lists the tables already selected for the query under the Tables
tab.
○ To order by all columns on a table, select a table name in the left pane, and click
Right.
○ To order by select columns, in the left pane, expand a table name, select a col­
umn, and click Right; the column appears in the right pane. You can only add
one column at a time.
○ To remove a column from the ORDER BY clause, select a column in the right
pane and click Left.
○ To reorder the column in the ORDER BY clause, highlight a column in the right
pane and click Up and Down.
○ To use a derived column in the ORDER BY clause, click Add a computed
column, or press Alt+C.

Table 30: Query Editor Tools


Tool Description

Expression Editor (Available on the Columns, WHERE, GROUP BY, HAVING, ORDER BY tabs) Use to
build search conditions or define computed columns.

Derived Table (Available on the Tables tab and Expression Editor) Similar to the Query Editor, use
this tool to create derived tables and subqueries.

5. Click OK to display the SELECT statement to the SQL Statements pane.

Note
If you selected a single SELECT statement before starting the Query Editor, only the highlighted
statement is replaced with the statement from the Query Editor. Otherwise, the entire contents of the

Interactive SQL Guide PUBLIC


Build Queries with the Query Editor © 2015 SAP SE or an SAP affiliate company. All rights reserved. 87
SQL Statements pane is replaced with the SELECT statement from the Query Editor. There is no
confirmation prompt before overwriting.

10.2 Configuring the Query Editor

You can customize some Query Editor behavior.

Procedure

1. Select Tools Options SAP Sybase IQ Query Editor .

Note
You can also access the Query Editor configuration page by clicking Options in the Query Editor.

2. Adjust the settings:

Table 31:
Setting Description

Fully qualify table and col­ Use fully qualified table and column names when constructing SELECT statements.
umn names

Quote names Enclose the names of identifiers in double quotation marks when constructing SELECT
statements.

Get list of tables on startup (Default) Automatically populate the list of tables when the Query Editor opens.

Caution
If you are connected to a database with a large number of tables or have a slow
communications link, you may want to disable this option to speed up the opening
of the Query Editor.

3. Click OK.

PUBLIC Interactive SQL Guide


88 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Build Queries with the Query Editor
11 View Query Execution Plans

An execution plan is the set of steps the database server uses to access information in the database related to
a query. The Plan Viewer is a graphical tool to view these plans.

Table 32: Plan Viewer Panes


Pane Description

SQL A place for you to type queries that you want to generate plans for. Click Hide SQL
or Show SQL to control the appearance of the pane.

Query Plan A graphical diagram of the plan after you click Get Plan. Click the dropdown arrow
to change the query type.

Details Details about the generated query plan. For multiple-node plans, click each node in
the Query pane to display the corresponding plan details.

11.1 Starting the Plan Viewer

The Plan Viewer opens in a separate window.

Procedure

1. In the SQL Statements pane, enter the SQL statement you want to generate a plan for.
2. Do one of:

○ Select Tools Plan Viewer


○ Press Shift+F5.

Results

The Plan View opens in a new window with your specified query in the SQL pane.

Interactive SQL Guide PUBLIC


View Query Execution Plans © 2015 SAP SE or an SAP affiliate company. All rights reserved. 89
11.2 Generating a Query Plan

You can view the query optimizer's execution plan for a SQL statement in the Plan Viewer window.

Context

Note
The Get Plan button is inoperative if the SQL pane is empty.

Procedure

1. If empty, enter your query in the SQL pane.


2. Click Get Plan to generate a plan for the specified query.

Results

Note
If a query plan cannot be generated, you see a message in the bottom pane. Modify the query and click Get
Plan again.

11.3 Customizing the Query Plan

You can customize the appearance of items in the query plan. You can do this before or after generating the
query plan.

Context

Customizations to options in the Plan viewer are retained only for the current database connection session.

PUBLIC Interactive SQL Guide


90 © 2015 SAP SE or an SAP affiliate company. All rights reserved. View Query Execution Plans
Procedure

1. In the Plan Viewer, change the settings as needed.

Table 33:
Option Description

Statistics level Specifies the type of query execution statistics the database server monitors when the
query is executed. Valid options are:
○ Optimizer estimates only
○ Detailed statistics
○ Detailed and node statistics

Cursor type Specifies the type of cursor used in the plan. The type of cursor you choose affects opti­
mizer performance. Valid options are:
○ Asensitive
○ Insensitive
○ Keyset-driven
○ Sensitive

Update status Specifies how the optimizer should treat the given cursor. Valid options are:
○ Read-write
○ Read-only

2. Click Get Plan to generate the graphical plan with your changes.

11.4 Saving a Query Plan

You can save a query plan for later retrieval. Query plans have a *.saplan file extension.

Prerequisites

Generate a query plan.

Procedure

1. Click Save As at the bottom of the viewer.


2. Type a file name and click Save.

Interactive SQL Guide PUBLIC


View Query Execution Plans © 2015 SAP SE or an SAP affiliate company. All rights reserved. 91
11.5 Opening a Saved Query Plan

You can load a saved query plan, make modifications, and regenerate the query plan.

Context

You do not need to be connected to the database the saved query plan was generated for to open a saved
query plan. However, you must be connected before you can regenerate the query plan.

Procedure

1. In the Plan Viewer, click Open.


2. Select a plan file (.saplan) and click Open.

11.6 Printing a Query Plan

You can print a query plan generated in the Plan Viewer.

Prerequisites

Generate a query plan.

Procedure

Do one of:

○ Click the Print button.


○ Right-click in the Query pane and select Print.

PUBLIC Interactive SQL Guide


92 © 2015 SAP SE or an SAP affiliate company. All rights reserved. View Query Execution Plans
11.7 Customizing the Query Pane in the Plan Viewer

You can customize the appearance of the text in the Query pane, including the color, shape, and font of the
output.

Prerequisites

Generate a query plan.

Context

Customizations apply to all generated plans—not just the currently generated plan—and persist beyond the
current database connection.

Procedure

1. Right-click in the Query pane and select Customize.


2. Adjust the colors and shapes, as needed.
3. Click OK to apply the changes.

Interactive SQL Guide PUBLIC


View Query Execution Plans © 2015 SAP SE or an SAP affiliate company. All rights reserved. 93
12 Source Control Integration

Interactive SQL integrates with third-party source control systems, allowing you to perform many common
source control operations on files from within Interactive SQL.

On Windows, Interactive SQL integrates with most source control products that support the Microsoft
Common Source Code Control API (MSSCCI), including Microsoft Visual SourceSafe. To use source control
products that do not support the MSSCCI API on Windows and other operating systems, specify a command
line to run for each source control action. Output from those commands appears in a log window.

Interactive SQL supports these tasks, as long as the task is supported in the source control product:

● Open a source control project


● Get
● Check in
● Check out
● Undo checkout
● Compare versions
● Show file history
● Show file properties
● Run the source control manager

If the underlying source control program does not support an action, its corresponding menu item is disabled.
For example, Visual SourceSafe supports all of these actions, but using a custom (command line) source
control system does not support opening a source control project, or running a source control manager.

You should be familiar with the operations of your source control program before attempting to use it from
Interactive SQL.

12.1 Configuring Interactive SQL to Use Source Control

You must configure Interactive SQL to use source control before you can perform source control actions on
files, such as checking files in and out, comparing different versions of a file, and viewing the history for a file.

If you are running Interactive SQL on a Windows computer that has a source control product that supports the
Microsoft SCC API, you can use that product or use a custom (command line oriented) system.

PUBLIC Interactive SQL Guide


94 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Source Control Integration
12.1.1 Configuring Source Control Integration on Windows

You can enable source control integration if you are running Interactive SQL on a Windows computer that has
a source control product that supports the Microsoft SCC API.

Prerequisites

Set up your source control system.

Procedure

1. Select Tools Options Source Control .


2. Select Enable Source Control Integration.
3. (Optional) Select Automatically check out files when editor contents are modified if you want source
files to be automatically checked out of the source control program when editor contents are modified.

12.1.2 Configuring Source Control Systems with a


Command Line Interface

You can enable source control integration if you are running Interactive SQL on a computer that has a custom
command line oriented source control product.

Prerequisites

Set up your source control system.

Procedure

1. Click Tools Options Source Control .


2. Select Enable Source Control Integration.
3. Click Configure.
4. In the Custom Source Control Options window, click Reset.
5. Select your source control system from the list, and then click OK.
6. Edit the commands in the list as necessary by selecting an action from the Source Control Actions list, and
then typing the corresponding command in the Command Line pane.

Interactive SQL Guide PUBLIC


Source Control Integration © 2015 SAP SE or an SAP affiliate company. All rights reserved. 95
When you are defining commands for your system in the Source Control Actions list, use the placeholder
[FILENAME] to represent the name of the file that is used when you run the command.

If you do not specify a command line for an action, the item in the File Source Control menu is
disabled.
7. Click OK once to save the Custom Source Control Options, and again to close the Options window.

Note
If the connected database does not support source control integration, you see an error message, and
source control extensions are disabled.

12.1.3 Exporting Custom Source Control Options

You can save custom source control options for later retrieval. The export file has a *.cfg extension.

Prerequisites

Enable source control integration.

Procedure

1. Click Tools Options Source Control .


2. Click Configure and then Export.
3. Type a file name and click Save.

Note
If the connected database does not support source control integration, you see an error message, and
source control extensions are disabled.

PUBLIC Interactive SQL Guide


96 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Source Control Integration
12.1.4 Importing Custom Source Control Options

You can load custom source control options from a *.cfg file.

Prerequisites

Enable source control integration.

Procedure

1. Click Tools Options Source Control .


2. Click Import and then Open.
3. Click OK

Note
If the connected database does not support source control integration, you see an error message, and
source control extensions are disabled.

12.2 Opening Source Control Projects

Some source control products require you to open a source control project before you can perform any other
source control actions.

The exact definition of what a project is depends on the source control system you are using. Typically, it is a
set of files that are under source control, along with a location on your local file system where working copies
of the files are placed. You usually have to provide some credentials, such as a user ID and password, to the
source control system to open a project.

If your source control system supports opening a source control project, the File > Source Control > Open
Source Control > Project menu item is enabled. Choosing this option from the File menu opens a source
control-specific window for opening a project. Once you open a project, you do not have to open it again, even
in subsequent Interactive SQL sessions. The project is opened automatically for you.

Interactive SQL Guide PUBLIC


Source Control Integration © 2015 SAP SE or an SAP affiliate company. All rights reserved. 97
12.3 Checking Out Files

Once you open a file in Interactive SQL, use the command on the File menu to check the file out.

Procedure

1. Select File Open and then browse to the file you want to open.

The file status (Checked In, Checked Out, or Not Controlled) appears on the status bar at the bottom of
the Interactive SQL window.

2. Select File Source Control Check Out .


3. Depending on which source control product you are using, you may be prompted for a comment or other
options as part of the check out procedure.

Note
If you are using an SCC-compliant source control system, the status is always accurate. However, if you
use the custom source control system, the status is based on whether the file is read-only or not. A
read-only file is assumed to be checked in, but no assumptions are made about editable files because
they could be either checked out or not controlled.

12.4 Checking In Files

When you are finished making edits to your file, you can check it back in from Interactive SQL.

Procedure

1. Select File Source Control Check In .


2. Enter check-in comments if you are prompted.

12.5 Additional Source Control Actions

In addition to opening source control projects, and checking files in and out, Interactive SQL supports several
other source control actions. The availability of these actions depends on the source control system you are
using.

Access these actions from the File Source Control menu in Interactive SQL.

PUBLIC Interactive SQL Guide


98 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Source Control Integration
Table 34:
Action Description

Get Gets the latest copy of the file you currently have open in the SQL Statements pane.

Undo Check Out Discards your working copy of the file, and then downloads the copy of the file that is
in the source control archive.

Compare Versions This action compares the working copy of the file you have opened against the ver­
sion in the source control archive.

History Displays a list of source control actions (typically check-ins) that have been made to
the file you have open.

Properties Displays a list of source control properties that are associated with the file you have
opened.

Run Source Control Manager Launches the management program for your source control system. For example, if
you are using Microsoft Visual SourceSafe, this launches Visual SourceSafe Explorer.

Interactive SQL Guide PUBLIC


Source Control Integration © 2015 SAP SE or an SAP affiliate company. All rights reserved. 99
13 Troubleshooting Hints

Troubleshoot problems that occur when using Interactive SQL.

13.1 Only the First Line of a Multiline Statement Is Executed

Problem: When you start Interactive SQL using the -nogui command line option, and you execute a multiline
statement, only the first line of the statement executes.

In -nogui mode, any SQL text you enter at the command prompt is executed when you press Enter, even if you
specify a command delimiter using the -d switch. Ensure the SQL command is complete before you press
Enter.

Solution: Do not start Interactive SQL using -nogui mode when executing multiline statements.

Related Information

Starting Interactive SQL from a Command Prompt [page 6]

PUBLIC Interactive SQL Guide


100 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Troubleshooting Hints
14 Appendix: SQL Statements and Options

Reference material for SQL statements and SQL options mentioned in this document.

14.1 SQL Statements for Interactive SQL

Interactive SQL statements can only be used from within Interactive SQL.

14.1.1 CLEAR Statement [Interactive SQL]

Closes any open result sets in Interactive SQL (dbisql).


Quick Links:

Go to Usage [page 101]

Go to Standards [page 102]

Go to Permissions [page 102]

Syntax

CLEAR

Usage

(back to top) [page 101]

Closes any open result sets and leaves the contents of the SQL Statements pane unchanged.

Side effects:

The CLEAR statement closes the cursor that is associated with the data being cleared.

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 101
Standards

(back to top) [page 101]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Not applicable.

Permissions

(back to top) [page 101]

None

14.1.2 CONFIGURE Statement [Interactive SQL]

Activates the Interactive SQL (dbisql) configuration window.


Quick Links:

Go to Usage [page 102]

Go to Standards [page 103]

Go to Permissions [page 103]

Syntax

CONFIGURE

Usage

(back to top) [page 102]

The dbisql configuration window displays the current settings of all dbisql options. It does not display or let
you modify database options.

If you select Permanent, the options are written to the SYSOPTION table in the database and the database
server performs an automatic COMMIT. If you do not choose Permanent, and instead click OK, options are set
temporarily and remain in effect only for the current database connection.

PUBLIC Interactive SQL Guide


102 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
Standards

(back to top) [page 102]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Not supported by SAP® Adaptive Server® Enterprise (SAP ASE).

Permissions

(back to top) [page 102]

None

14.1.3 CONNECT Statement [ESQL] [Interactive SQL]

Establishes a connection to the database identified by <database-name> running on the server identified by
<engine-name>.
Quick Links:

Go to Parameters [page 104]

Go to Examples [page 104]

Go to Usage [page 104]

Go to Standards [page 105]

Go to Permissions [page 105]

Syntax

Syntax 1

CONNECT
… [ TO <engine-name> ]
…[ DATABASE <database-name> ]
…[ AS <connection-name> ]
…[ USER ] <userid> [ IDENTIFIED BY ]

Syntax 2

CONNECT USING <connect-string>

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 103
Parameters

(back to top) [page 103]

● connect-string a list of parameter settings of the form keyword=<value>, and must be enclosed in single
quotes.

● AS connection can optionally be named by specifying the clause. This allows multiple connections to the
same database, or multiple connections to the same or different database servers, all simultaneously.
Each connection has its own associated transaction. You might even get locking conflicts between your
transactions if, for example, you try to modify the same record in the same database from two different
connections.

Examples

(back to top) [page 103]

Example 1

CONNECT usage from dbisql:

Connect to a database from dbisql. You are prompted for user ID and password.

CONNECT

Connect to the default database as DBA, from dbisql. You are prompted to enter a password.

CONNECT USER "DBA"

Connect to the demo database as the DBA, from dbisql,where <machine_iqdemo> is the engine name:

CONNECT
TO <machine>_iqdemo
USER "DBA"
IDENTIFIED BY sql

Connect to the demo database using a connect string, from dbisql:

CONNECT
USING 'UID=DBA;PWD=sql;DBN=iqdemo'

Usage

(back to top) [page 103]

Embedded SQL behavior if no <engine-name> is specified, the default local database server is assumed
(the first database server started). If no <database-name> is specified, the first database on the given
server is assumed.

PUBLIC Interactive SQL Guide


104 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
The user ID and password are used for permission checks on all dynamic SQL statements. By default, the
password is case-sensitive; the user ID is not. You can connect without a password by using a host
variable for the password and setting the value of the host variable to be the null pointer.
dbisql behavior if no database or server is specified in the CONNECT statement, dbisql remains
connected to the current database, rather than to the default server and database. If a database name is
specified without a server name, dbisql attempts to connect to the specified database on the current
server. You must specify the database name defined in the -n database switch, not the database file name.
If a server name is specified without a database name, dbisql connects to the default database on the
specified server. For example, if this batch is executed while connected to a database, the two tables are
created in the same database:

CREATE TABLE t1( c1 int );


CONNECT DBA IDENTIFIED BY sql;
CREATE TABLE t2 (c1 int );

No other database statements are allowed until a successful CONNECT statement has been executed.

The user ID and password check the permissions on SQL statements. If the password or the user ID and
password are not specified, the user is prompted to type the missing information. By default, the
password is case-sensitive; the user ID is not.

Multiple connections are managed through the concept of a current connection. After a successful connect
statement, the new connection becomes the current one. To switch to a different connection, use SET
CONNECTION. Executing a CONNECT statement does not close the existing connection (if any). Use
DISCONNECT to drop connections.

Static SQL statements use the user ID and password specified with the -l option on the SQLPP statement line.
If no -l option is given, the user ID and password of the CONNECT statement are used for static SQL statements
also.

Standards

(back to top) [page 103]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Open Client Embedded SQL supports a different syntax for the CONNECT
statement.

Permissions

(back to top) [page 103]

None

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 105
14.1.4 DISCONNECT Statement [Interactive SQL]

Drops a connection with the database.


Quick Links:

Go to Parameters [page 106]

Go to Examples [page 106]

Go to Usage [page 107]

Go to Standards [page 107]

Go to Permissions [page 107]

Syntax

DISCONNECT [ { <connection-name> | CURRENT | ALL } ]

Parameters

(back to top) [page 106]

● ALL drops all of the connections of the application to all database environments.

● CURRENT (default) drops the current connection.

Examples

(back to top) [page 106]

Example 1

To use DISCONNECT in Embedded SQL, enter:

EXEC SQL DISCONNECT :conn_name

Example 2

To use DISCONNECT from dbisql to disconnect all connections, enter:

DISCONNECT ALL

PUBLIC Interactive SQL Guide


106 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
Usage

(back to top) [page 106]

The DISCONNECT statement drops a connection with the database server and releases all resources used by it.
If the connection to be dropped was named on the CONNECT statement, the name can be specified.

An implicit ROLLBACK is executed on connections that are dropped.

Standards

(back to top) [page 106]

● SQL—ISO/ANSI SQL compliant.


● SAP Database Products—Supported by Open Client/Open Server.

Permissions

(back to top) [page 106]

None

14.1.5 OUTPUT Statement [Interactive SQL]

Writes the information retrieved by the current query to a file.


Quick Links:

Go to Parameters [page 108]

Go to Examples [page 109]

Go to Usage [page 110]

Go to Standards [page 110]

Go to Permissions [page 110]

Syntax

OUTPUT TO <filename>
[ APPEND ] [ VERBOSE ]
[ FORMAT output-format ]
[ ESCAPE CHARACTER <character> ]
[ DELIMITED BY <string> ]
[ QUOTE <string> [ ALL ] ]

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 107
[ COLUMN WIDTHS ( <integer>, … ) ]
[ HEXADECIMAL { ON | OFF | ASIS } ]
[ ENCODING <encoding> ]
[ WITH COLUMN NAMES ]
output-format
TEXT | FIXED | HTML | SQL | XML

Parameters

(back to top) [page 107]

● FORMAT the output format. If no FORMAT clause is specified, the Interactive SQL OUTPUT_FORMAT
database option setting is used.

● TEXT output is a TEXT format file with one row per line in the file. All values are separated by commas, and
strings are enclosed in apostrophes (single quotes). The delimiter and quote strings can be changed using
the DELIMITED BY and QUOTE clauses. If the ALL clause is specified in the QUOTE clause, all values (not
just strings) are quoted. TEXT is the default output format. Three other special sequences are also used.
The two characters \n represent a newline character, \\ represents a single \, and the sequence \xDD
represents the character with hexadecimal code DD.

If you are exporting Java methods that have string return values, you must use the HEXADECIMAL OFF
clause.

● FIXED output is fixed format with each column having a fixed width. The width for each column can be
specified using the COLUMN WIDTHS clause. No column headings are output in this format. If you omit
the COLUMN WIDTHS clause, the width for each column is computed from the data type for the column,
and is large enough to hold any value of that data type. The exception is that LONG VARCHAR and LONG
BINARY data defaults to 32KB.

● HTML output is in the Hyper Text Markup Language format.

● SQL output is an Interactive SQL INPUT statement required to re-create the information in the table.

Note
SAP IQ does not support the INPUT statement. Change this statement to a valid LOAD TABLE (or
INSERT) statement to use it to load data back in.

● XML output is an XML file encoded in UTF-8 and containing an embedded DTD. Binary values are encoded
in CDATA blocks with the binary data rendered as 2-hex-digit strings. The LOAD TABLE statement does
not accept XML as a file format.

● APPEND appends the results of the query to the end of an existing output file without overwriting the
previous contents of the file. By default, if you do not use APPEND clause, the OUTPUT statement
overwrites the contents of the output file. The APPEND clause is valid if the output format is TEXT, FIXED,
or SQL.

● VERBOSE error messages about the query, the SQL statement used to select the data, and the data itself
are written to the output file. By default, if you omit the VERBOSE clause, only the data is written to the file.
The VERBOSE clause is valid if the output format is TEXT, FIXED, or SQL.

PUBLIC Interactive SQL Guide


108 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
● ESCAPE CHARACTER the default escape character for characters stored as hexadecimal codes and
symbols is a backslash (\), so \x0A is the line feed character, for example. To change this default, use the
ESCAPE CHARACTER clause. For example, to use the exclamation mark as the escape character, enter:

... ESCAPE CHARACTER '!'

● DELIMITED BY for the TEXT output format only. The delimiter string, by default a comma, is placed
between columns.

● QUOTE for the TEXT output format only. The quote string, by default a single quote character, is placed
around string values. If ALL is specified in the QUOTE clause, the quote string is placed around all values,
not just around strings.

● COLUMN WIDTHS specifies column widths for the FIXED format output.

● HEXADECIMAL specifies how binary data is to be unloaded for the TEXT format only. When set to ON,
binary data is unloaded in the format 0xabcd. When set to OFF, binary data is escaped when unloaded
(\xab\xcd). When set to ASIS, values are written without any escaping even if the value contains control
characters. ASIS is useful for text that contains formatting characters such as tabs or carriage returns.

● ENCODING specifies the encoding that is used to write the file. You can use the ENCODING clause only
with the TEXT format. Can be a string or identifier. If you do not specify the ENCODING clause, Interactive
SQL determines the code page that is used to write the file as follows, where code page values occurring
earlier in the list take precedence over those occurring later:

● The code page specified with the DEFAULT_ISQL_ENCODING option (if this option is set)
● The default code page for the computer Interactive SQL is running on

Examples

(back to top) [page 107]

Example 1

places the contents of the Employees table in a text file:

SELECT * FROM Employees;


OUTPUT TO employees.txt FORMAT TEXT

Example 2

places the contents of the Employees table at the end of an existing file, and includes any messages about
the query in this file as well:

SELECT * FROM Employees;


OUTPUT TO employees.txt APPEND VERBOSE

Example 3
exports a value that contains an embedded line feed character. A line feed character has the numeric
value 10, which you can represent as the string '\x0a' in a SQL statement.

Execute this statement with HEXADECIMAL ON:

SELECT 'line1\x0aline2'; OUTPUT TO file.txt HEXADECIMAL ON

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 109
The result is a file with one line in it, containing this text:

line10x0aline2

Execute the same statement with HEXADECIMAL OFF:

line1\x0aline2

If you set HEXADECIMAL to ASIS, the result is a file with two lines:

'line1
line2'

Using ASIS generates two lines, because the embedded line feed character has been exported without
being converted to a two-digit hex representation, and without a prefix.

Usage

(back to top) [page 107]

The current query is the SELECT or LOAD TABLE statement that generated the information that appears on
the Results tab in the Results pane. The OUTPUT statement reports an error if there is no current query.

Note
OUTPUT is especially useful in making the results of a query or report available to another application, but is
not recommended for bulk operations. For high-volume data movement, use the ASCII and BINARY data
extraction functionality with the SELECT statement. The extraction functionality provides much better
performance for large-scale data movement, and creates an output file you can use for loads.

Side Effects

● In Interactive SQL, the Results tab displays only the results of the current query. All previous query results
are replaced with the current query results.

Standards

(back to top) [page 107]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Not applicable.

Permissions

(back to top) [page 107]

PUBLIC Interactive SQL Guide


110 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
None

14.1.6 PARAMETERS Statement [Interactive SQL]

Specifies parameters to an Interactive SQL (dbisql) command file.


Quick Links:

Go to Examples [page 111]

Go to Usage [page 111]

Go to Standards [page 112]

Go to Permissions [page 112]

Syntax

PARAMETERS <parameter1>, <parameter2>, …

Examples

(back to top) [page 111]

Example 1

this dbisql command file takes two parameters:

PARAMETERS department_id, file ;


SELECT Surname
FROM Employees
WHERE DepartmentID = {department_id}
>#{file}.dat;

Usage

(back to top) [page 111]

PARAMETERS specifies how many parameters there are to a command file and also names those parameters
so that they can be referenced later in the command file.

Parameters are referenced by putting the named parameter into the command file where you want the
parameter to be substituted:

{parameter1}

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 111
There can be no spaces between the braces and the parameter name.

If a command file is invoked with fewer than the required number of parameters, dbisql prompts for values of
the missing parameters.

Standards

(back to top) [page 111]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Not applicable.

Permissions

(back to top) [page 111]

None

14.1.7 READ Statement [Interactive SQL]

Reads Interactive SQL (dbisql) statements from a file.


Quick Links:

Go to Parameters [page 112]

Go to Examples [page 113]

Go to Standards [page 114]

Go to Permissions [page 114]

Syntax

READ [ ENCODING <encoding> ] <filename> [ <parameter> ] …

Parameters

(back to top) [page 112]

● ENCODING an identifier or string that specifies encoding that is used to read the file. The READ statement
does not process escape characters when it reads a file. It assumes that the entire file is in the specified

PUBLIC Interactive SQL Guide


112 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
encoding. When running Interactive SQL, the encoding that is used to read the data is determined in the
following order:

1. The encoding specified by the ENCODING clause, if used.


2. The encoding specified by the byte order mark (BOM) in the file, if used.
3. The encoding specified with the default_isql_encoding option, if used.
4. The default encoding for the platform you are running on.

● filename if <filename> has no file extension, Interactive SQL searches for the same file name with the
extension .sql.

If <filename> does not contain an absolute path, Interactive SQL searches for the file. The location of
<filename> is based on the location of the READ statement, as follows:

● If the READ statement is executed directly in Interactive SQL, Interactive SQL first attempts to resolve
the path to <filename> relative to the directory in which Interactive SQL is running. If unsuccessful,
Interactive SQL looks for <filename> in the directories specified in the environment variable
SQLPATH, then the directories specified in the environment variable PATH.
● If the READ statements reside in an external file (for example, a .sql file), Interactive SQL first
attempts to resolve the path to <filename> relative to the location of the external file. If
unsuccessful, Interactive SQL looks for <filename> in a path relative to the directory in which
Interactive SQL is running. If still unsuccessful, Interactive SQL looks in the directories specified in the
environment variable SQLPATH, then the directories specified in the environment variable PATH.

● parameters can be listed after the name of the SQL script file, and correspond to the parameters named
in the PARAMETERS statement at the beginning of the statement file. Parameter names must be enclosed
in square brackets. Interactive SQL substitutes the corresponding parameter wherever the source file
contains { <parameter-name> }.

The parameters passed to a script file can be identifiers, numbers, quoted identifiers, or strings. Any
quotes around a parameter are placed into the text during the substitution. Parameters that are not
identifiers, numbers, or strings (contain spaces or tabs) must be enclosed in square brackets ([ ]). This
allows for arbitrary textual substitution in the script file.

If not enough parameters are passed to the script file, Interactive SQL prompts for values for the missing
parameters.

When executing a reload.sql file with Interactive SQL, you must specify the encryption key as a
parameter. If you do not provide the key in the READ statement, Interactive SQL prompts for the key.

Examples

(back to top) [page 112]

Example 1

this example reads from the file status.rpt and birthday.sql and passes the parameter values to the
variables within the file:

READ status.rpt '160'

READ birthday.sql [>= '1988-1-1'] [<= '1988-1-30']

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 113
Example 2

this example uses the PARAMETERS clause to pass parameters to a script file:

[test1.sql]
PARAMETERS par1, par2;
BEGIN
DECLARE v_par1 int;
DECLARE v_par2 varchar(200)
SET v_par1 = {par1};
SET v_par2 = {par2};
MESSAGE STRING('PAR1 Value: ', v_par1 ) TO CLIENT;
MESSAGE STRING('PAR2 Value: ', v_par2 ) TO CLIENT;
END;

(USR1)> READ test1.sql 123 '041028'


PAR1 Value: 123
PAR2 Value: 041028

Note
The second parameter value 041028 must be enclosed in quotes, as <v_par2> is declared as a
character data type.

Standards

(back to top) [page 112]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Not applicable.

Permissions

(back to top) [page 112]

None

14.1.8 SET CONNECTION Statement [ESQL] [Interactive


SQL]

Changes the active database connection.


Quick Links:

Go to Examples [page 115]

Go to Usage [page 115]

Go to Standards [page 115]

PUBLIC Interactive SQL Guide


114 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
Go to Permissions [page 116]

Syntax

SET CONNECTION [<connection-name>]

Examples

(back to top) [page 114]

Example 1

from dbisql, set the current connection to the connection named “conn1”:

SET CONNECTION conn1

Usage

(back to top) [page 114]

The current connection state is saved, and resumed when it again becomes the active connection. If you omit
<connection-name>, but a connection exists, that was not named, that connection becomes the active
connection.

Note
When cursors are opened in Embedded SQL, they are associated with the current connection. When the
connection is changed, the cursor names are not accessible. The cursors remain active and in position and
become accessible when the associated connection becomes active again.

Standards

(back to top) [page 114]

● SQL— dbisql use is a vendor extension to ISO/ANSI SQL grammar. Embedded SQL is a full-level feature.
● SAP Database Products—Supported by Open Client/Open Server.

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 115
Permissions

(back to top) [page 114]

None

14.1.9 SET OPTION Statement [Interactive SQL]

Changes Interactive SQL (dbisql) options.


Quick Links:

Go to Usage [page 116]

Go to Permissions [page 117]

Syntax

Syntax 1

SET [ TEMPORARY ] OPTION


… [ <userid>. | PUBLIC.]<option-name> = [ <option-value> ]

Syntax 2

SET PERMANENT

Syntax 3

SET

Usage

(back to top) [page 116]

SET PERMANENT (Syntax 2) stores all current dbisql options in the SYSOPTION system table. These settings
are automatically established every time dbisql is started for the current user ID.

Syntax 3 shows all current option settings. If there are temporary options set for dbisql or the database
server, these are shown; otherwise, permanent option settings are shown.

If you incorrectly enter the name of an option when you are setting the option, the incorrect name is saved in
the SYSOPTION table. You can remove the incorrectly enterd name from the SYSOPTION table by setting the
option PUBLIC with an equality after the option name and no value:

SET OPTION PUBLIC.a_mistyped_name=;

PUBLIC Interactive SQL Guide


116 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
Permissions

(back to top) [page 116]

No specific system privileges are required to set your own options.

The SET ANY PUBLIC OPTION system privilege is required to set database options for another user.

The SET ANY SYSTEM OPTION system privilege is required to set a SYSTEM option for the PUBLIC user ID.

The SET ANY SECURITY OPTION system privilege is required to set a SECURITY option for the PUBLIC user
ID.

14.1.10 START DATABASE Statement [Interactive SQL]

Starts a database on the specified database server.


Quick Links:

Go to Parameters [page 117]

Go to Examples [page 118]

Go to Usage [page 118]

Go to Standards [page 118]

Go to Permissions [page 118]

Syntax

START DATABASE <database-file>


… [ AS <database-name >]
… [ ON <engine-name >]
… [ AUTOSTOP { YES | NO } ]
… [ KEY <key> ]

Parameters

(back to top) [page 117]

● database-name if not specified, a default name is assigned to the database. This default name is the root
of the database file. For example, a database in file c:\SAP\16_0\demo\iqdemo.db is given the default
name iqdemo.

● engine-name if not specified, the default database server is assumed. The default database server is the
first started server among those that are currently running.

● AUTOSTOP when set to YES (default), the database is unloaded when the last connection to it is dropped.
When set to NO, the database is not unloaded.

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 117
● KEY to enter the KEY value (password) for strongly encrypted databases.

Note
Start only one database on a given SAP IQ database server.

Examples

(back to top) [page 117]

Example 1

on a UNIX system, start the database file /s1/sybase/sample_2.db on the current server:

START DATABASE '/s1/sybase/sample_2.db'

Example 2

on a Windows system, start the database file c:\sybase\sample_2.db as sam2 on the server eng1:

START DATABASE 'c:\sybase\sample_2.db'


AS sam2
ON eng1

Usage

(back to top) [page 117]

The database server must be running. The full path must be specified for the database file unless the file is
located in the current directory.

The START DATABASE statement does not connect dbisql to the specified database you must also issue a
CONNECT statement to make a connection.

Standards

(back to top) [page 117]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Not applicable.

Permissions

(back to top) [page 117]

PUBLIC Interactive SQL Guide


118 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
Requires the SERVER OPERATOR system privilege.

14.1.11 START ENGINE Statement [Interactive SQL]

Starts a database server.


Quick Links:

Go to Parameters [page 119]

Go to Examples [page 119]

Go to Usage [page 120]

Go to Standards [page 120]

Go to Permissions [page 120]

Syntax

START ENGINE
AS <engine-name> [ STARTLINE <command-string> ]

Parameters

(back to top) [page 119]

● STARTLINE to specify a set of options for the server.

● command-string valid command strings conform to the database server command line description. See
start_iq Database Server Startup Utility in the Utility Guide.

Examples

(back to top) [page 119]

Example 1

starts a database server named eng1 without starting any databases on it:

START ENGINE AS eng1

Example 2
starts the same server with a cache of 8096KB:

START ENGINE AS eng1 STARTLINE 'start_iq -c 8096'

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 119
Usage

(back to top) [page 119]

Several server options are required for SAP IQ to operate well. To ensure that you are using the best options,
start your server by using either SAP IQ Cockpit or a configuration file with the start_iq command.

Standards

(back to top) [page 119]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Not applicable.

Permissions

(back to top) [page 119]

None

14.1.12 STOP DATABASE Statement [Interactive SQL]

Stops a database on the specified database server.


Quick Links:

Go to Parameters [page 121]

Go to Examples [page 121]

Go to Standards [page 121]

Go to Permissions [page 121]

Syntax

STOP DATABASE <database-name>


… [ ON <engine-name> ]
… [ UNCONDITIONALLY ]

PUBLIC Interactive SQL Guide


120 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
Parameters

(back to top) [page 120]

● database-name the name specified in the -n parameter when the database is started, or specified in the
DBN (DatabaseName) connection parameter. This name is typically the file name of the database file that
holds the catalog store, without the .db extension, but can be any user-defined name.

● engine-name if not specified, all running engines are searched for a database of the specified name.

● UNCONDITIONALLY if specified, the database is stopped, even if there are connections to the database. If
not specified, the database is not stopped if there are connections to it.

Examples

(back to top) [page 120]

Example 1

stop the database named sample on the default server:

STOP DATABASE sample

Standards

(back to top) [page 120]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Not applicable.

Permissions

(back to top) [page 120]

Requires the SERVER OPERATOR system privilege.

14.1.13 STOP ENGINE Statement [Interactive SQL]

Stops a database server.


Quick Links:

Go to Parameters [page 122]

Go to Examples [page 122]

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 121
Go to Standards [page 122]

Go to Permissions [page 122]

Syntax

STOP ENGINE <engine-name> [ UNCONDITIONALLY ]

Parameters

(back to top) [page 121]

● UNCONDITIONALLY if specified, the database server is stopped, even if there are connections to the
server. If not specified, the database server is not stopped if there are connections to it.

Examples

(back to top) [page 121]

Example 1

stop the database server named sample:

STOP ENGINE sample

Standards

(back to top) [page 121]

● SQL—Vendor extension to ISO/ANSI SQL grammar.


● SAP Database Products—Not applicable.

Permissions

(back to top) [page 121]

None

PUBLIC Interactive SQL Guide


122 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
14.2 SQL Options for Interactive SQL

Interactive SQL options are a subset of the SAP IQ SQL options, which change how Interactive SQL interacts
with the database.

14.2.1 DEFAULT_ISQL_ENCODING Option [Interactive SQL]

Specifies the code page used by READ and OUTPUT statements.

Allowed Values

<identifier> or <string>

Default

Use system code page (empty string)

Scope

Can only be set as a temporary option, for the duration of the current connection.

Remarks

DEFAULT_ISQL_ENCODING specifies the code page to use when reading or writing files. It cannot be set
permanently. The default code page is the default code page for the platform you are running on.

Interactive SQL determines the code page that is used for a particular OUTPUT or READ statement as follows,
where code page values occurring earlier in the list take precedence over those occurring later in the list:

● The code page specified in the ENCODING clause of the OUTPUT or READ statement
● The code page specified with the DEFAULT_ISQL_ENCODING option (if this option is set)
● The default code page for the computer on which Interactive SQL is running

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 123
Example

Set the encoding to UTF-16 (for reading Unicode files):

SET TEMPORARY OPTION DEFAULT_ISQL_ENCODING = 'UTF-16'

14.2.2 ON_ERROR Option [Interactive SQL]

Controls the action taken if an error is encountered while executing statements in Interactive SQL.

Allowed Values

Table 35:
Value Description

STOP Interactive SQL stops executing statements from the file and returns to the state­
ment window for input.

PROMPT Interactive SQL prompts the user whether to continue.

CONTINUE Errors appear in the Messages pane, and Interactive SQL continues executing
statements.

EXIT Interactive SQL terminates.

NOTIFY_CONTINUE The error is reported, and the user is prompted to continue.

NOTIFY_STOP The error is reported, and the user is prompted to stop executing statements.

NOTIFY_EXIT The error is reported, and the user is prompted to terminate Interactive SQL.

Default

PROMPT

Remarks

Controls the action taken, if an error is encountered while executing statements. When you are executing
a .SQL file, the values STOP and EXIT are equivalent.

PUBLIC Interactive SQL Guide


124 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Appendix: SQL Statements and Options
14.2.3 QUERY_PLAN_TEXT_ACCESS Option

Enables or prevents users from accessing query plans from the Interactive SQL client or from using SQL
functions to get plans.

Allowed Values

ON, OFF

Default

OFF

Scope

Option can be set at the database (PUBLIC) or user level. At the database level, the value becomes the default
for any new user, but has no impact on existing users. At the user level, overrides the PUBLIC value for that
user only. No system privilege is required to set option for self. System privilege is required to set at database
level or at user level for any user other than self.

Requires the SET ANY SYSTEM OPTION system privilege to set this option. Can be set temporary for an
individual connection or for the PUBLIC role. Takes effect immediately.

Remarks

When QUERY_PLAN_TEXT_ACCESS option is ON, users can view, save, and print query plans from the
Interactive SQL client. When the option is OFF, query plans are not cached, and other query plan-related
database options have no effect on the query plan that is shown from the Interactive SQL client. This error
message appears:

No plan available. The database option QUERY_PLAN_TEXT_ACCESS is OFF.

Interactive SQL Guide PUBLIC


Appendix: SQL Statements and Options © 2015 SAP SE or an SAP affiliate company. All rights reserved. 125
Important Disclaimers and Legal Information

Coding Samples
Any software coding and/or code lines / strings ("Code") included in this documentation are only examples and are not intended to be used in a productive system
environment. The Code is only intended to better explain and visualize the syntax and phrasing rules of certain coding. SAP does not warrant the correctness and
completeness of the Code given herein, and SAP shall not be liable for errors or damages caused by the usage of the Code, unless damages were caused by SAP
intentionally or by SAP's gross negligence.

Accessibility
The information contained in the SAP documentation represents SAP's current view of accessibility criteria as of the date of publication; it is in no way intended to be
a binding guideline on how to ensure accessibility of software products. SAP in particular disclaims any liability in relation to this document. This disclaimer, however,
does not apply in cases of wilful misconduct or gross negligence of SAP. Furthermore, this document does not result in any direct or indirect contractual obligations of
SAP.

Gender-Neutral Language
As far as possible, SAP documentation is gender neutral. Depending on the context, the reader is addressed directly with "you", or a gender-neutral noun (such as
"sales person" or "working days") is used. If when referring to members of both sexes, however, the third-person singular cannot be avoided or a gender-neutral noun
does not exist, SAP reserves the right to use the masculine form of the noun and pronoun. This is to ensure that the documentation remains comprehensible.

Internet Hyperlinks
The SAP documentation may contain hyperlinks to the Internet. These hyperlinks are intended to serve as a hint about where to find related information. SAP does
not warrant the availability and correctness of this related information or the ability of this information to serve a particular purpose. SAP shall not be liable for any
damages caused by the use of related information unless damages have been caused by SAP's gross negligence or willful misconduct. All links are categorized for
transparency (see: http://help.sap.com/disclaimer).

PUBLIC Interactive SQL Guide


126 © 2015 SAP SE or an SAP affiliate company. All rights reserved. Important Disclaimers and Legal Information
Interactive SQL Guide PUBLIC
Important Disclaimers and Legal Information © 2015 SAP SE or an SAP affiliate company. All rights reserved. 127
www.sap.com/contactsap

© 2015 SAP SE or an SAP affiliate company. All rights reserved.


No part of this publication may be reproduced or transmitted in any
form or for any purpose without the express permission of SAP SE
or an SAP affiliate company. The information contained herein may
be changed without prior notice.
Some software products marketed by SAP SE and its distributors
contain proprietary software components of other software
vendors. National product specifications may vary.
These materials are provided by SAP SE or an SAP affiliate company
for informational purposes only, without representation or warranty
of any kind, and SAP or its affiliated companies shall not be liable for
errors or omissions with respect to the materials. The only
warranties for SAP or SAP affiliate company products and services
are those that are set forth in the express warranty statements
accompanying such products and services, if any. Nothing herein
should be construed as constituting an additional warranty.
SAP and other SAP products and services mentioned herein as well
as their respective logos are trademarks or registered trademarks
of SAP SE (or an SAP affiliate company) in Germany and other
countries. All other product and service names mentioned are the
trademarks of their respective companies.
Please see http://www.sap.com/corporate-en/legal/copyright/
index.epx for additional trademark information and notices.

You might also like