Re: SQL works but same function is confused

From: David Johnston <polobo(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL works but same function is confused
Date: 2014-04-02 03:56:07
Message-ID: 1396410967197-5798298.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message loc 2014-04-02 12:17:12 Insert zero to auto increment serial column
Previous Message Bui, Michelle P 2014-04-02 03:06:19 Re: SQL works but same function is confused