[SQL] Proper way of iterating over the column names in a trigger function.

2006-12-06 Thread Rajesh Kumar Mallah
Hi, I am trying to interate over column names of a table on which a C trigger function is called on UPDATE/DELETE and INSERT. SPI function char * SPI_fname(TupleDesc rowdesc, int colnumber) is being used. looks like the function is returning column names like pg.dropped.2 for

[SQL] Count field in query

2006-12-06 Thread lucas
Hi all. Is there any way to build a query with a field that has the IndexCount of the query. It's something like the number of the row returned (starting with 1). Something like: select * from mytable order by name; id | name | CountField 7 | KK | 1 98 | LL | 2 5 | ZZ

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

2006-12-06 Thread Tom Lane
Rajesh Kumar Mallah [EMAIL PROTECTED] 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. regards, tom lane ---(end of

[SQL] Query is fast and function is slow

2006-12-06 Thread Richard Ray
The query select count(*) from documents where doc_num = '106973821' and (select bit_or(group_access) from mda_groups where group_name in (select groname from pg_user,pg_group where usename = 'bbob' and usesysid = any(grolist) and (groname ~ '.*owner$' or groname = 'admin'))) access

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

2006-12-06 Thread Rajesh Kumar Mallah
On 12/6/06, Tom Lane [EMAIL PROTECTED] wrote: Rajesh Kumar Mallah [EMAIL PROTECTED] 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

[SQL] INSERT DELETE RETURNING

2006-12-06 Thread Phillip Smith
Hi All, As per Daniel Caune's posting (with no replies) on October 22nd, (http://archives.postgresql.org/pgsql-sql/2006-10/msg00195.php), Can I do this.? INSERT INTO stock_deleted_tmp ( code, description, date_deleted ) DELETE FROM ONLY stock_tmp