Home | Previous Page | Next Page   Creating User-Defined Routines > Developing a User-Defined Routine >

Executing a UDR

After you register a UDR as an external routine in the database, it can be called in one of the following ways:

Tip:
Within a C UDR, you can obtain the name of the SQL statement that invoked the UDR with the mi_current_command_name( ) function.

Each occurrence of a UDR, implicit or explicit, in an SQL or SPL statement is a routine instance. One routine instance might involve several routine invocations. A routine invocation is one execution of the UDR. For example, if the following query selects five matching rows, the query has one routine instance of the a_func( ) user-defined function and five routine invocations for this function:

SELECT a_func(x) FROM table1 WHERE y > 7;

Similarly an iterator function might contain many invocations in a single routine instance.

To execute a UDR instance in an SQL statement, the database server takes the following steps:

  1. The query parser breaks the SQL statement into its syntactic parts and performs any routine resolution required.

    The query optimizer develops a query plan, which efficiently organizes the execution of the SQL-statement parts.

  2. The query executer calls the routine manager, which handles execution of the UDR instance and any invocations.

The following sections provide information about how the steps of UDR execution can affect the way that you write the UDR. For more general information, see the chapter on how a UDR runs in the IBM Informix: User-Defined Routines and Data Types Developer's Guide.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]