Re: How the get variables out of a plggsql RECORD by column number

From: "Keith Worthington" <keithw(at)narrowpathinc(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: How the get variables out of a plggsql RECORD by column number
Date: 2005-01-18 18:54:00
Message-ID: 20050118185400.M4680@narrowpathinc.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

> > A record type contians the 1st row form dynamic
> > query result.
> >
> > From that row I want to select the 1st column.
> >
> > How do I do that?
>

Can you use a simple LOOP?

DECLARE rcrd_data RECORD

FOR rcrd_data IN SELECT tbl_source.first_column,
tbl_source.second_column,
FROM tbl_source
LOOP
-- Now rcrd_data.first_column has data.
END LOOP;

See
http://www.postgresql.org/docs/7.4/interactive/plpgsql-control-structures.html#PLPGSQL-RECORDS-ITERATING
for more information.

Kind Regards,
Keith

PS Caution, I am still a novice myself.

______________________________________________
99main Internet Services http://www.99main.com

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Iain 2005-01-19 03:28:01 Re: Problem with pl/perl in postgresql
Previous Message sarlav kumar 2005-01-18 18:34:11 generating dynamic queries using pl/pgsql