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

Поиск
Список
Период
Сортировка
От David G Johnston
Тема Re: Need help. Getting an error in my function when I do a select * from foo_bar()
Дата
Msg-id 1402503937253-5806854.post@n5.nabble.com
обсуждение исходный текст
Ответ на Need help. Getting an error in my function when I do a select * from foo_bar()  (Shubhra Sharma <sharma.shubhra07@gmail.com>)
Список 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 по дате отправления:

Предыдущее
От: Shubhra Sharma
Дата:
Сообщение: Need help. Getting an error in my function when I do a select * from foo_bar()
Следующее
От: Markus Neumann
Дата:
Сообщение: I probably don't understand aggregates.