Kinds of expressions - Connect_CDC - connect_cdc_mimix_share - 5.8

Connect CDC System Reference Guide

Product type
Software
Portfolio
Integrate
Product family
Connect
Product
Connect > Connect CDC (MIMIX Share)
Version
5.8
Language
English
Product name
Connect CDC
Title
Connect CDC System Reference Guide
Copyright
2024
First publish date
2003
ft:lastEdition
2024-02-12
ft:lastPublication
2024-02-12T15:11:59.486869

The expression grammar (see below) supports three kinds of expressions:

  1. Simple expression – Some examples were listed in the Expression Handling Overview in Examples of simple expressions. The implicit input to the expression is the current row of the default associated source table. Given this input, all column values are accessible by column name qualified with the source table or not. The types of simple expressions follow:
    • Boolean expression that implicitly returns Boolean (true or false). This is meant for use as a gate condition.

    • Value expression that implicitly returns some other non-Boolean type of value. This is meant for use as a result column expression.

    The following is an example of a simple expression:

    Column1 > 1;
                        Column2 == ‘aaa’;
                        Table1.Column2!=’hhh’;
                        substring(column2,1,1);

       If you enter an expression that should be a complex expression, you receive an error. For example, if you enter the following:

    (c5 == 0) return 999; else return 1000;

    it returns this error:

    The correct expression is:

    begin returns integer;
                        if (c5 == 0) return 999; else return 1000;

       end;

    This returns success with a warning:

  2. Complex expression – un-named – These are like simple expressions in that the assumed input to the expression is the current row and, therefore, column values in the row are accessible. Also, like simple expressions, complex expressions can return all supported types. However, they differ significantly from simple expressions in the following ways:

    • The return type is explicitly declared with the “returns <type>” clause in the “begin” statement.

    The body of the expression (between “begin returns <type>;” and “end;” can contain statements. A simple expression cannot contain statements, only Boolean or value expressions. Complex expressions are intended to be “computationally complete,” that is, nearly all the statements (if/else, while, do/while, for, switch, break, continue, return) allowed for Java or C can be used verbatim in the expression language. See Notes and Restrictions to the Grammar for differences.

    Here is an example of a complex expression that calculates the factorial of the column value for the column “C2”:

    begin returns integer;
                        declare integer n;
                        declare integer fact;
                        /* calculate the factorial of the following number */
                        n=C2;
                        fact = 1;
                        while (n>1)
                        {
                          fact=fact*n;
                          n=n-1;
                        }
                        return fact;
                        end;
  3.   Complex expression – named – also known as a procedure or user-defined method. This type of expression is like its unnamed counterpart in that a returns clause identifies the type of the return value and the same set of statements between begin and end (procedure and end in the case of a procedure) is allowed. Procedures are different in the following ways:

    •       The procedure statement, which begins (and identifies) the procedure, contains a procedure name and an input parameter list. The name is the method name that identifies it if referenced in another expression elsewhere in the model.

    •       Column references are not allowed within the body of the procedure. The current row is not an implied input to the method; the user explicitly defines the input parameters that are required. A procedure is provided as the way for a user to code a built-in data transformation method. A procedure, like one of Connect CDC’s system data transformation methods (for example, substring), is intended to be called by other expressions.

    In the following example, the previous example of an un-named complex expression has been written as a procedure:

    procedure factorial (int col_value) returns integer;
                        declare integer fact;
                         
                        /* calculate the factorial of the following number */
                        fact = 1;
                        while (col_value>1)
                        {
                          fact=fact*col_value;
                          col_value = col_value-1;
                        }
                        return fact;
                        end;

    Once the previous procedure is defined, then it can be used in a simple expression elsewhere:

    factorial(C2);