Обсуждение: Triggers in 7.0.x and SQL syntax.

Поиск
Список
Период
Сортировка

Triggers in 7.0.x and SQL syntax.

От
D0
Дата:
Well, after dinking around for serveral hours I decided to beg for help
on here about triggers and look like an idiot all in one slew.

I have two tables. A and B.  Whenever A has a row inserted I want to
grab that newly created primary key from it's row in table A and insert
it into a field in table B.

I have tried creating single triggers and triggers that call functions.
I even messed with rules a bit.  All resulted in either "something"
happening but not seeing a change in data or flat out syntax or code
errors.

I was attempting to use:  select last_value from A_A_id_seq;    to get
the latest primary key. This seems to work ok on it's own.

Question is how do I incorporate that into a trigger or something
equivalent? Also, what if I have tables C and D that need to be update
the same as B is.  Do I make more triggers or simply have the function
called by the trigger or the trigger itself update all three tables?

Thanks.