parameter substitution in aginity workbench

Post on 15-Jul-2015

125 Views

Category:

Data & Analytics

5 Downloads

Preview:

Click to see full reader

TRANSCRIPT

PARAMETER SUBSTITUTIONIN AGINITY WORKBENCH

Author: Mary Uguet

Manager Database and Data Warehouse Architect

@Restaurant Services Inc.

1

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

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

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

The Solution: Parameter Substitution

5

Next click on “Current Query Options”

The Solution: Parameter Substitution

6

Then check “Enable parameterized queries

The Solution: Parameter Substitution

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

7

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

The Solution: Parameter Substitution

The different data types that can be selected are:

9

The Solution: Parameter Substitution

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

10

The Solution: Parameter Substitution

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

11

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

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

The Solution: Parameter Substitution

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

14

top related