Nested functions - connect_cdc_sqdata - Latest

Connect CDC (SQData) Apply engine

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (SQData)
Version
Latest
Language
English
Product name
Connect CDC (SQData)
Title
Connect CDC (SQData) Apply engine
Copyright
2024
First publish date
2000
Last updated
2024-11-25
Published on
2024-11-25T15:00:28.224244

Nested SQData functions are basically ‘functions within functions’ or a function set. Nesting functions within other functions provides greater flexibility in controlling the data manipulation and logic flow of an SQData Apply Engine script. Some functions, such as CASE, usually result in some level of function nesting.

When using nested functions, it is helpful to put the ending parenthesis for an ‘outer’ function on a separate line and place the ‘inner’ functions within the starting and ending parenthesis.

Example 1

The following example shows two (2) levels of nesting within a CASE function.
CASE
WHEN SEX = 'M'
{
    V_WORKVAR = STRING('MALE')
}
OTHERWISE
{
    V_WORKVAR = STRING('FEMALE')
}

In this example, the variable TEMP_VAR is set to ‘MALE’ if the SEX field contains a ‘M’. If the SEX column contains an ‘F’, the variable TEMP_VAR is set to the value ‘FEMALE’. If the SEX column does not contain a ‘M’ or ‘F’, the variable TEMP_VAR is set to the value ‘OTHER’.

Example 2

This example introduces another level of nesting to the previous by adding an OR condition to the CASE logic. Assign a function alias of GEDNER_CALC to the function set.
CASE
WHEN (SEX = 'M'  OR   SEX = 'F')
{
   V_WORKVAR = 'KNOWN')
}
OTHERWISE
{
   V_WORKVAR = 'OTHER'
}

In this example, the variable TEMP_VAR is set to ‘KNOWN’ if the SEX field contains either a ‘M’ or ‘F’ value. If the SEX column does not contain a ‘M’ or ‘F’, the variable TEMP_VAR is set to the value ‘OTHER’.

Since a function alias (GENDER_CALC) was specified, this function set can be reused later using the VALUE function.