f2s_esql_set_func_name

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

Syntax

f2s_esql_set_func_name {funcName} [using {variant}]

Parameter

Description

funcName

A string containing the SQL Function name setup and execute

variant

Optional variant type variable that will receive a statement interface

Description

This command is used to set the name a SQL Function.

This command is used in the same way as f2s_esql_set_proc_name and f2s_esql_create_stmt to set the name of the function to be executed. When calling SQL functions in this fashion, this command must be used along with f2s_esql_execute_func (to execute the function), f2s_esql_set_func_param (to set the needed parameters) and f2s_esql_get_func_retval (to get any returned value).

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_SET_FUNCTION_NAME