f2s_esql_execute_func

Applies to: Oracle, MS SQL, MySql/MariaDB, PostgreSQL Drivers

Syntax

f2s_esql_execute_func [using {variant}]

Parameter

Description

variant

Optional variant type variable that will receive a statement interface

Description

This command is used to execute a SQL Function. Once this command has been called, an interface is instantiated to handle the call.

The optional “using” syntax allows you to pass around the interface created by this command. The variable passed MUST be a variant. This allows for multiple statements to be active concurrently in some cases. If you use the “using” syntax, it must be used on all subsequent commands. Mixing the using syntax is not supported. So for instance, if you plan on having multiple statements active concurrently, all active statements must make use of the using syntax.

Example

SQL Server Code to create a simple function ‘dbo.AddTwoIntegers’ that adds two integers and returns the result
CREATE FUNCTION AddTwoIntegers(
    @intOne INT,
    @intTwo INT
)
RETURNS INT
AS
BEGIN
    RETURN   @intOne + @intTwo;
END;
-- To call the function
-- Select dbo.AddTwoIntegers(2, 2)
DataFlex code to call the ‘AddTwoIntegers’ SQL Function under the ‘.dbo’ schema
Integer iReturnVal
Integer iParmIntegerValue1
Integer iParmIntegerValue2
Move 1 to iParmIntegerValue1
Move 2 to iParmIntegerValue2

f2s_esql_set_func_name "dbo.AddTwoIntegers"
f2s_esql_prepare_stmt
f2s_esql_set_func_param 1 to iParmIntegerValue1
f2s_esql_set_func_param 2 to iParmIntegerValue2
f2s_esql_execute_func
f2s_esql_get_func_retval iReturnVal

Showln  (String(iReturnVal))

Related Commands

Replaces: Command SQL_FUNCTION_EXECUTE