Trigger is not working for Inserts from the application

Поиск
Список
Период
Сортировка
От Kiran
Тема Trigger is not working for Inserts from the application
Дата
Msg-id CAJfd1U4Tcohjp9Lg27xYKuDkC5A_e-EjiTgLwv4Bhe4JWmZyJw@mail.gmail.com
обсуждение исходный текст
Ответы Re: Trigger is not working for Inserts from the application  (Jim Nasby <Jim.Nasby@BlueTreble.com>)
Список pgsql-general
Hi,

Problem background :
I have a *function in the DB* as follows
CREATE FUNCTION question_tsv_trigger() RETURNS trigger AS
$BODY$
begin
New.weighted_tsv :=
to_tsvector('swedish',coalesce(New.body->>'qtext','')::text);
RAISE NOTICE 'TRIGER called on %', TG_TABLE_NAME;
return New;
end
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;

*Trigger in the DB:*
CREATE TRIGGER insert_upd_question_tsvector BEFORE INSERT OR UPDATE
ON myschema.cf_question
FOR EACH ROW EXECUTE PROCEDURE question_tsv_trigger();

If I insert a record from my application using following code :
db.myschema.cf_question.insert({
cf_question_type_id:request.payload.type_id,
cf_question_category_id:request.payload.cat_id,
lang:request.payload.lang,
body:request.payload.body
}
The above app code inserts the record in the DB, but the respective trigger
in the database is not triggered hence the "weighted_tsv" columns is empty
for this record.

But if I insert another record from the postgre's psql, it will insert and
the respective trigger is working perfectly.

What could be the problem ? Why trigger is not working if I insert from the
application ? Am I doing anything wrong ?
Any help would be really really appreciated.

Thanks
Kiran

В списке pgsql-general по дате отправления:

Предыдущее
От: Kiran
Дата:
Сообщение: Trigger is not working for Inserts from the application
Следующее
От: Alexander Farber
Дата:
Сообщение: Re: Comibining UPDATE ... SET ... FROM (SELECT ...) with a JOIN