Home Explore Blog CI



postgresql

35th chunk of `doc/src/sgml/syntax.sgml`
fc6be85f53ddcca68509ef1c566e040e06a1b322d43b59600000000100000884
 SQL IMMUTABLE STRICT;
</programlisting>
    Function <function>concat_lower_or_upper</function> has two mandatory
    parameters, <literal>a</literal> and <literal>b</literal>.  Additionally
    there is one optional parameter <literal>uppercase</literal> which defaults
    to <literal>false</literal>.  The <literal>a</literal> and
    <literal>b</literal> inputs will be concatenated, and forced to either
    upper or lower case depending on the <literal>uppercase</literal>
    parameter.  The remaining details of this function
    definition are not important here (see <xref linkend="extend"/> for
    more information).
   </para>

   <sect2 id="sql-syntax-calling-funcs-positional">
    <title>Using Positional Notation</title>

    <indexterm>
     <primary>function</primary>
     <secondary>positional notation</secondary>
    </indexterm>

    <para>
     Positional notation is the traditional mechanism for passing arguments
     to functions in <productname>PostgreSQL</productname>.  An example is:
<screen>
SELECT concat_lower_or_upper('Hello', 'World', true);
 concat_lower_or_upper
-----------------------
 HELLO WORLD
(1 row)
</screen>
     All arguments are specified in order.  The result is upper case since
     <literal>uppercase</literal> is specified as <literal>true</literal>.
     Another example is:
<screen>
SELECT concat_lower_or_upper('Hello', 'World');
 concat_lower_or_upper
-----------------------
 hello world
(1 row)
</screen>
     Here, the <literal>uppercase</literal> parameter is omitted, so it
     receives its default value of <literal>false</literal>, resulting in
     lower case output.  In positional notation, arguments can be omitted
     from right to left so long as they have defaults.
    </para>
   </sect2>

   <sect2 id="sql-syntax-calling-funcs-named">
    <title>Using Named Notation</title>

    <indexterm>
     <primary>function</primary>
     <secondary>named notation</secondary>
    </indexterm>

    <para>
     In named notation, each argument's name is specified using
     <literal>=&gt;</literal> to separate it from the argument expression.
     For example:
<screen>
SELECT concat_lower_or_upper(a =&gt;

Title: Using Positional and Named Notation for Function Calls in PostgreSQL
Summary
This section illustrates calling functions in PostgreSQL using positional and named notation. Positional notation involves passing arguments in the order defined in the function, while named notation specifies each argument's name using `=>`. Examples show how to use positional notation with the `concat_lower_or_upper` function, demonstrating argument omission from right to left when default values exist. The section then transitions into introducing named notation.