You can define a formal and explicitly-described expression, known as a procedure, to suit your site’s particular requirements. A procedure is a complex expression (built with programming statements) that you CREATE with an internal procedure name and with an explicit input parameter list (source columns are not referenced by name).
You also supply an external name for the procedure. This is its display name in the Connect CDC Director, and it may be the same as its internal procedure name but may be different.
To access the Connect CDC Director interface with which you define your procedure, from the context menu of the Data Enhancement Methods branch of your model, select New Data Enhancement Method > New Compiled Method:
In the tabs of the Data Enhancement Methods Properties dialog box, you provide the Connect CDC Director with identifying information for your procedure, and you specify the actual procedure code.
To enter the new compiled method:
-
In the Name text box, enter a unique name which will identify this compiled method in the Connect CDC Director. The name can have as many as 32 characters.
-
In the Return type list, select the datatype of the value to be placed in the target table. Be sure to enter a return type.
-
Enter the greatest possible length of a return value, that is, the total number of digits, in the Length box. For example, if you are converting Fahrenheit to Celsius temperatures, enter 3.
Length is not available for all datatypes.
-
Enter the Scale, if applicable. Scale is the number of digits to the right of the decimal point in a number. Scale is not available for all datatypes.
-
For each input parameter, enter a name, datatype, and precision (the number of digits in the number).
You can specify zero, one, or more input parameters, each to be represented by a column in your source table, a constant, or a system variable.
To specify multiple parameters, use the Add button. To rearrange the order of parameters, use the Move up and Move down buttons. To delete a parameter, use the Delete button.
-
On the Compiled tab, you must enter the Function name to be used with this method. The name must be a valid Java identifier. It must begin with a letter, underscore (__), or dollar sign ($).
The Body tab contains executable code. The input parameters you entered on the Basic tab fill in here automatically. You can write your own procedure here from scratch, if required.
These procedures are named, complex, expressions. The rules for specifying them are:
-
The first statement must be a procedure statement, containing:
-
name of the procedure
-
list of input arguments (a void or empty argument list is allowed)
-
"returns" clause, which indicates the type of the return value.
-
Column references are not allowed within the body of the procedure. The current row is not an implied input; you must explicitly define the input parameters that are required.
-
The following programming statements are allowed:
-
-
Variable declaration ("declare type variable name;")
-
Assignment
-
if / else
-
"switch / case / default"
-
"while"
-
"do"
-
"for"
-
"break" and "continue"
-
"return"
-
blocks, where multiple statements can be grouped within left and right braces. Anywhere a single statement can be used, a block of statements can be specified.
-
Statements must be terminated with a semi-colon (;).
-
The last statement must be an "end;" statement.
-
To write your own procedure:
-
Enter your code, observing the rules for procedures.
-
Click the Validate button to verify the syntax of your procedure. At a minimum, the procedure requires a return statement between the procedure and end statements in order to validate.
-
Once the procedure is valid, click OK to complete the creation of the compiled method.
The compiled method is now available in the Method column on the Table Properties, Mapping tab of a source or target table. You can use this compiled method to map data from one or more source columns to any target column for which you want data converted.
When you complete a valid definition, your user-defined procedure is available to be selected from:
-
Data Enhancement Methods branch of your model
-
Method lists on table Properties, Mapping tabs and on the Target Column Expression tab.
Define a user (named) procedure only in the context of a procedure expression. You cannot enter a user procedure in either of the following:
-
Sending Table Properties, Gate Condition tab
-
Result expression box in the Target Column Expression tab that you see when you select the Expression Method for a target column in the Mapping tab of the Sending Table Properties dialog box and then click Edit Source.