Hello,
I am writing my first trigger in C for PostgreSQL. It compiles Ok, and
added it to the database using CREATE TRIGGER. But when I try to fire
it, psql simply says 'The connection was lost". What I don't know is how
to get the row values (not the name fields) from tg_trigger.
The code is:
...
TriggerData *trigdata = (TriggerData *) fcinfo->context;
...
strcpy(query, "INSERT INTO visita_log VALUES ('");
strcat(query, trigdata->tg_trigger->tgargs[0]);
strcat(query, "','");
strcat(query, trigdata->tg_trigger->tgargs[1]);
strcat(query, "','");
strcat(query, trigdata->tg_trigger->tgargs[2]);
strcat(query, "','");
strcat(query, trigdata->tg_trigger->tgargs[3]);
strcat(query, "',");
strcat(query, trigdata->tg_trigger->tgargs[4]);
strcat(query, ",'");
strcat(query, trigdata->tg_trigger->tgargs[5]);
strcat(query, "');");
SPI_exec(query, 0);
...
I don't know if tgargs[] return the row values or the field names.
Thanks.
Juan