Home Explore Blog CI



postgresql

5th chunk of `doc/src/sgml/ref/create_procedure.sgml`
fc1aa63b5dc6453cb5ca93c886908adbe990d0ba804e234300000001000007f7
  <para>
       This form of the <literal>AS</literal> clause is used for
       dynamically loadable C language procedures when the procedure name
       in the C language source code is not the same as the name of
       the SQL procedure. The string <replaceable
       class="parameter">obj_file</replaceable> is the name of the shared
       library file containing the compiled C procedure, and is interpreted
       as for the <link linkend="sql-load"><command>LOAD</command></link> command.  The string
       <replaceable class="parameter">link_symbol</replaceable> is the
       procedure's link symbol, that is, the name of the procedure in the C
       language source code.  If the link symbol is omitted, it is assumed
       to be the same as the name of the SQL procedure being defined.
      </para>

      <para>
       When repeated <command>CREATE PROCEDURE</command> calls refer to
       the same object file, the file is only loaded once per session.
       To unload and
       reload the file (perhaps during development), start a new session.
      </para>

     </listitem>
    </varlistentry>

    <varlistentry>
     <term><replaceable class="parameter">sql_body</replaceable></term>

     <listitem>
      <para>
       The body of a <literal>LANGUAGE SQL</literal> procedure.  This should
       be a block
<programlisting>
BEGIN ATOMIC
  <replaceable>statement</replaceable>;
  <replaceable>statement</replaceable>;
  ...
  <replaceable>statement</replaceable>;
END
</programlisting>
      </para>

      <para>
       This is similar to writing the text of the procedure body as a string
       constant (see <replaceable>definition</replaceable> above), but there
       are some differences: This form only works for <literal>LANGUAGE
       SQL</literal>, the string constant form works for all languages.  This
       form is parsed at procedure definition time, the string constant form is
       parsed at execution time; therefore this form cannot support
       polymorphic argument types and other

Title: CREATE PROCEDURE - C Language Procedures and SQL Body
Summary
This section details how to use the AS clause for dynamically loadable C language procedures, explaining the purpose of 'obj_file' and 'link_symbol'. It also mentions that the object file is only loaded once per session and that a new session is required to reload it. Additionally, the section describes the 'sql_body' parameter for LANGUAGE SQL procedures, providing the required block structure and highlighting the differences between this form and using a string constant for the procedure body.