バージョンごとのドキュメント一覧

38.3. ユーザ定義関数 #

<title>User-Defined Functions</title>

<productname>PostgreSQL</productname> provides four kinds of functions: PostgreSQLは4種類の関数を提供します。

Every kind of function can take base types, composite types, or combinations of these as arguments (parameters). In addition, every kind of function can return a base type or a composite type. Functions can also be defined to return sets of base or composite values. すべての関数は、基本型、複合型、またはこの組み合わせを引数(パラメータ)として受け付けることが可能です。 また、すべての関数は基本型または複合型を返すことが可能です。 関数は、基本型の集合または複合型の集合を返すようにも定義できます。

Many kinds of functions can take or return certain pseudo-types (such as polymorphic types), but the available facilities vary. Consult the description of each kind of function for more details. 多くの関数は(多様型のような)特定の疑似型を引数としたり返したりできます。 しかし、利用できる機能は様々です。 詳細は各関数の種類の説明を参照してください。

It's easiest to define <acronym>SQL</acronym> functions, so we'll start by discussing those. Most of the concepts presented for <acronym>SQL</acronym> functions will carry over to the other types of functions. SQL関数の定義の方法が最も簡単ですので、そちらから説明します。 SQL関数にある概念のほとんどは、他の種類の関数にも適用できます。

Throughout this chapter, it can be useful to look at the reference page of the <link linkend="sql-createfunction"><command>CREATE FUNCTION</command></link> command to understand the examples better. Some examples from this chapter can be found in <filename>funcs.sql</filename> and <filename>funcs.c</filename> in the <filename>src/tutorial</filename> directory in the <productname>PostgreSQL</productname> source distribution. 本章の全体に関して、その例をより理解するために、CREATE FUNCTIONコマンドのマニュアルページを一読することが有用です。 本章の例のいくつかはPostgreSQLソース配布物内のsrc/tutorialディレクトリにあるfuncs.sqlfuncs.cにあります。