Re: Want FUNCTION to return argv[0] thru argv[6]

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Jerry Richards <jerry(dot)richards(at)teotech(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Want FUNCTION to return argv[0] thru argv[6]
Date: 2010-07-28 17:53:04
Message-ID: AANLkTinj+2b===s0oRfOV2L4577McM3z3FGgcsGpz-Qc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Jul 28, 2010 at 12:06 PM, Jerry Richards
<jerry(dot)richards(at)teotech(dot)com> wrote:
> Hello,
>
> I am using postgres-odbc and I created the following function which is
> called from a C-application.  This function returns a single argv[0] of the
> form "(a,b,c,d,e,f,g)".
>
> CREATE OR REPLACE FUNCTION PresRoute(int, int) RETURNS
> TABLE(d1 text, d2 text, d3 text, d4 text, r1 bigint, r2 bigint, r3 bigint)
> AS $$
> SELECT PresDest1(PresNode($1,$2)), PresDest2(PresNode($1,$2)),
> PresDest3(PresNode($1,$2)),
> PresDest4(PresNode($1,$2)), PresRing1(PresNode($1,$2)),
> PresRing2(PresNode($1,$2)),
> PresRing3(PresNode($1,$2)) $$ LANGUAGE SQL;
>
> But I would like it to return data as argv[0] thru argv[6] as shown:
>
> d1 | d2 | d3| d4 | r1 | r2 | r3
> -------------------------------
> a    b    c   d    e    f    g
>
> How should I change my function definition to achieve this?

I think it's just a matter of how you're calling it. Are you doing this:
SELECT PresRoute(...
or this:
SELECT * FROM PresRoute(...

if you don't want the rowtype, do the latter. The former is roughly
same as doing 'select foo from foo' vs 'select * from foo'.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Oleg Bartunov 2010-07-28 18:00:35 Re: Incorrect FTS result with GIN index
Previous Message Tom Lane 2010-07-28 17:46:54 Re: Comparison of Oracle and PostgreSQL full text search