Re: SQL works but same function is confused - Mailing list pgsql-general

From David Johnston
Subject Re: SQL works but same function is confused
Date
Msg-id 1396410967197-5798298.post@n5.nabble.com
Whole thread Raw
In response to Re: SQL works but same function is confused  ("Bui, Michelle P" <michelle.p.bui@boeing.com>)
List 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 by date:

Previous
From: "Bui, Michelle P"
Date:
Subject: Re: SQL works but same function is confused
Next
From: loc
Date:
Subject: Insert zero to auto increment serial column