Re: Triggers and Function's
От | scott.marlowe |
---|---|
Тема | Re: Triggers and Function's |
Дата | |
Msg-id | Pine.LNX.4.33.0305281559530.28136-100000@css120.ihs.com обсуждение исходный текст |
Ответ на | Triggers and Function's (Campos Chaves <camposchaves@yahoo.com.br>) |
Список | pgsql-general |
On Wed, 28 May 2003, Campos Chaves wrote: > Hi, > > After I insert on rocord on Table A, I need to insert > another record on Table B. I think that I have to use > triggers and functions. But I don't know how! You can > help me? You can either do it by hand in a transaction, or in something like plpgsql / triggers. To do it by hand, you do: begin; insert into table a ( field1, field2, idfield ) values ( 'data', number, nextval('sequence') ); insert into table b ( fielda, fieldb, fktotable1 ) values ( 'date', number3, currval('sequence') ); commit; Just make the whole thing a plsql function and feed it all the data it needs and you don't have to worry about anything but checking for errors in your app. If you need to update other tables based on some kind of caclulation, then you'll be needing triggers or rules.
В списке pgsql-general по дате отправления: