Re: Proper way of iterating over the column names in a trigger function. [ SOLVED]

From: "Rajesh Kumar Mallah" <mallah(dot)rajesh(at)gmail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Proper way of iterating over the column names in a trigger function. [ SOLVED]
Date: 2006-12-06 17:39:23
Message-ID: a97c77030612060939t6ba0566dkfa27a5539316c313@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 12/6/06, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Rajesh Kumar Mallah" <mallah(dot)rajesh(at)gmail(dot)com> writes:
> > what is the proper way for iterating over column names of a table using
> > SPI_* functions.
>
> You need to pay attention to the attisdropped field of the TupleDesc
> entries.

thanks.

did the below (hopefully gotcha free)

for (i = 1; i <= tupdesc->natts ; i++)
{
if ( tupdesc->attrs[i-1]->attisdropped)
continue;
col_name = SPI_fname(tupdesc, i);
elog (NOTICE , "colname: %s" , col_name);
}

Warm Regds
Mallah.

>
> regards, tom lane
>

Browse pgsql-sql by date

  From Date Subject
Next Message Phillip Smith 2006-12-06 23:02:16 INSERT DELETE RETURNING
Previous Message Richard Ray 2006-12-06 15:44:45 Query is fast and function is slow