Search Postgresql Archives

Re: SQL works but same function is confused

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux