Re: [GENERAL] Fetching column names for a table

2005-09-21 Thread David Fetter
On Wed, Sep 21, 2005 at 02:31:23PM -0400, Steve Manes wrote: > I need to extract a SETOF column names for a table in plpgsql. How > is this done? You can do it in SQL. CREATE OR REPLACE FUNCTION get_columns_for ( in_schema TEXT, in_table TEXT ) RETURNS SETOF TEXT LANGUAGE SQL STRICT AS $

Re: [GENERAL] Fetching column names for a table

2005-09-21 Thread Joshua D. Drake
Steve Manes wrote: I need to extract a SETOF column names for a table in plpgsql. How is this done? A query such as this: select * from information_schema.columns where table_name = 'table_name'; Will give you a bunch of information. For SET OF functions in general take a look at: http:/

Re: [GENERAL] Fetching column names for a table

2005-09-21 Thread Tony Wasson
On 9/21/05, Steve Manes <[EMAIL PROTECTED]> wrote: > I need to extract a SETOF column names for a table in plpgsql. How is > this done? I got the queries for this by running psql with -E and then using \d on a table. Use this function like so: SELECT * FROM column_names('your_table'); CREATE OR

Re: [GENERAL] Fetching column names for a table

2005-09-21 Thread Philip Hallstrom
I need to extract a SETOF column names for a table in plpgsql. How is this done? Start up psql with the -E option. Then type "\dt tablename". This will print out the SQL that psql runs to give you the column names. Maybe that will do what you want? -philip ---(en