Re: SQL works but same function is confused

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: "Bui, Michelle P" <michelle(dot)p(dot)bui(at)boeing(dot)com>, "'pgsql-general(at)postgresql(dot)org'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: SQL works but same function is confused
Date: 2014-04-02 02:35:35
Message-ID: 533B7777.3000403@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/01/2014 06:44 PM, Bui, Michelle P wrote:
> v_status is not used inthe SQL statement but is used in the function because we need to return a table (catgory, tool_count, status).
>
> Even when I did not use v_status, and assign value 'valid' or 'invalid' to the output parameter directly, the same error occurred.

Not use v_status where, in the DECLARE block or as an alias in the query?

If it where me and I wanted to keep the variable in the DECLARE block I
would do:

DECLARE

_v_status TEXT;

At least you would be able to track which variable is in play.

> Can we assign value for an alias in a function?

An SQL alias for table, column, etc or an alias for a function argument?

http://www.postgresql.org/docs/9.3/interactive/plpgsql-declarations.html#PLPGSQL-DECLARATION-ALIAS

>
> Thanks,
> Michelle

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Sullivan 2014-04-02 02:45:19 Re: simple update query stuck
Previous Message Tom Lane 2014-04-02 02:20:30 Re: SQL works but same function is confused