From: Marko Tiikkaja <marko@joh.to>
To: PG Docs <pgsql-docs@postgresql.org>
Subject: Broken example in PL/PgSQL documentation
Date: Thu, 04 Sep 2014 14:06:40 +0200
Message-ID: <540855D0.4020108@joh.to> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-docs>
Hi,
Just came across a broken example in the docs:
local:marko=#* select * from extended_sales(1);
ERROR: column reference "quantity" is ambiguous
LINE 1: SELECT quantity, quantity * price FROM sales
^
DETAIL: It could refer to either a PL/pgSQL variable or a table column.
QUERY: SELECT quantity, quantity * price FROM sales
WHERE itemno = p_itemno
CONTEXT: PL/pgSQL function "extended_sales" line 3 at RETURN QUERY
Patch to fix this attached.
.marko
--
Sent via pgsql-docs mailing list (pgsql-docs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-docsAttachments:plpgsql_return_query.patch (text/plain, 686B) download
*** a/doc/src/sgml/plpgsql.sgml
--- b/doc/src/sgml/plpgsql.sgml
***************
*** 487,494 **** $$ LANGUAGE plpgsql;
CREATE FUNCTION extended_sales(p_itemno int)
RETURNS TABLE(quantity int, total numeric) AS $$
BEGIN
! RETURN QUERY SELECT quantity, quantity * price FROM sales
! WHERE itemno = p_itemno;
END;
$$ LANGUAGE plpgsql;
</programlisting>
--- 487,494 ----
CREATE FUNCTION extended_sales(p_itemno int)
RETURNS TABLE(quantity int, total numeric) AS $$
BEGIN
! RETURN QUERY SELECT sales.quantity, sales.quantity * sales.price FROM sales
! WHERE sales.itemno = p_itemno;
END;
$$ LANGUAGE plpgsql;
</programlisting>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-docs@postgresql.org
Cc: marko@joh.to
Subject: Re: Broken example in PL/PgSQL documentation
In-Reply-To: <540855D0.4020108@joh.to>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox