]> begriffs open source - ai-pg/blob - full-docs/txt/sql-dropprocedure.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / sql-dropprocedure.txt
1
2 DROP PROCEDURE
3
4    DROP PROCEDURE — remove a procedure
5
6 Synopsis
7
8 DROP PROCEDURE [ IF EXISTS ] name [ ( [ [ argmode ] [ argname ] argtype [, ...]
9 ] ) ] [, ...]
10     [ CASCADE | RESTRICT ]
11
12 Description
13
14    DROP PROCEDURE removes the definition of one or more existing
15    procedures. To execute this command the user must be the owner of the
16    procedure(s). The argument types to the procedure(s) usually must be
17    specified, since several different procedures can exist with the same
18    name and different argument lists.
19
20 Parameters
21
22    IF EXISTS
23           Do not throw an error if the procedure does not exist. A notice
24           is issued in this case.
25
26    name
27           The name (optionally schema-qualified) of an existing procedure.
28
29    argmode
30           The mode of an argument: IN, OUT, INOUT, or VARIADIC. If
31           omitted, the default is IN (but see below).
32
33    argname
34           The name of an argument. Note that DROP PROCEDURE does not
35           actually pay any attention to argument names, since only the
36           argument data types are used to determine the procedure's
37           identity.
38
39    argtype
40           The data type(s) of the procedure's arguments (optionally
41           schema-qualified), if any. See below for details.
42
43    CASCADE
44           Automatically drop objects that depend on the procedure, and in
45           turn all objects that depend on those objects (see
46           Section 5.15).
47
48    RESTRICT
49           Refuse to drop the procedure if any objects depend on it. This
50           is the default.
51
52 Notes
53
54    If there is only one procedure of the given name, the argument list can
55    be omitted. Omit the parentheses too in this case.
56
57    In PostgreSQL, it's sufficient to list the input (including INOUT)
58    arguments, because no two routines of the same name are allowed to
59    share the same input-argument list. Moreover, the DROP command will not
60    actually check that you wrote the types of OUT arguments correctly; so
61    any arguments that are explicitly marked OUT are just noise. But
62    writing them is recommendable for consistency with the corresponding
63    CREATE command.
64
65    For compatibility with the SQL standard, it is also allowed to write
66    all the argument data types (including those of OUT arguments) without
67    any argmode markers. When this is done, the types of the procedure's
68    OUT argument(s) will be verified against the command. This provision
69    creates an ambiguity, in that when the argument list contains no
70    argmode markers, it's unclear which rule is intended. The DROP command
71    will attempt the lookup both ways, and will throw an error if two
72    different procedures are found. To avoid the risk of such ambiguity,
73    it's recommendable to write IN markers explicitly rather than letting
74    them be defaulted, thus forcing the traditional PostgreSQL
75    interpretation to be used.
76
77    The lookup rules just explained are also used by other commands that
78    act on existing procedures, such as ALTER PROCEDURE and COMMENT ON
79    PROCEDURE.
80
81 Examples
82
83    If there is only one procedure do_db_maintenance, this command is
84    sufficient to drop it:
85 DROP PROCEDURE do_db_maintenance;
86
87    Given this procedure definition:
88 CREATE PROCEDURE do_db_maintenance(IN target_schema text, OUT results text) ...
89
90    any one of these commands would work to drop it:
91 DROP PROCEDURE do_db_maintenance(IN target_schema text, OUT results text);
92 DROP PROCEDURE do_db_maintenance(IN text, OUT text);
93 DROP PROCEDURE do_db_maintenance(IN text);
94 DROP PROCEDURE do_db_maintenance(text);
95 DROP PROCEDURE do_db_maintenance(text, text);  -- potentially ambiguous
96
97    However, the last example would be ambiguous if there is also, say,
98 CREATE PROCEDURE do_db_maintenance(IN target_schema text, IN options text) ...
99
100 Compatibility
101
102    This command conforms to the SQL standard, with these PostgreSQL
103    extensions:
104      * The standard only allows one procedure to be dropped per command.
105      * The IF EXISTS option is an extension.
106      * The ability to specify argument modes and names is an extension,
107        and the lookup rules differ when modes are given.
108
109 See Also
110
111    CREATE PROCEDURE, ALTER PROCEDURE, DROP FUNCTION, DROP ROUTINE