Posted Wed, 11 Sep 2013 20:00:00 GMT by Portal Admin

I have a view and a prompt that i say where 'field' in(&var) and it prompts for a list of states. I enter them in the window and say run and I get information about all those states.

I want to run these 2 views in a script and be able to prompt for the states within the script. I'm having trouble figuring out the syntax to make it do this. Is it possible to do an 'IN' statement in a script? If so, how is the variable handled?

Posted Thu, 16 Jun 2016 05:00:00 GMT by Portal Admin

Hi there!

Make sure in your script you have your SETVAR (see below) setup. It should be setup the same way as the variable in the view.

If you are using a multiselect, you need to also select quote values in the variable tab of the script.

Please let me know if you need more information...

 

Thanks

Jackie Daugherty

Technical Consultant

 

Placing Variables in a Script

Variables can be used in a script in many different ways to provide user input for almost anything. When placing a variable in a script, the variable name must be proceeded by an ampersand(&).The variable can be the same name as the view variable or be unique. Once a variable is placed in the script, it must be defined before the script can be run.

Below are some example script lines that show three areas where variables are most commonly used: SETVAR, SQL and Command Parameters.

Each of the examples is followed by some general rules or guidelines for the syntax of the variable. These are not ‘hard and fast’ rules. There are many ways syntactically to use the variable, but these guidelines will help to avoid errors in most cases.

 

SETVAR

A very powerful use of variables is the ability to pass user input into a Sequel view using the Set Variable (SETVAR) parameter. Most Sequel commands that generate output (Display, Execute, Print, Report, etc.), have a SETVAR parameter for this purpose.

The SETVAR parameter will contain pairs of variables. The first variable in the pair is a variable defined in the view – the variable user input will be passed to. The second variable is the variable defined in the script – the value that will set the view variable. For example, &TEXT is the view variable and &EXPR is the script variable.

DISPLAY VIEW(SEQUELEX/CUSTLISTX2) SETVAR((&TEXT '&&EXPR') (&FILE '&&NAME')

(&CUSNO '&&NMBR') (&CSTTE '&&QSTNG') (&DTE '&&DTE'))

 

The SETVAR above has five pairs of variables. Each represents the five different prompt types. Quoted String and Number type prompts are used most often to pass input to the WHERE clause of the view for record selection purposes.

As a general rule, it is best to use single-quotes around the variable in case the value has spaces or punctuation, inside the SETVAR parameter. When a script variable is enclosed in quotes, two ampersands(&&) are required to ensure substitution.

Originally Posted By jdaugherty

You must be signed in to post in this forum.