Shubhra Sharma wrote
> ERROR: subquery must return only one column
> LINE 1: SELECT outer_query || 'UNION' || (select
A scalar sub-query can only return a single row and column. Somewhere in
that jumble of text you have a scalar sub-query returning more than one
column.
i.e.:
SELECT ...,
(SELECT one_column_only FROM ... LIMIT 1) AS valid_scalar_subquery
FROM ...
SELECT ...,
(SELECT col1, col2 FROM ... LIMIT 1) AS invalid_scalar_subquery
FROM ...
I am thinking your "per_inventory_query:=quote_literal((SELECT ...))"
statement may be the culprit since a query result being fed into a function
is an instance of a scalar sub-query. I have no way to test/prove since
your example is not self-contained.
I've spent as much time as I am willing to try and spot it but cannot.
You can wait and see if anyone else has better luck/more patience or you can
try greatly simplifying and formatting the query which you can either
re-post here or in the process of doing discover where the error is
yourself.
David J.
--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Need-help-Getting-an-error-in-my-function-when-I-do-a-select-from-foo-bar-tp5806849p5806854.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.