|
Within a DataBlade API module, you can use either of the following methods to call a UDR, as long as you know the name of the UDR you want to call:
You can call any registered UDR in an SQL statement. When your UDR is called in an SQL statement, the database server parses the statement and produces a query plan. It then automatically performs any routine resolution necessary and loads the shared-object file in which that user-defined routine resides into shared memory (if it is not already loaded) when it parses and compiles the SQL statement. For more information on how the database server executes a UDR in an SQL statement, see Executing a User-Defined Routine.
Within the DataBlade API, you can:
For example, the following call to mi_exec() sends the EXECUTE FUNCTION statement to the database server to execute the myfunc() user-defined function:
For more information on the use of mi_exec() and mi_exec_prepared_statement(), see Chapter 7, Establishing a Connection.
From within a C UDR, you can directly call another C function when the following conditions are met:
This C function can be a registered UDR. In Figure 9-9, assume that the func2() and func3() functions were registered as user-defined functions with the CREATE FUNCTION statement. The func3() user-defined function can directly call the func2() UDR because func3() and func2() reside in the same shared-object file, source1.so.
If the UDR that you want to call is an overloaded routine, the database server executes the version of the UDR that resides in the same shared-object file. This UDR gets neither parameter casting nor a default MI_FPARAM structure. If no version of this UDR exists in the same shared-object file, you receive a runtime error. To execute UDRs in other shared-object files, use the Fastpath interface.