User Defined Function

A User Defined Function (English User Defined Function, abbreviation UDF) in a programming environment called a function that create the users themselves and can incorporate in their projects. It fulfills a task as a macro, but is implemented via a function call. UDFs are available in general programming languages ​​such as Visual Objects, scripting languages ​​such as PHP, special macro software as AutoIt and database languages ​​such as SQL and Firebird.

The syntax of a UDF must be the syntax of the source language correspond with pre-defined standard functions and other UDFs can be used in the definition. As a UDF function must return exactly one return value.

Unlike a stored procedure can not be started as a UDF program.

Examples

The following UDF takes two date values ​​, the function returns the younger date.

CREATE FUNCTION [ MaxDateValue ] ( v1 @ datetime, @ v2 datetime)   RETURNS datetime AS   BEGIN   IF ( @ v1 <@ v2)      RETURN ( @ v2)   RETURN ( @ v1)   END UDF after that is stored in the database, it can be used within a SQL query:

SELECT MaxDateValue ( the date of purchase order date ) FROM order External Table Function ("external table function " ) in SQL In this variant a ( unnamed ) SQL table is used for the return value exactly. You can within a SQL statement are wherever a SQL table can stand. On the SQL level, a control entry is defined that points to an external program. The database system typically supports several programming languages ​​in which the program can be written.

  • Programming
  • Databases
795158
de