PREP_PROCESS_VAR and PREP_PROCESS_VAR_XML

Use the PREP_PROCESS_VAR script function to retrieve a list of VARA object values. For XML VARA objects, you can also use PREP_PROCESS_VAR_XML. The script functions let you filter by key and value. The script functions return a reference to a data sequence that you can use for further processing by assigning the return code to the :PROCESS script statement. Use the GET_PROCESS_LINE script function to access a particular line in the VARA object.

More Information

Notes:

SQL and SQLI VARA Objects with Many Entries

The number of lines returned can be limited in your system settings. When you filter for a particular Value with PREP_PROCESS_VAR, the system will only search for the value within the defined maximum number of lines.

More Information:

Tip: Use the Key parameter in PREP_PROCESS_VAR to limit the number of lines returned when the VARA object has many entries. The Key value is passed to the database and used for the query.

Example

Your system is configured to limit the returned number of lines: SQLVAR_MAX_ROWS is set to 1000. Your SQL VARA object contains over 1000 lines and you are looking for a particular value that can occur in any of the lines. Because of the limitation, PREP_PROCESS_VAR only returns the first 1000 lines. You may not find all occurrences of the value. Specify the Key parameter to reduce the number of lines retrieved, and search those lines only for the value.

Syntax

PREP_PROCESS_VAR (VARA object[,Key [,Value [, Column]]])
PREP_PROCESS_VAR_XML (VARA object, Key, Value)

Parameters

Important! When you use PREP_PROCESS_VAR to access values in an XML VARA object, specify all three parameters (Key, Value, and Column).

Notes:


Examples

A VARA object that is called DATABASE_MAINTENANCE contains the following entries, in 2 columns (Key and Value1):

The following script retrieves all values in the VARA object. The script prints the values from both columns in the activation report.

:SET &HND#=PREP_PROCESS_VAR(DATABASE_MAINTENANCE)
:
PROCESS &HND#
:   
SET &VK# = GET_PROCESS_LINE(&HND#,1)
:   
SET &VALUE# = GET_PROCESS_LINE(&HND#,2)
:   
PRINT "&VK# &VALUE#"
:
ENDPROCESS

:
CLOSE_PROCESS &HND#

The activation report would look like this:

2018-01-31 11:28:59 - U0020408 ARCHIVING Y
2018-01-31 11:28:59 - U0020408 REORGANIZING N
2018-01-31 11:28:59 - U0020408 UNLOADING N
2018-01-31 11:28:59 - U0020408 CLIENT 3

The following script only retrieves entries where the key starts with "client":

:SET &HND#=PREP_PROCESS_VAR(DATABASE_MAINTENANCE,"Client*")
:
PROCESS &HND#
:   
SET &VK# = GET_PROCESS_LINE(&HND#,1)
:   
SET &VALUE# = GET_PROCESS_LINE(&HND#,2)
:   
PRINT "&VK# &VALUE#"
:
ENDPROCESS

:
CLOSE_PROCESS &HND#

The activation report would only include the following line:

2018-01-31 11:28:59 - U0020408 CLIENT 3

The following example retrieves values from an XML VARA object that is called VARA.XML. The specified XPath filters for elements in the XML.

:SET &HND# = PREP_PROCESS_VAR_XML(VARA.XML, "KEY01", "A/B")
:PROCESS &HND#
: SET &GB# = GET_PROCESS_LINE(&HND#,1)
: SET &VALUE# = GET_PROCESS_LINE(&HND#,2)
: PRINT "&GB# &VALUE#"
:ENDPROCESS

See also:

seealso

Script Elements for Data Sequences