Top Banner
PARAMETER SUBSTITUTION IN AGINITY WORKBENCH Author: Mary Uguet Manager Database and Data Warehouse Architect @Restaurant Services Inc. 1
15
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Parameter substitution in Aginity Workbench

PARAMETER SUBSTITUTIONIN AGINITY WORKBENCH

Author: Mary Uguet

Manager Database and Data Warehouse Architect

@Restaurant Services Inc.

1

Page 2: Parameter substitution in Aginity Workbench

What is the Aginity Workbench?

• The Aginity Workbench is a query tool that allows to connect to a Netezza Appliance for development purposes.

• The Aginity Workbench is free and very easy to use.

• The Aginity Workbench connects to Netezza via OLEDB or ODBC.

• The Aginity Workbench allows the Netezza developer to write and test SQL code, stored procedures, views and other database objects.

2

Page 3: Parameter substitution in Aginity Workbench

The Problem• Many times you are faced with the need to run a query using different date ranges,

or change the filters applied to the WHERE clause.

• Aginity Workbench only allows to DECLARE variables within the body of a STORED

PROCEDURE, which is inconvenient when testing a complex script.

In the example below, if you want to run the query for different titles, you have to

edit the query and change the value to test. This query is very simple but imagine a

more complex script with different variables. How many “find and replace” you have

to execute!

3

Page 4: Parameter substitution in Aginity Workbench

The Solution : Parameter Substitution

This is where the Parameter Substitution feature in Aginity Workbench comes to the rescue.

You can use parameters that follow the $ParameterName mask. The feature can be enabled by selecting the “Enable Parameterized Queries” checkbox in the Query Options Window.

4

Page 5: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

5

Next click on “Current Query Options”

Page 6: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

6

Then check “Enable parameterized queries

Page 7: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

To use the parameter substitution feature, create a SQL statement and your parameter using the $ sign:

7

Page 8: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

When this query is executed, a window pops up to prompt for the TITLE:

Notice the parameter name $title, a section to enter its value and the data type.

8

Page 9: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

The different data types that can be selected are:

9

Page 10: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

In this example, you can use the string data type and enter for example Sr.

10

Page 11: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

Once you click on “OK, the results will show as follows:

11

Page 12: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

If you are running a script and you need to make the table name dynamic or dynamically build the SQL statement, the parameter substitution feature can be use as follows:

12

Page 13: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

When you click on “Execute”, Aginity prompts for the $title and $table. In the case of $table, the parameter has to be defined as Inserted “As-Is” data type.

13

Page 14: Parameter substitution in Aginity Workbench

The Solution: Parameter Substitution

The results will be the same as shown in slide #11:

14