PROCs are created using the CREATE PROC command. The PROC consists of a SELECT command that contains one or more Functions.
Example
A pair of identical mapping functions currently exist at several locations within the SELECT command in the main processing section of the script. A decision is made to modularize the script by placing the two (LEFT and RIGHT) mapping instructions in a separate PROC which will then be called whenever needed.
In order to create a PROC containing these mapping functions, simply add a CREATE PROC command before the mapping functions as follows and move the group of lines.
CREATE PROC proc_name AS
SELECT
{
TARGET_FIELD1 = LEFT(SOURCE_FIELD1, 3)
TARGET_FIELD2 = RIGHT(SOURCE_FIELD2, 3)
}
FROM INPUT_DATASTORE;