Execute routines in expressions
Just as with built-in functions, you can execute SPL routines (and external routines from SPL routines) by using them in expressions in SQL and SPL statements. A routine used in an expression is usually a function, because it returns a value to the rest of the statement.
For
example, you might execute a function by a LET statement that assigns
the return value to a variable. The statements in the following figure
perform the same task. They execute an external function within an
SPL routine and assign the return value to the variable a.
You can also execute an SPL routine from an SQL statement,
as the following figure shows. Suppose you write an SPL function, increase_by_pct,
which increases a given price by a given percentage. After you write
an SPL routine, it is available for use in any other SPL routine.
The example selects the price column of a specified row of inventory and uses the value as an argument to the SPL function increase_by_pct. The function then returns the new value of price, increased by 20 percent, in the variable p.