Learn good practices for creating user-defined functions.
- Do not hard-code library paths in SQL registration scripts. This practice makes it difficult to provide flexibility to the user to install the UDFs into the same directory as Sybase IQ.
- Do not write output files. Sybase IQ version 15.1 includes an architectural limitation on UDF results within Sybase IQ. Due to this limitation, some UDFs have been developed to write to temporary results files outside of the Sybase IQ container. The first ESD release of version 15.1 will expand, this architectural limit to a usable size. The limit is scheduled to be removed completely from a future version of Sybase IQ.
- Do not write ambiguous code, or constructs that can unexpectedly loop forever, without providing a mechanism for the user to cancel the UDF invocation (see the function 'get_is_cancelled()' in (UDF and UDAF callback functions).
- Do not perform complex, or memory-intensive operations that are repeated every invocation. When a UDF call is made against a table that contains many thousands of rows, efficient execution becomes paramount. Sybase recommends that you allocate blocks of memory for a thousand to several thousand rows at a time, rather than on a row-by-row basis.
- Do not open a database connection, or perform database operations from within a UDF. All parameters and data required for UDF execution must be passed as parameters to the UDF.
- Do not use reserved words when naming UDFs.