summaryrefslogtreecommitdiffstats
path: root/doc/src/sgml/html/xproc.html
blob: 89b891ef24a50bbc10def7de85325dc7a16e38de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>38.4. User-Defined Procedures</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="xfunc.html" title="38.3. User-Defined Functions" /><link rel="next" href="xfunc-sql.html" title="38.5. Query Language (SQL) Functions" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">38.4. User-Defined Procedures</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="xfunc.html" title="38.3. User-Defined Functions">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="extend.html" title="Chapter 38. Extending SQL">Up</a></td><th width="60%" align="center">Chapter 38. Extending <acronym class="acronym">SQL</acronym></th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 15.6 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="xfunc-sql.html" title="38.5. Query Language (SQL) Functions">Next</a></td></tr></table><hr /></div><div class="sect1" id="XPROC"><div class="titlepage"><div><div><h2 class="title" style="clear: both">38.4. User-Defined Procedures</h2></div></div></div><a id="id-1.8.3.7.2" class="indexterm"></a><p>
    A procedure is a database object similar to a function.
    The key differences are:

    </p><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p>
       Procedures are defined with
       the <a class="link" href="sql-createprocedure.html" title="CREATE PROCEDURE"><code class="command">CREATE
       PROCEDURE</code></a> command, not <code class="command">CREATE
       FUNCTION</code>.
      </p></li><li class="listitem"><p>
       Procedures do not return a function value; hence <code class="command">CREATE
       PROCEDURE</code> lacks a <code class="literal">RETURNS</code> clause.
       However, procedures can instead return data to their callers via
       output parameters.
      </p></li><li class="listitem"><p>
       While a function is called as part of a query or DML command, a
       procedure is called in isolation using
       the <a class="link" href="sql-call.html" title="CALL"><code class="command">CALL</code></a> command.
      </p></li><li class="listitem"><p>
       A procedure can commit or roll back transactions during its
       execution (then automatically beginning a new transaction), so long
       as the invoking <code class="command">CALL</code> command is not part of an
       explicit transaction block.  A function cannot do that.
      </p></li><li class="listitem"><p>
       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.
      </p></li></ul></div><p>
   </p><p>
    The explanations in the following sections about how to define
    user-defined functions apply to procedures as well, except for the
    points made above.
   </p><p>
    Collectively, functions and procedures are also known
    as <em class="firstterm">routines</em><a id="id-1.8.3.7.5.2" class="indexterm"></a>.
    There are commands such as <a class="link" href="sql-alterroutine.html" title="ALTER ROUTINE"><code class="command">ALTER ROUTINE</code></a>
    and <a class="link" href="sql-droproutine.html" title="DROP ROUTINE"><code class="command">DROP ROUTINE</code></a> that can operate on functions and
    procedures without having to know which kind it is.  Note, however, that
    there is no <code class="literal">CREATE ROUTINE</code> command.
   </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="xfunc.html" title="38.3. User-Defined Functions">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="extend.html" title="Chapter 38. Extending SQL">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="xfunc-sql.html" title="38.5. Query Language (SQL) Functions">Next</a></td></tr><tr><td width="40%" align="left" valign="top">38.3. User-Defined Functions </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 15.6 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 38.5. Query Language (<acronym class="acronym">SQL</acronym>) Functions</td></tr></table></div></body></html>