Re: How the get variables out of a plggsql RECORD by column number - Mailing list pgsql-novice

From Keith Worthington
Subject Re: How the get variables out of a plggsql RECORD by column number
Date
Msg-id 20050118185400.M4680@narrowpathinc.com
Whole thread Raw
In response to Re: How the get variables out of a plggsql RECORD by column number  (Jeff Eckermann <jeff_eckermann@yahoo.com>)
List 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


pgsql-novice by date:

Previous
From: sarlav kumar
Date:
Subject: generating dynamic queries using pl/pgsql
Next
From: "Pradeepkumar, Pyatalo (IE10)"
Date:
Subject: dropdb command not working.