Re: Postgres 8.3 Function returning a row with different number of colums

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Postgres 8.3 Function returning a row with different number of colums
Date: 2011-08-02 07:46:21
Message-ID: 4E37AB4D.7020006@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 08/02/11 12:29 AM, Gianpiero Venditti wrote:
> First of all thanks for the quick replies, i'll describe my problem
> more in detail.
>
> I'm using postgress with the latest release of GNU Gatekeeper.
>
> More specifically I need a query that returns a row with exactly a
> single column (a text) in one case and a row with exactly two columns
> (a text and an integer) in the other case.
>
> So i can't just return everytime two columns with one null sometimes.
> I know this is a little strange but it's a constraint of the
> Gatekeeper so i have no choiche :(
>
> This is the way i call the query from inside the gatekeeper:
>
> select * from routing ( param1, param2, param3, param4 ) as ( result
> text, reason integer );
>
> is there a way to make the reason optional?

that should be two separate queries.

"select *" shouldn't really be made from application code in the first
place, its a convenience when you're manually querying something, but
queries from a program should name the fields they expect so they aren't
dependent on the table definition and field order.

--
john r pierce N 37, W 122
santa cruz ca mid-left coast

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ognjen Blagojevic 2011-08-02 09:10:24 Re: Postgres 8.0 upgrade to 9.0
Previous Message Gianpiero Venditti 2011-08-02 07:29:15 Re: Postgres 8.3 Function returning a row with different number of colums