interactive sql guide - sap · pdf file1 start interactive sql there are several ways to start...

128
PUBLIC SAP IQ 16.0 SP08 Document Version: 4.0 ( 2014-12-29 ) Interactive SQL Guide

Upload: phungnhi

Post on 30-Jan-2018

232 views

Category:

Documents


6 download

TRANSCRIPT

Page 1: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

PUBLIC

SAP IQ 16.0 SP08Document Version: 4.0 ( 2014-12-29 )

Interactive SQL Guide

Page 2: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Content

1 Start Interactive SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.1 Starting Interactive SQL from the Windows Start Menu. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61.2 Starting Interactive SQL from a Command Prompt. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6

1.2.1 Interactive SQL Command Line Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2 Connect to a Database. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.1 Connect Using a Connection Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.2 Connect Window Tools. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.3 Connecting Using an ODBC Data Source. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.4 Connecting to a Running Database on this Computer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132.5 Connecting to a Running Database on Another Computer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142.6 Connecting to a Logical Server. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152.7 Starting and Connecting to a Database on this Computer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162.8 Starting and Connecting to a Database on Another Computer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172.9 Connecting with a Connection String . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .18

2.9.1 Connection Parameters for Interactive SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .192.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. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416.1 Changing the Number of Spaces that are Indented. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416.2 Configuring Clearing of the SQL Statements Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .416.3 Configuring the Query Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426.4 Configuring the Execute Statements Button. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436.5 Creating a Header or Footer for Printed Output. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436.6 Setting Quiet Mode Prerequisites. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446.7 Disabling Warning Messages. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446.8 Disabling Table Editing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456.9 Setting Interactive SQL as the Default Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 456.10 Configuring Text Completion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46

7 Build and Execute Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .477.1 Using Text Completion. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

7.1.1 Text Completion Keyboard Shortcuts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47

2P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideContent

Page 3: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

7.2 Comments in SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487.2.1 Converting Statements to Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 487.2.2 Removing Comments. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

7.3 Indent SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 507.3.1 Adding or Increasing Indentation of SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . 507.3.2 Removing or Decreasing Indentation of SQL Statements. . . . . . . . . . . . . . . . . . . . . . . . . 51

7.4 Text Editing Keyboard Shortcuts. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 517.5 Look Up Tables, Views, Columns, and Procedures. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

7.5.1 Looking Up Table Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .527.5.2 Looking Up Table Column Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .537.5.3 Looking Up View Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547.5.4 Looking Up View Column Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 547.5.5 Looking Up Procedure Names. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

7.6 Clearing the SQL Statements Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 567.7 Execute Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

7.7.1 Executing All Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 577.7.2 Executing Selected Queries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 587.7.3 Executing Queries One at a Time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

7.8 Recall Previously Executed Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607.8.1 Scrolling Through Previously Executed Commands. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 607.8.2 Use Execution History. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

7.9 Executing COMMIT and ROLLBACK Statements. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

8 Result Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658.1 Showing Multiple Result Sets (UNIX). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 658.2 Showing Multiple Result Sets (Windows). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 668.3 Edit Result Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66

8.3.1 Editing Table Values in the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 678.3.2 Inserting a New Row into the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 698.3.3 Inserting a New Row Using the INPUT Statement. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 708.3.4 Deleting Rows from the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 718.3.5 Copying Rows from the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 728.3.6 Copying Columns from the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738.3.7 Copying Cells from the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 738.3.8 Sorting Columns in the Result Set. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

8.4 Generating SQL Statements from Result Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 758.5 Printing SQL Statements and Result Sets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

9 Favorites List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779.1 Showing or Hiding the Favorites Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779.2 Creating a Connection Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 779.3 Creating a SQL Statements Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

Interactive SQL GuideContent

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 3

Page 4: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

9.4 Creating a .sql File Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .799.5 Deleting a Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .809.6 Renaming a Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 809.7 Using a Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819.8 Editing a Favorite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 819.9 Exporting a Favorites List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 829.10 Importing a Favorites List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .829.11 Creating a Folder in the Favorites Pane. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 839.12 Adding a Favorite to a Favorites Folder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 839.13 Removing a Favorite from a Favorites Folder. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849.14 Reordering the Favorites List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

10 Build Queries with the Query Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8510.1 Creating a SELECT Query Using the Query Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8510.2 Configuring the Query Editor. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88

11 View Query Execution Plans. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8911.1 Starting the Plan Viewer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .8911.2 Generating a Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9011.3 Customizing the Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9011.4 Saving a Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9111.5 Opening a Saved Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9211.6 Printing a Query Plan. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9211.7 Customizing the Query Pane in the Plan Viewer. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

12 Source Control Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9412.1 Configuring Interactive SQL to Use Source Control. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .94

12.1.1 Configuring Source Control Integration on Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . 9512.1.2 Configuring Source Control Systems with a Command Line Interface. . . . . . . . . . . . . . . . 9512.1.3 Exporting Custom Source Control Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9612.1.4 Importing Custom Source Control Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96

12.2 Opening Source Control Projects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9712.3 Checking Out Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9712.4 Checking In Files. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9812.5 Additional Source Control Actions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98

13 Troubleshooting Hints. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9913.1 Only the First Line of a Multiline Statement Is Executed. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99

14 Appendix: SQL Statements and Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10014.1 SQL Statements for Interactive SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

14.1.1 CLEAR Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10014.1.2 CONFIGURE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

4P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideContent

Page 5: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

14.1.3 CONNECT Statement [ESQL] [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10214.1.4 DISCONNECT Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10514.1.5 OUTPUT Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10614.1.6 PARAMETERS Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11014.1.7 READ Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11114.1.8 SET CONNECTION Statement [ESQL] [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . 11414.1.9 SET OPTION Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11514.1.10 START DATABASE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11614.1.11 START ENGINE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11814.1.12 STOP DATABASE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12014.1.13 STOP ENGINE Statement [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

14.2 SQL Options for Interactive SQL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12214.2.1 DEFAULT_ISQL_ENCODING Option [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . 12314.2.2 ON_ERROR Option [Interactive SQL]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12414.2.3 QUERY_PLAN_TEXT_ACCESS Option. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124

Interactive SQL GuideContent

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 5

Page 6: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

1. 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

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

Procedure

1. For:

6P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideStart Interactive SQL

Page 7: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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> ]

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

ExampleThis 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"

Interactive SQL GuideStart Interactive SQL

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 7

Page 8: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 var­iable SQLCONNECT is used.

Depending on the connection parameters specified, if Interactive SQL cannot connect, 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.

NoteAlways specify connection parameters for Interactive SQL instead of relying on de­faults 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 subnets, spec­ify the communications protocol parameter with host number.

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

Command delimiters are used for all connections in the current Interactive SQL session, regardless of the setting stored in the database (for either the user or the PUBLIC set­ting).

-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.

NoteThe 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 Any­where 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 Anywhere 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, Interactive 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.

8P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideStart Interactive SQL

Page 9: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Option Description

-nogui Runs Interactive SQL in a command-prompt mode, without a graphical user interface. 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.

NoteIn -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. En­sure 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 com­mand 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 option does not suppress error messages.

NoteIf the data extraction commands (primarily setting the option TEMP_EX­TRACT_NAME1 to an output file) are contained in a command file, you must enable the Show all result sets option before using the -q option. See Setting 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 check­ing long command files for syntax errors.

Interactive SQL GuideStart Interactive SQL

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 9

Page 10: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Related Information

Setting Quiet Mode Prerequisites [page 44]Setting Quiet Mode Prerequisites [page 44]

10P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideStart Interactive SQL

Page 11: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 11

Page 12: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 successful connection.

Copy Connection String to Clipboard Creates a connection string from the options you have speci­fied, 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.

TipInformation 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.

12P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 13: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 13

Page 14: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 28]Password (PWD) Connection Parameter [page 31]ServerName (Server) Connection Parameter [page 32]Userid (UID) Connection Parameter [page 35]

14P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 15: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 28]Password (PWD) Connection Parameter [page 31]Userid (UID) Connection Parameter [page 35]

Interactive SQL GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 15

Page 16: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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]Password (PWD) Connection Parameter [page 31]ServerName (Server) Connection Parameter [page 32]StartLine (START) Connection Parameter [page 33]

16P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 17: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

Related Information

AutoStop (ASTOP) Connection Parameter [page 19]DatabaseFile (DBF) Connection Parameter [page 22]

Interactive SQL GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 17

Page 18: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

DatabaseKey (DBKEY) Connection Parameter [page 23]Host Connection Parameter [page 28]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;

TipAny 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.

18P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 19: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 19

Page 20: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

NoteSAP 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.

20P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 21: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

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 28]ServerName (Server) Connection Parameter [page 32]

Interactive SQL GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 21

Page 22: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

22P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 23: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 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.

CautionThe 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 GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 23

Page 24: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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>

24P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 25: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

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 GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 25

Page 26: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

26P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 27: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

CautionWhen 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).

Related Information

Password (PWD) Connection Parameter [page 31]

Interactive SQL GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 27

Page 28: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

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> ] ...

28P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 29: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

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.

Interactive SQL GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 29

Page 30: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Option Description

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.

NoteThe 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]

30P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 31: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

CautionWhen 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 GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 31

Page 32: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

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.

32P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 33: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

NoteInclude 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 28]

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 database server using the value you enter here. The database server does not automatically start if you

Interactive SQL GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 33

Page 34: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

NoteTo 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

34P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 35: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Related Information

CommLinks (LINKS) connection parameter [page 20]Host Connection Parameter [page 28]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 GuideConnect to a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 35

Page 36: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

36P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideConnect to a Database

Page 37: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideDisconnect from a Database

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 37

Page 38: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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]

38P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideUser Interface Navigation

Page 39: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 re­maining 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 GuideKeyboard Shortcuts

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 39

Page 40: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

40P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideKeyboard Shortcuts

Page 41: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideCustomize Interactive SQL Behavior

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 41

Page 42: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 .

NoteYou 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 column names

Use fully qualified table and column names when constructing SELECT statements.

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.

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

3. Click OK.

42P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideCustomize Interactive SQL Behavior

Page 43: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideCustomize Interactive SQL Behavior

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 43

Page 44: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

CautionThe 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.

44P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideCustomize Interactive SQL Behavior

Page 45: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

NoteYou 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 GuideCustomize Interactive SQL Behavior

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 45

Page 46: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

46P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideCustomize Interactive SQL Behavior

Page 47: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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, includ­ing data types. For stored procedures, inserts the procedure name, followed by a comma-separated list of parameter 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 GuideBuild and Execute Queries

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 47

Page 48: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 window.

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

NoteYou 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)

NoteThere 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.

48P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild and Execute Queries

Page 49: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Procedure

1. To:

Table 10:

Task Action

Comment a single line of text. Position the cursor anywhere on the line to be commented; 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

NoteYou 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.

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.

Interactive SQL GuideBuild and Execute Queries

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 49

Page 50: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Task Action

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.

Related Information

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

50P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild and Execute Queries

Page 51: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

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

Interactive SQL GuideBuild and Execute Queries

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 51

Page 52: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Key Task

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

NoteThe 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 and when you

insert the table name into the SQL statement.

52P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild and Execute Queries

Page 53: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

NoteYou 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

NoteThe 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.

NoteYou 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.

Interactive SQL GuideBuild and Execute Queries

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 53

Page 54: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

NoteThe 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.

NoteYou 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.

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

NoteThe lookup feature is not available in the Query Plan Viewer.

54P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild and Execute Queries

Page 55: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

NoteYou 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

NoteThe lookup feature is not available in the Query Plan Viewer.

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.

NoteYou can only insert one procedure name at a time.

Interactive SQL GuideBuild and Execute Queries

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 55

Page 56: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

1. 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

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

Related Information

Configuring Clearing of the SQL Statements Pane [page 41]

7.7 Execute Queries

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

56P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild and Execute Queries

Page 57: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 aTable1SELECT * 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

1. 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.

Related Information

Configuring the Execute Statements Button [page 43]

Interactive SQL GuideBuild and Execute Queries

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 57

Page 58: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 aTable1SELECT * 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.

NoteThe queries must be selectable as a single block.

2. Do one of:

○ Press F9.

○ Select SQL Execute Selection .○ (If configured) Click the Execute selected statement(s) icon on the Interactive SQL toolbar.

58P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild and Execute Queries

Page 59: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 aTable1SELECT * 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

As you step through each query, the next sequential query to run is highlighted.

Interactive SQL GuideBuild and Execute Queries

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 59

Page 60: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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:

○ Press Alt+Right Arrow, or

○ Select SQL Next SQL .

60P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild and Execute Queries

Page 61: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

1. 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.3. Click OK.

Interactive SQL GuideBuild and Execute Queries

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 61

Page 62: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

CautionDo 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.

62P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild and Execute Queries

Page 63: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

7.8.2.5 Removing Executed Commands from the SQL History Window

Clear select commands or all commands from the History window.

Context

CautionYou 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 mul­tiple 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 GuideBuild and Execute Queries

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 63

Page 64: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

NoteExecuting 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.

64P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild and Execute Queries

Page 65: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideResult Sets

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 65

Page 66: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

Related Information

66P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideResult Sets

Page 67: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 Re­sults Set Text Editor.

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

NoteThe Set to NULL option appears only if the column allows 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 GuideResult Sets

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 67

Page 68: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

NoteThe 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

1. 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.

68P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideResult Sets

Page 69: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

Interactive SQL GuideResult Sets

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 69

Page 70: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

○ Once (DEFAULT) is removed from the field, it cannot be restored. Manually enter the value of the default in the field.

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.

NoteBy 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.

70P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideResult Sets

Page 71: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

NoteYou 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 additional row to be selected.

2. Do one of:

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

CautionThere 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 GuideResult Sets

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 71

Page 72: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 additional 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.

72P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideResult Sets

Page 73: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 press­ing 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 addi­tional 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 of the

Interactive SQL GuideResult Sets

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 73

Page 74: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 34 5 67 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,36

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

1,34,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 pressing 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 additional row to be selected.

NoteAdditional cells may become automatically selected.

2. Do one of:

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

74P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideResult Sets

Page 75: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 additional 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 GuideResult Sets

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 75

Page 76: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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]

76P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideResult Sets

Page 77: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

1. 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 GuideFavorites List

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 77

Page 78: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

○ 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.

NoteIf 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

NoteEach 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 pane. 1. Select Favorites Add To Favorites or press Ctrl+D.2. Select Add SQL statements.

78P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideFavorites List

Page 79: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Action Task

Save select text in the SQL Statements pane.

1. Select the text to be saved as a favorite.

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 pane. 1. Select Favorites Add To Favorites or press Ctrl+D.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 pane.

1. Select the text to be saved as a favorite.

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 GuideFavorites List

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 79

Page 80: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

5. Click OK.

9.5 Deleting a Favorite

Delete a favorite from the favorites list.

Procedure

1. 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.

80P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideFavorites List

Page 81: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

1. 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 GuideFavorites List

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 81

Page 82: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

82P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideFavorites List

Page 83: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

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

Procedure

1. 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 GuideFavorites List

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 83

Page 84: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

9.13 Removing a Favorite from a Favorites Folder

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

Context

NoteYou 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

1. 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.

84P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideFavorites List

Page 85: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideBuild Queries with the Query Editor

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 85

Page 86: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Table 28:

Task Action

Import an existing SELECT statement into the Query Editor.

If there is only one recognizable SELECT statement in the SQL State­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 Editor.

Ensure the SQL Statements pane is empty or does not contain a single 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 auto­matically 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 Editor 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 Ta­bles 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.

86P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild Queries with the Query Editor

Page 87: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 column,

and click Right; the column appears in the right pane. You can only add one col­umn 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.

NoteIf 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 SQL Statements pane is replaced with the SELECT statement from the Query Editor. There is no confirmation prompt before overwriting.

Interactive SQL GuideBuild Queries with the Query Editor

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 87

Page 88: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

10.2 Configuring the Query Editor

You can customize some Query Editor behavior.

Procedure

1. Select Tools Options SAP Sybase IQ Query Editor .

NoteYou 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 column names

Use fully qualified table and column names when constructing SELECT statements.

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.

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

3. Click OK.

88P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideBuild Queries with the Query Editor

Page 89: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideView Query Execution Plans

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 89

Page 90: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

NoteThe 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

NoteIf 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.

90P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideView Query Execution Plans

Page 91: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 optimizer 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 GuideView Query Execution Plans

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 91

Page 92: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

1. Do one of:

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

92P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideView Query Execution Plans

Page 93: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideView Query Execution Plans

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 93

Page 94: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

94P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideSource Control Integration

Page 95: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideSource Control Integration

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 95

Page 96: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

NoteIf 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.

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

12.1.4 Importing Custom Source Control Options

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

Prerequisites

Enable source control integration.

96P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideSource Control Integration

Page 97: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Procedure

1. Click Tools Options Source Control .2. Click Import and then Open.3. Click OK

NoteIf 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.

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.

Interactive SQL GuideSource Control Integration

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 97

Page 98: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

NoteIf 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.

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 version 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.

98P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideSource Control Integration

Page 99: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

Interactive SQL GuideTroubleshooting Hints

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 99

Page 100: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 100]

Go to Standards [page 101]

Go to Permissions [page 101]

Syntax

CLEAR

Usage

(back to top) [page 100]

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.

100P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 101: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Standards

(back to top) [page 100]

● SQL—Vendor extension to ISO/ANSI SQL grammar.● SAP Database products—Not applicable.

Permissions

(back to top) [page 100]

None

14.1.2 CONFIGURE Statement [Interactive SQL]

Activates the Interactive SQL (dbisql) configuration window.Quick Links:

Go to Usage [page 101]

Go to Standards [page 102]

Go to Permissions [page 102]

Syntax

CONFIGURE

Usage

(back to top) [page 101]

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.

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 101

Page 102: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Standards

(back to top) [page 101]

● 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 101]

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 103]

Go to Examples [page 103]

Go to Usage [page 103]

Go to Standards [page 104]

Go to Permissions [page 104]

Syntax

Syntax 1

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

Syntax 2

CONNECT USING <connect-string>

102P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 103: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Parameters

(back to top) [page 102]

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

ASconnection 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 102]

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>_iqdemoUSER "DBA"IDENTIFIED BY sql

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

CONNECTUSING 'UID=DBA;PWD=sql;DBN=iqdemo'

Usage

(back to top) [page 102]

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 103

Page 104: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

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 102]

● 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 102]

None

104P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 105: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

14.1.4 DISCONNECT Statement [Interactive SQL]

Drops a connection with the database.Quick Links:

Go to Parameters [page 105]

Go to Examples [page 105]

Go to Usage [page 106]

Go to Standards [page 106]

Go to Permissions [page 106]

Syntax

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

Parameters

(back to top) [page 105]

ALLdrops all of the connections of the application to all database environments.

CURRENT(default) drops the current connection.

Examples

(back to top) [page 105]

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

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 105

Page 106: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Usage

(back to top) [page 105]

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 105]

● SQL—ISO/ANSI SQL compliant.● SAP Database products—Supported by Open Client/Open Server.

Permissions

(back to top) [page 105]

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 107]

Go to Examples [page 109]

Go to Usage [page 109]

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 ] ]

106P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 107: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

[ COLUMN WIDTHS ( <integer>, … ) ] [ HEXADECIMAL { ON | OFF | ASIS } ] [ ENCODING <encoding> ] [ WITH COLUMN NAMES ]

output-format TEXT | FIXED | HTML | SQL | XML

Parameters

(back to top) [page 106]

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

TEXToutput 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.

FIXEDoutput 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.

HTMLoutput is in the Hyper Text Markup Language format.

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

NoteSAP 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.

XMLoutput 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.

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 107

Page 108: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

APPENDappends 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.

VERBOSEerror 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.

ESCAPE CHARACTERthe 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 BYfor the TEXT output format only. The delimiter string, by default a comma, is placed between columns.

QUOTEfor 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 WIDTHSspecifies column widths for the FIXED format output.

HEXADECIMALspecifies 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.

ENCODINGspecifies 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

108P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 109: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Examples

(back to top) [page 106]

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 3exports 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

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:

'line1line2'

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 106]

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.

NoteOUTPUT 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

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 109

Page 110: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 106]

● SQL—Vendor extension to ISO/ANSI SQL grammar.● SAP Database products—Not applicable.

Permissions

(back to top) [page 106]

None

14.1.6 PARAMETERS Statement [Interactive SQL]

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

Go to Examples [page 110]

Go to Usage [page 111]

Go to Standards [page 111]

Go to Permissions [page 111]

Syntax

PARAMETERS <parameter1>, <parameter2>, …

Examples

(back to top) [page 110]

110P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 111: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Example 1

this dbisql command file takes two parameters:

PARAMETERS department_id, file ;SELECT SurnameFROM EmployeesWHERE DepartmentID = {department_id}>#{file}.dat;

Usage

(back to top) [page 110]

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}

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 110]

● SQL—Vendor extension to ISO/ANSI SQL grammar.● SAP Database products—Not applicable.

Permissions

(back to top) [page 110]

None

14.1.7 READ Statement [Interactive SQL]

Reads Interactive SQL (dbisql) statements from a file.Quick Links:

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 111

Page 112: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 111]

ENCODINGan 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 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.

filenameif <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.

parameterscan 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

112P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 113: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 111]

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']

Example 2

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

[test1.sql]PARAMETERS par1, par2;

BEGINDECLARE 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: 123PAR2 Value: 041028

NoteThe second parameter value 041028 must be enclosed in quotes, as <v_par2> is declared as a character data type.

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 113

Page 114: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.8 SET CONNECTION Statement [ESQL] [Interactive SQL]

Changes the active database connection.Quick Links:

Go to Examples [page 114]

Go to Usage [page 115]

Go to Standards [page 115]

Go to Permissions [page 115]

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

114P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 115: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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.

NoteWhen 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.

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 116]

Syntax

Syntax 1

SET [ TEMPORARY ] OPTION … [ <userid>. | PUBLIC.]<option-name> = [ <option-value> ]

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 115

Page 116: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Syntax 2

SET PERMANENT

Syntax 3

SET

Usage

(back to top) [page 115]

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=;

Permissions

(back to top) [page 115]

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 117]

Go to Usage [page 118]

Go to Standards [page 118]

116P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 117: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 116]

database-nameif 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-nameif not specified, the default database server is assumed. The default database server is the first started server among those that are currently running.

AUTOSTOPwhen 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.

KEYto enter the KEY value (password) for strongly encrypted databases.

NoteStart only one database on a given SAP IQ database server.

Examples

(back to top) [page 116]

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'

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 117

Page 118: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 sam2ON eng1

Usage

(back to top) [page 116]

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 116]

● SQL—Vendor extension to ISO/ANSI SQL grammar.● SAP Database products—Not applicable.

Permissions

(back to top) [page 116]

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 119]

Go to Standards [page 119]

Go to Permissions [page 120]

118P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 119: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Syntax

START ENGINE AS <engine-name> [ STARTLINE <command-string> ]

Parameters

(back to top) [page 118]

STARTLINEto specify a set of options for the server.

command-stringvalid 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 118]

Example 1

starts a database server named eng1 without starting any databases on it:

START ENGINE AS eng1

Example 2starts the same server with a cache of 8096KB:

START ENGINE AS eng1 STARTLINE 'start_iq -c 8096'

Usage

(back to top) [page 118]

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 118]

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 119

Page 120: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

● SQL—Vendor extension to ISO/ANSI SQL grammar.● SAP Database products—Not applicable.

Permissions

(back to top) [page 118]

None

14.1.12 STOP DATABASE Statement [Interactive SQL]

Stops a database on the specified database server.Quick Links:

Go to Parameters [page 120]

Go to Examples [page 121]

Go to Standards [page 121]

Go to Permissions [page 121]

Syntax

STOP DATABASE <database-name> … [ ON <engine-name> ] … [ UNCONDITIONALLY ]

Parameters

(back to top) [page 120]

database-namethe 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-nameif not specified, all running engines are searched for a database of the specified name.

UNCONDITIONALLYif 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.

120P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 121: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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]

Go to Standards [page 122]

Go to Permissions [page 122]

Syntax

STOP ENGINE <engine-name> [ UNCONDITIONALLY ]

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 121

Page 122: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Parameters

(back to top) [page 121]

UNCONDITIONALLYif 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

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.

122P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 123: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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

Example

Set the encoding to UTF-16 (for reading Unicode files):

SET TEMPORARY OPTION DEFAULT_ISQL_ENCODING = 'UTF-16'

Interactive SQL GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 123

Page 124: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 state­ments.

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.

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

124P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideAppendix: SQL Statements and Options

Page 125: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

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 GuideAppendix: SQL Statements and Options

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 125

Page 126: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Important Disclaimers and Legal Information

Coding SamplesAny 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.

AccessibilityThe 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 LanguageAs 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 HyperlinksThe 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).

126P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved.

Interactive SQL GuideImportant Disclaimers and Legal Information

Page 127: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

Interactive SQL GuideImportant Disclaimers and Legal Information

P U B L I C© 2014 SAP SE or an SAP affiliate company. All rights reserved. 127

Page 128: Interactive SQL Guide - SAP · PDF file1 Start Interactive SQL There are several ways to start Interactive SQL. 1.1 Starting Interactive SQL from the Windows Start Menu Start Interactive

www.sap.com/contactsap

© 2014 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.