Query analyzer scripts have support for 9 client-side commands which allow you to execute a stored procedure with local variables bound to the parameters.

See the AquaScripts and AquaProjects Section for much more complex scripting capabilities.

This allows for the execution of procedures with OUT parameters. The commands include print, println, variable, executeCallableQuery, sendMail, saveResults, saveLastResult, setResultSettings, and setPivotResultSettings.

Client-side commands are identified by a dot at the beginning of the command line, and multiple commands can be executed within one batch statement. The schema browser contains object scripting for procedures and functions that include "EXECUTE" and "EXECUTE BIND". The script EXECUTE will generate the appropriate code needed to execute the object according to the database procedural language (ie. PL/SQL, T-SQL). The EXECUTE BIND will generate the appropriate Aqua Data Studio client-side commands to execute the object. To easily generate the needed client commands to execute a procedure or function, you may browse in the schema browser to locate the procedure or function and right-click on the object to select "EXECUTE BIND" from the Script Object menus.

Command support

Query Analyzer scripts have support for client side commands ".sendMail", ".saveResults", ".saveLastResult", "setResultSettings", "setPivotResultSettings" which allow users to either save query results in an EXCEL, HTML, XML, or CSV document, or insert them into a table.

The 'sendMail' command sends emails using the settings you specify and allows attachments.

The 'saveResults' command saves the results of all of the queries in the window, while the 'saveLastResult' command only saves the result for the last query.

The 'setResultSettings' command lays out how grid data will be presented.

The 'setPivotResultSettings' command lays out how to pivot grid data will be presented.

Here is a combination example script using .setPivotResultSettings, .saveResults, and .sendMail which runs a query, takes data from that query, lays out, and generates a pivot grid result, saves the pivot grid results to two different Excel files, then emails a message with both Excel files as attachments.


.println [.print]

Syntax:
.println { | 'text value' }[, ... n]

Example:
.println myvar
.println ' Results:', OUTVAR


.variable

Syntax:
.variable , datatype [, value]

Example:
.variable myvar, varchar, 'this is a test'
.variable INVAR, NUMBER, 0
.variable OUTVAR, NUMBER, 0
.variable INOUTVAR, DATE, '2005-01-01 12:00:00 AM'


.executeCallableQuery

Syntax:
.executeCallableQuery 'parameter_name[, ... n]',
{ CALL ( ? { , ? ... } ) }
or ...
{ ? = CALL ( ? { , ? ... } ) }

Example:
.executeCallableQuery 'INVAR,OUTVAR,INOUTVAR',
BEGIN
    SCOTT.FULL_PROCEDURE(?, ?, ?);
END;


.sendMail

Syntax:
.sendMail 'host=mail.aquafold.com,
port=25,
ssl=TRUE,
authentication=TRUE,
user=myuser,
password=mypass,
from=admin@defghi.com,
to="user@abc.net,user1@abc.net, user2@abc.net",
cc="user3@abc.net,user4@abc.net",
bcc="user5@abc.net,user6@abc.net",
subject="New Software Release",
message="Get the latest version of ADS!\nReady for download at www.aquafold.com",
attachments="c:/my directory/abc.xls, D:/another/def.txt"'

Example:
.sendMail 'host=smtp.gmail.com,
port=465,
ssl=true,
authentication=true,
user=,
password=,
from=me@mycompany.com,
to=you@yourcompany.com,
subject="Nice document attached",
message="This will blow your sockets off\ncheck it out!",
attachments="c:/abc.xls,c:/abc2.xls"'


.saveResults and .saveLastResult
(all of the .saveResults commands work for both .saveResults and .saveLastResult)

 

.saveResults

Syntax:
.saveResults 'Format=CSV,
File="",
Delimiter=,
QuoteIdentifier=,
IncludeHeader=,
IncludeRowCount=,
IncludeNullText=,
NewLine=,
Encoding=,
Overwrite='

Syntax:
.saveResults 'Format=XML,
File="",
QuoteIdentifier=,
IncludeHeader=,
IncludeRowCount=,
IncludeNullText=,
NewLine=,
Encoding=,
Overwrite='

Syntax:
.saveResults 'Format=HTML,
File="",
IncludeSQL=,
QuoteIdentifier=,
IncludeHeader=,
IncludeRowCount=,
IncludeNullText=,
NewLine=,
Encoding=,
AlternateRow=,
AlternateRowForeground=,
AlternateRowBackground=,
Overwrite='

Syntax:
.saveResults 'Format=INSERT,
File="",
QuoteIdentifier=,
IncludeHeader=,
IncludeRowCount=,
IncludeNullText=,
NewLine=,
Encoding=,
Overwrite='

Syntax:
.saveResults 'Format=EXCEL,
Source=,
File="",
IncludeSQL=,
IncludeHeader=,
IncludeRowCount=,
IncludeNullText=,
AlternateRow=,
AlternateRowForeground=,
AlternateRowBackground=,
Overwrite='

Example:
.saveResults 'format=excel,
source=pivot,
file=C:/abc.xls,
overwrite=true'



.setResultSettings

Syntax:

"CategoryFields" is now synonymous with "RowFields"
and
"SeriesFields" is now synonymous with "ColFields"

The List of Aggregate Functions can contain one or more of the following:
Sum, Max, Min, Mean, Var, Stddev, Count

.setResultSettings 'Index=,
Title=,
CategoryFields=,where a field looks like "[Field Name] {List of Aggregate Functions}
SeriesFields=,
SortBy=,
SortOrder=,
ShowTitle=,
TopCount=,
ShowTopCount=,
ShowLegend=,
ShowChart=,
Chart=,
ScaleData=,
RotX=,
RotY=,
RotZ=,
Zoom=,
Split=,
Paging=,
Paging='

Example:
.setResultSettings 'Index=1,
Chart=column,
RotX=325,
RotY=53,
RotZ=0,
Zoom=50.0,
ScaleData=true,
ShowChart=true,
ShowLegend=true,
ShowTitle=false,
ColFields="[ShipCountry]",
DataFields="[Freight]",
Paging=true,
ShowTopCount=false,
Split=0.35460994'



.setPivotResultSettings

Syntax:

"CategoryFields" is now synonymous with "RowFields"
and
"SeriesFields" is now synonymous with "ColFields"

The List of Aggregate Functions can contain one or more of the following:
Sum, Max, Min, Mean, Var, Stddev, Count

.setPivotResultSettings 'Index=,
ShowFields=,
ShowTotal=,
ShowSubTotal=,
Title=,
RowFields=,where a field looks like "[Field Name] {List of Aggregate Functions}
ColFields=,
DataFields=,
SortBy=,
SortOrder=,
ShowTitle=,
TopCount=,
ShowTopCount=,
ShowLegend=,
ShowChart=,
Chart=,
ScaleData=,
RotX=,
RotY=,
RotZ=,
Zoom=,
Split=,
Paging=,
Paging='

Example:
.setPivotResultSettings 'Index=1,
Chart=column,
RotX=324,
RotY=12,
RotZ=0,
Zoom=50.0,
ScaleData=true,
ShowChart=false,
ShowLegend=true,
ShowTitle=false,
RowFields="ShipCountry",
ColFields="ShipVia",
DataFields="Freight",
Paging=true,
ShowTopCount=false,
Split= 0.5,
ShowFields=true,
ShowTotal=true,
ShowSubTotal=true'


COMBINATION EXAMPLE SCRIPT


select * from orders

GO

.setPivotResultSettings 'Index=1,
Chart=column,
RotX=324,
RotY=12,
RotZ=0,
Zoom=50.0,
ScaleData=true,
ShowChart=false,
ShowLegend=true,
ShowTitle=false,
RowFields="ShipCountry",
ColFields="ShipVia",
DataFields="Freight",
Paging=true,
ShowTopCount=false,
Split= 0.5,
ShowFields=true,
ShowTotal=true,
ShowSubTotal=true'

GO

.saveResults 'format=excel,
source=pivot,
file=C:/abc.xls,
overwrite=true'

GO

.saveResults 'format=excel,
source=pivot,
file=C:/abc2.xls,
overwrite=true'

GO

.sendMail 'host=smtp.gmail.com,
port=465,
ssl=true,
authentication=true,
user=,
password=,
from=me@mycompany.com,
to=you@yourcompany.com,
subject="Nice document attached",
message="This will blow your sockets off\ncheck it out!",
attachments="c:/abc.xls,c:/abc2.xls"'


GO

  • No labels