Other company, product, and service names may be trademarks or service marks ofothers.
Section 2. Using user-defined functions
What are user-defined functions?
, or UDFs as they are commonly known, are functions definedby the user aaqqthat run in the database engine. The functions are used to simplifythe logic within SQL statements. Instead of repeatedly including common or complexlogic in multiple statements, the developer can isolate that logic in a single function.Traditionally, people think of a function as a program that takes in some inputs andthen returns a result. Within a database, you have a great deal more flexibility andpossibilities in what you can do with a function. There are a number of different typesof functions, and also different languages you can write them in.Here are the types of available functions:•
: Returns a single data type value using SQL•
: Returns a row of data using SQL•
: Returns an SQL table based on SQL•
: Returns a single data type using an external language•
: Are based on another function or templateAnd here are the programming languages that you can write them in:• SQL (for functions written using one or more SQL statements)• C/C++• The Java language• SQLJ• Visual Basic
There are two distinct types of functions. The more common type is an
, which is a function written using SQL statements. Functions can also bewritten as references to external components of code, be they in the Java language,