Content deleted Content added
Dana Zhang (talk | contribs) No edit summary |
Rescuing 1 sources and tagging 0 as dead.) #IABot (v2.0.9.5 |
||
(12 intermediate revisions by 8 users not shown) | |||
Line 1:
{{Short description|Function provided by the user of a program or environment}}
A '''user-defined function''' ('''UDF''') is a [[function (programming)|function]] provided by the user of a program or environment, in a context where the usual assumption is that functions are built into the program or environment. UDFs are usually written for the requirement of its creator.
Line 7 ⟶ 8:
In the [[COBOL]] programming language, a user-defined function is an entity that is defined by the user by specifying a FUNCTION-ID paragraph. A user-defined function must return a value by specifying the RETURNING phrase of the procedure division header and they are invoked using the function-identifier syntax. See the ISO/IEC 1989:2014 Programming Language COBOL standard for details.
As of May 2022, the IBM Enterprise COBOL for [[z/OS]] 6.4 ([[IBM COBOL]]) compiler contains support for user-defined functions.
==Databases==
In [[relational database management system]]s, a user-defined function provides a mechanism for extending the functionality of the [[database server]] by adding a function, that can be evaluated in standard [[query language]] (usually [[SQL]]) statements.
User-defined functions in SQL are declared using the <code>CREATE FUNCTION</code> statement. For example, a user-defined function that converts Celsius to Fahrenheit (a temperature scale used in USA) might be declared like this:
<syntaxhighlight lang="sql">
CREATE FUNCTION dbo.CtoF(Celsius FLOAT)
Line 19 ⟶ 20:
</syntaxhighlight>
Once created, a user-defined function may be used in [[expression (programming)|expressions]] in SQL statements. For example, it can be invoked where most other intrinsic functions are allowed.
<syntaxhighlight lang="sql">
Line 26 ⟶ 27:
</syntaxhighlight>
would retrieve the name and the boiling point from each row. It invokes the <code>CtoF</code> user-defined function as declared above in order to convert the value in the column to a value in Fahrenheit.
Each user-defined function carries certain properties or characteristics. The SQL standard defines the following properties:
Line 49 ⟶ 50:
Performance Notes:
<syntaxhighlight lang="tsql">
Line 83 ⟶ 84:
</syntaxhighlight>
User-defined functions are subroutines made of one or more Transact-SQL statements that can be used to encapsulate code for reuse.
Line 106 ⟶ 107:
END
</syntaxhighlight>
===Apache Hive===
Line 135 ⟶ 126:
|date=26 June 2015}}
</ref>
===Apache Doris===
Apache Doris, an open-source real-time analytical database, allows external users to contribute their own UDFs written in C++ to it.<ref>{{cite web |title=Apache Doris UDF |url=https://doris.apache.org/docs/dev/ecosystem/udf/contribute-udf?_highlight=udf |access-date=8 April 2023 |archive-date=10 April 2023 |archive-url=https://web.archive.org/web/20230410141729/https://doris.apache.org/docs/dev/ecosystem/udf/contribute-udf/?_highlight=udf |url-status=dead }}</ref>
==References==
|