Download Extending INFORMIX-Universal Server: User

Transcript
Number of Arguments
Number of Arguments
User-defined routines should take a small number of arguments and should
not include arguments that make them modal. For example, the following
statements show alternative routine calls to compute containment of spatial
values:
Containment(polygon, polygon, integer);
Contains(polygon, polygon)
ContainedBy(polygon, polygon)
The first example determines whether the first polygon contains the second
polygon or whether the second contains the first. The caller supplies an
integer argument (for example, one or zero) to identify which value to
compute. This is modal behavior; the mode of the routine changes depending
on the third argument.
The second example is better in that the routine names clearly explain what
computation is performed. Always construct your routines to be nonmodal,
as in the second example.
Coding Standards
The SQL/PSM standard is available for UDR development. In addition,
Informix publishes a collection of standards for DataBlade module development. These standards are available from the DataBlade Developers
Program. The most important rules govern the naming of data types and
routines. DataBlade modules share these name spaces, so you must follow
the naming guidelines to guarantee that no problems occur when you
register multiple DataBlade modules in a single database.
In addition, the standards for 64-bit clean implementation, safe functioncalling practices, thread-safe development, and platform portability are
important. Adherence to these standards ensures that UDR modules are
portable across platforms.
You should ask the following questions:
■
Do I obey all naming standards?
■
Is my design 64-bit safe and portable across platforms?
■
Is my design thread-safe?
Designing a User-Defined Routine 3-5