Re: Need help. Getting an error in my function when I do a select * from foo_bar() - Mailing list pgsql-novice

From David G Johnston
Subject Re: Need help. Getting an error in my function when I do a select * from foo_bar()
Date
Msg-id 1402503937253-5806854.post@n5.nabble.com
Whole thread Raw
In response to Need help. Getting an error in my function when I do a select * from foo_bar()  (Shubhra Sharma <sharma.shubhra07@gmail.com>)
List pgsql-novice
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.


pgsql-novice by date:

Previous
From: Shubhra Sharma
Date:
Subject: Need help. Getting an error in my function when I do a select * from foo_bar()
Next
From: Markus Neumann
Date:
Subject: I probably don't understand aggregates.