diff --git a/doc/src/sgml/ref/create_function.sgml b/doc/src/sgml/ref/create_function.sgml
index 3c1eaea651c..f1001615f4a 100644
--- a/doc/src/sgml/ref/create_function.sgml
+++ b/doc/src/sgml/ref/create_function.sgml
@@ -100,6 +100,11 @@ CREATE [ OR REPLACE ] FUNCTION
To be able to create a function, you must have USAGE
privilege on the argument types and the return type.
+
+
+ Refer to for further information on writing
+ functions.
+
@@ -578,12 +583,6 @@ CREATE [ OR REPLACE ] FUNCTION
-
-
- Refer to for further information on writing
- functions.
-
-
@@ -661,8 +660,7 @@ CREATE FUNCTION foo(int, int default 42) ...
Examples
- Here are some trivial examples to help you get started. For more
- information and examples, see .
+ Add two integers using a SQL function:
CREATE FUNCTION add(integer, integer) RETURNS integer
AS 'select $1 + $2;'
diff --git a/doc/src/sgml/ref/create_procedure.sgml b/doc/src/sgml/ref/create_procedure.sgml
index e258eca5cee..6dbc0127194 100644
--- a/doc/src/sgml/ref/create_procedure.sgml
+++ b/doc/src/sgml/ref/create_procedure.sgml
@@ -76,6 +76,11 @@ CREATE [ OR REPLACE ] PROCEDURE
To be able to create a procedure, you must have USAGE
privilege on the argument types.
+
+
+ Refer to for further information on writing
+ procedures.
+
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
index 2863f7c2065..41bcc5b79dd 100644
--- a/doc/src/sgml/xfunc.sgml
+++ b/doc/src/sgml/xfunc.sgml
@@ -63,7 +63,8 @@
Throughout this chapter, it can be useful to look at the reference
- page of the command to
+ page of the CREATE
+ FUNCTION command to
understand the examples better. Some examples from this chapter
can be found in funcs.sql and
funcs.c in the src/tutorial
@@ -81,21 +82,55 @@
- A procedure is a database object similar to a function. The difference is
- that a procedure does not return a value, so there is no return type
- declaration. While a function is called as part of a query or DML
- command, a procedure is called in isolation using
- the CALL command. If the CALL command is not
- part of an explicit transaction, a procedure in many server-side
- languages can commit, rollback, and begin new transactions during
- its execution, which is not possible in functions.
+ A procedure is a database object similar to a function.
+ The key differences are:
+
+
+
+
+ Procedures are defined with
+ the CREATE
+ PROCEDURE command, not CREATE
+ FUNCTION.
+
+
+
+
+ Procedures do not return a function value; hence CREATE
+ PROCEDURE lacks a RETURNS clause.
+ However, procedures can instead return data to their callers via
+ output parameters.
+
+
+
+
+ While a function is called as part of a query or DML command, a
+ procedure is called in isolation using
+ the CALL command.
+
+
+
+
+ A procedure can commit or roll back transactions during its
+ execution (then automatically beginning a new transaction), so long
+ as the invoking CALL command is not part of an
+ explicit transaction block. A function cannot do that.
+
+
+
+
+ Certain function attributes, such as strictness, don't apply to
+ procedures. Those attributes control how the function is
+ used in a query, which isn't relevant to procedures.
+
+
+
- The explanations on how to define user-defined functions in the rest of
- this chapter apply to procedures as well, except that
- the CREATE PROCEDURE command is used instead, there is
- no return type, and some other features such as strictness don't apply.
+ The explanations in the following sections about how to define
+ user-defined functions apply to procedures as well, except for the
+ points made above.