Re: SQL works but same function is confused

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: SQL works but same function is confused
Дата
Msg-id 1396410967197-5798298.post@n5.nabble.com
обсуждение исходный текст
Ответ на Re: SQL works but same function is confused  ("Bui, Michelle P" <michelle.p.bui@boeing.com>)
Список pgsql-general
Bui, Michelle P wrote
> #variable_conflict use_variable
> DECLARE
> v_status TEXT;
> BEGIN
>     RETURN QUERY SELECT category, v_status as status, count (tool_id) AS
> tool_count
>     FROM
>     (SELECT distinct category, tool_id, 'active' as v_status

Seriously? Just pick a different alias for the 'active/inactive' column in
the sub-query. Problem solved.

Or, even smarter, don't even declare the variable since you never actually
use it anywhere in the function...

The variable_conflict variable should generally be used for backward
compatibility and not for newly coded functions.  For those just choose
names that do not conflict. The exception is for function return names that
you want to match existing column names in which case you need to prefix
appropriately.

You may want to provide your attempt to name the block to see if we can
figure why it gave a syntax error.

David J.





--
View this message in context:
http://postgresql.1045698.n5.nabble.com/SQL-works-but-same-function-is-confused-tp5798277p5798298.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


В списке pgsql-general по дате отправления:

Предыдущее
От: "Bui, Michelle P"
Дата:
Сообщение: Re: SQL works but same function is confused
Следующее
От: loc
Дата:
Сообщение: Insert zero to auto increment serial column