Skip site navigation (1) Skip section navigation (2)

PQexec and SPI_exec

From: "Pedro B(dot)" <pedro(dot)borracha(at)netcabo(dot)pt>
To: pgsql-sql(at)postgresql(dot)org
Subject: PQexec and SPI_exec
Date: 2004-08-25 14:21:40
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
Hello everyone.

I'm experiencing some doubts regarding a procedure i have (.c compiled 
as .so) running as an 'after insert for each row' trigger.

This trigger is supposed to do a simple query, something like
SELECT * FROM table order by id where processed=0 limit 1

It's not the perfect way to get the vars of the insert itself, but the 
result is a set of 45 columns, and the operations of the trigger are 
somehow complex, so .c is really a necessity on this one, and as long as 
this select actually returns the proper values, i can deal with it later.

But my problem is not one of a structure nature: my problem is the fact 
that using SPI_exec, and the SPI_getvalue(SPI_tuptable->vals[0], 
SPI_tuptable->tupdesc, columnX), and 
SPI_tuptable->tupdesc, columnX)))), etc, it all works fine.
the can detect the correct values - 
from the insert that triggered it.

I would prefer to use the more friendly PQexec and the simpler 
PQgetvalue(res,0,X), but this last approach does not return the values 
of the insert that triggered it. It returns the values from the "the 
last insert before this one". What is the proper way to make this method 

I'm sorry if this might be a basic question, but i have tried so many 
things, that i'm probably too puzzled right now to make any sense.

Any help is deeply appreciated.



pgsql-sql by date

Next:From: David PriceDate: 2004-08-25 14:49:25
Subject: Optimizer Selecting Incorrect Index
Previous:From: IainDate: 2004-08-25 02:48:11
Subject: Re: Possible rounding error of large float values?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group