Home Explore Blog CI



postgresql

3rd chunk of `doc/src/sgml/ref/drop_procedure.sgml`
2dd84423213c6f3b7910402e0b4ea0b88d08a7cfee07df6a0000000100000d2c
 <literal>OUT</literal> are just noise.  But
   writing them is recommendable for consistency with the
   corresponding <command>CREATE</command> command.
  </para>

  <para>
   For compatibility with the SQL standard, it is also allowed to write
   all the argument data types (including those of <literal>OUT</literal>
   arguments) without
   any <replaceable class="parameter">argmode</replaceable> markers.
   When this is done, the types of the procedure's <literal>OUT</literal>
   argument(s) <emphasis>will</emphasis> be verified against the command.
   This provision creates an ambiguity, in that when the argument list
   contains no <replaceable class="parameter">argmode</replaceable>
   markers, it's unclear which rule is intended.
   The <command>DROP</command> command will attempt the lookup both ways,
   and will throw an error if two different procedures are found.
   To avoid the risk of such ambiguity, it's recommendable to
   write <literal>IN</literal> markers explicitly rather than letting them
   be defaulted, thus forcing the
   traditional <productname>PostgreSQL</productname> interpretation to be
   used.
  </para>

  <para>
   The lookup rules just explained are also used by other commands that
   act on existing procedures, such as <command>ALTER PROCEDURE</command>
   and <command>COMMENT ON PROCEDURE</command>.
  </para>
 </refsect1>

 <refsect1 id="sql-dropprocedure-examples">
  <title>Examples</title>

  <para>
   If there is only one procedure <literal>do_db_maintenance</literal>,
   this command is sufficient to drop it:
<programlisting>
DROP PROCEDURE do_db_maintenance;
</programlisting>
  </para>

  <para>
   Given this procedure definition:
<programlisting>
CREATE PROCEDURE do_db_maintenance(IN target_schema text, OUT results text) ...
</programlisting>
   any one of these commands would work to drop it:
<programlisting>
DROP PROCEDURE do_db_maintenance(IN target_schema text, OUT results text);
DROP PROCEDURE do_db_maintenance(IN text, OUT text);
DROP PROCEDURE do_db_maintenance(IN text);
DROP PROCEDURE do_db_maintenance(text);
DROP PROCEDURE do_db_maintenance(text, text);  -- potentially ambiguous
</programlisting>
   However, the last example would be ambiguous if there is also, say,
<programlisting>
CREATE PROCEDURE do_db_maintenance(IN target_schema text, IN options text) ...
</programlisting></para>
 </refsect1>

 <refsect1 id="sql-dropprocedure-compatibility">
  <title>Compatibility</title>

  <para>
   This command conforms to the SQL standard, with
   these <productname>PostgreSQL</productname> extensions:
   <itemizedlist>
    <listitem>
     <para>The standard only allows one procedure to be dropped per command.</para>
    </listitem>
    <listitem>
     <para>The <literal>IF EXISTS</literal> option is an extension.</para>
    </listitem>
    <listitem>
     <para>The ability to specify argument modes and names is an
     extension, and the lookup rules differ when modes are given.</para>
    </listitem>
   </itemizedlist></para>
 </refsect1>

 <refsect1>
  <title>See Also</title>

  <simplelist type="inline">
   <member><xref linkend="sql-createprocedure"/></member>
   <member><xref linkend="sql-alterprocedure"/></member>
   <member><xref linkend="sql-dropfunction"/></member>
   <member><xref linkend="sql-droproutine"/></member>
  </simplelist>
 </refsect1>

</refentry>

Title: DROP PROCEDURE - Examples and Compatibility
Summary
This section provides examples of how to use the DROP PROCEDURE command, demonstrating scenarios where the argument list can be omitted or must be specified. It also highlights potential ambiguities when argument modes are not explicitly defined. Furthermore, it outlines the command's compatibility with the SQL standard, noting PostgreSQL extensions such as dropping multiple procedures, the IF EXISTS option, and the ability to specify argument modes and names.