Am Dienstag, 27. Juli 2004 13:58 schrieb Prabu Subroto:
I am using SuSE Linux 9.1 and postgres. I am a beginner in postgres, usually I use MySQL.
I have 3 tables : appointment, appointment0 and appointment1.
the fields of table "appointment" are as follows: noapp* (int4):ID Number of appointment (PK) custid (int4) : Customer ID salesid (int4) : Sales ID date (date) : Date of appointment time (time) : Time of appointment todo (char(150)) : What's to do with them done (char(1)): whether done (N/Y) warned (char(1)): whether warned with prompt timestamp (timestamp) : timestamp of record
"appointment0" and "appointment1" have exactly the same field names as what "appointment" has.
But... 1. the population of "appointment0" and "appointment1" are the subset of "appointment" 2. what the "appointment0" has are the members of "appointment" whose "Y" as the value of fieldname "done". 3. and what "appointmnet1" has are the members of "appointment" whose "N" as the value of fieldname "done".
I want if my program inserted, updated, deleted the record of "appointment" than the postgres does the syncronization to the corresponded tables (appointment0 or appointment1 or both).
Is it possible to implement this strategy with trigger? But how?
It is possible but I do not recommend it. You produce redundant data. Use views instead: create view appointment0 as select * from appointment where done = 'Y'; create view appointment1 as select * from appointment where done = 'N'; You can use these views like tables and you don't have to alter the contents of three tables.
Where Can I find a good documentation about the trigger of postgres especially the PLPGSQL of the postgres?
Is it so difficult to find http://www.postgresql.org/docs? I used the documentation myself and found it very helpful. Jan -- Linux-Quickies: http://www.jan-trippler.de PingoS: http://www.pingos.org