Scripts with multiple statements return errors. Some database commands or symbols do not work in Aqua Data Studio while they do work in the database vendor’s command line tool.

by Nov 4, 2011

Scripts with multiple statements return errors. Some database commands or symbols (such as “;”) do not work in Aqua Data Studio while they do work in the database vendor’s command line tool.

Response

Jonathan Powers over 11 years ago
Example:

select * from t1
select * from t2
select * from t3

This script returns errors.

A: Aqua Data Studio uses “go” or “/” symbols as line separators between statements. Here is a corrected example of the same script:

select * from t1
/
select * from t2
/
select * from t3
/

or

select * from t1
go
select * from t2
go
select * from t3
go

Q: Some database commands do not work in Aqua Data Studio while they do work in command line tools, such as Oracle SQL*Plus, provided by database vendors.

A: Databases have server SQL commands, as well as commands that are part of the vendor’s command line tool. Server SQL commands are executed on the server, while command line commands are executed on the client by its native library. The command line tool recognizes the client-side commands and does not send them to the server. This means that, using the vendor’s command line tool, you can write scripts that execute both server SQL commands and client-side commands. Unfortunately, client-side commands are not typically specified by database vendors. ADS is therefore designed to send only server commands specific to each database vendor; if the script contains a client-side command, it will be sent to the server which will not recognize it and return an error.

Examples:

DB2

“RUNSTATS” is a client-side command. If you execute RUNSTATS in ADS, it will be sent to the server for execution. However, because RUNSTATS is a client-side command, the DB2 server will not recognize it and return an error.

Oracle

The output formatting commands below are commands specific to SQL*Plus:

set lines 100
col name format a10
col path format a30

Aqua Data Studio does not require the use of these commands, since it pre-formats text results and provides Grid Results. If entered, these commands will be sent to the database and the server will return an error.

MySQL

The “delimiter” command is not a command understood by the MySQL server. It is a command understood only by the MySQL command line tool, and used to interpret the SQL script before sending it to the server. The following shows you how to execute the script using ADS:

MySQL command tool script

ADS script

use ctom_dev;

drop procedure if exists init_ctom_db;

delimiter ||

create procedure init_ctom_db()

begin /* procedure */

…procedure building

end /* procedure */;

||

call init_ctom_db();

flush tables;

drop procedure init_ctom_db;

use ctom_dev
/
drop procedure if exists init_ctom_db
/
create procedure init_ctom_db()
begin /* procedure */
…procedure building
end /* procedure */;
/
call init_ctom_db()
/
flush tables
/
drop procedure init_ctom_db
/

Using Semicolons ” ; ” in Aqua Data Studio scripts

Q: Is there a way to run Oracle scripts that contain semicolons in Aqua Data Studio? A script with a semicolon returns an “invalid character” error.

A: ADS does not support “;” as the statement separator, although it can be enabled when not using Stored Procedures by selecting File->Options->Scripts->->[‘;’ Statement separator].

If you enable and try to use semicolons in scripts with procedural bodies, it will likely cause problems.

Using the “/” statement separator allows you to run scripts in ADS and SQL*Plus without modification.