sql-named-param-refs-doc-v1.patch

text/x-patch

Filename: sql-named-param-refs-doc-v1.patch
Type: text/x-patch
Part: 1
Message: Patch: Allow SQL-language functions to reference parameters by parameter name

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: unified
Series: patch v1
File+
doc/src/sgml/xfunc.sgml 0 0
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
new file mode 100644
index 7064312..cc6f3a1
*** a/doc/src/sgml/xfunc.sgml
--- b/doc/src/sgml/xfunc.sgml
*************** SELECT getname(new_emp());
*** 538,556 ****
  <programlisting>
  CREATE FUNCTION tf1 (acct_no integer, debit numeric) RETURNS numeric AS $$
      UPDATE bank
!         SET balance = balance - $2
!         WHERE accountno = $1
      RETURNING balance;
  $$ LANGUAGE SQL;
  </programlisting>
  
       Here the first parameter has been given the name <literal>acct_no</>,
       and the second parameter the name <literal>debit</>.
!      So far as the SQL function itself is concerned, these names are just
!      decoration; you must still refer to the parameters as <literal>$1</>,
!      <literal>$2</>, etc within the function body.  (Some procedural
!      languages let you use the parameter names instead.)  However,
!      attaching names to the parameters is useful for documentation purposes.
       When a function has many parameters, it is also useful to use the names
       while calling the function, as described in
       <xref linkend="sql-syntax-calling-funcs">.
--- 538,555 ----
  <programlisting>
  CREATE FUNCTION tf1 (acct_no integer, debit numeric) RETURNS numeric AS $$
      UPDATE bank
!         SET balance = balance - debit
!         WHERE accountno = acct_no
      RETURNING balance;
  $$ LANGUAGE SQL;
  </programlisting>
  
       Here the first parameter has been given the name <literal>acct_no</>,
       and the second parameter the name <literal>debit</>.
!      Named parameters can still be referenced as
!      <literal>$<replaceable>n</></>; in this example, the second
!      parameter can be referenced as <literal>$2</>, <literal>debit</>,
!      or <literal>tf2.debit</>.
       When a function has many parameters, it is also useful to use the names
       while calling the function, as described in
       <xref linkend="sql-syntax-calling-funcs">.