Need help? Email or Call Us: (952) 933-0609

Use SETVAR to pass variables

When you create a SEQUEL script, you can combine multiple commands into a job stream. If multiple SEQUEL objects in the script prompt for variables, you can use the SETVAR parameter so that you are prompted only once for the variables that will be passed to the various objects. This can be handy when you are setting up something like a script to run month-end reports and you must pass same date range to several reports.

Create two simple views with variables
Let’s create a sample script that displays two views. These views use the same variables for their beginning and ending dates. When you run the script we’ll create, it prompts you only once for the date range.

Because the PDATE field (in the WHERE clause) is a date data type, you must use two ampersands (&) within a pair of double quotes for the variable name.

Test View 1

Test View 2

Open the Variables tab and define the Type as “Date” for both variables. Exit and save the first view as TEST1 in the SEQUELEX library. Create and save the second view as TEST2 in the SEQUELEX library.

Variables Tab Selected

Create a script using SETVAR
Select File > New > Script from the ViewPoint Explorer menu to start the script designer.

In the script designer, enter the three lines shown below to monitor for global messages (and prevent the script from ending if an error occurs) and display the two views.

Notice that the SETVAR parameter contains pairs of variables. The first variable in the pair (&START) is the variable you defined in the view. You will define the second variable ('&&START2') in the script. SEQUEL passes the value of the script variable to the view variable at run time.

As you did with your view definition, define the script variables by opening the Variables tab and specify “Date” as the prompt type.

Date Prompt Type

Exit and save the script.

When you run the script, SEQUEL prompts you for the date range only once because the SETVAR parameter passes the dates from the script to the view for you. If you had not included the SETVAR parameter in your script, SEQUEL would have prompted you twice—once for the script and again for the view.

Contributed by Steven Smith, Technical Writer
 

Need Help?

Talk to Us
In the U.S. and Canada, call 1-800-328-1000 and ask for Sales.
Elsewhere in the world, contact your local international office.