By default, the SQL and XQuery editor uses a
semicolon ( ; ) as the default statement terminator. You can change
the default statement terminator or specify a different statement
terminator for the SQL statements in a script that you create in the
SQL and XQuery editor.
Before you begin
The SQL script for which you want to change the statement
terminator must be open in the SQL and XQuery editor.
About this task
A script can have multiple statement terminator commands.
A statement terminator applies to all of the SQL statements that follow
it, until the next statement terminator command is encountered. You
can specify different statement terminators in different SQL scripts.
The
statement terminator that you specify in an SQL script persists every
time that you open the script in the SQL and XQuery editor.
Procedure
To change the statement terminator for the SQL statements
in an SQL script:
- Open a script from the Data Project Explorer. When
you open a script the first time, or when you paste text into the
script, you are asked to specify a SQL statement terminator. This
adds a special comment statement to the script that is recognized
only by Data Studio: --<ScriptOptions statementTerminator
= "x"/>.
At any time, you can specify
a terminator by adding the DB2 statement --#SET TERMINATOR
x, where x is the terminator
character. This statement is recognized by both Data Studio and the
DB2 command line processor. The statement must be uppercase and in
a comment. There can be leading spaces before the --,
but there cannot be spaces between -- and #SET
TERMINATOR x. See the DB2 documentation
for more information about the #SET TERMINATOR statement.
- Use the command pane in the SQL and XQuery editor:
- Open the Validation tab.
- In the Set statement terminator box,
type a single character to use as the statement terminator.
- Use the pop-up menu in the editor:
- Right-click in the editor, and then select Set
Statement Terminator.
- In the Set Statement Terminator window,
type a single character to use as the statement terminator and then
click OK.
Results
If you specify a statement terminator other than the default,
a special comment statement is added to the top of the SQL script
that indicates the statement terminator that you specified. For example,
if you specified the terminator using the command pane or the pop-up
menu, the comment looks like this:
--<ScriptOptions statementTerminator = "x"/>
Existing
occurrences of the default statement terminator are not updated in
the SQL script; you must change them manually.