RE: [suse-programming-e] Trigger on Postgres for tables syncroniz ation
Can't help you with postgres.. You are on your own with that... There are several ways to get to your result. A very simplified trigger is below. I left the updating for you to figure out along with the insert statements. -------------------------------------------- create or replace trigger [TRIGGER_NAME] before insert or update or delete on appointment for each row declare begin if (inserting) then if :new.done = 'Y' then [insert into appointment0] else [insert into appointment1] end if; end if; if (updating) then [Your statements] end if; if (deleting) then delete from appointment0 where noapp = :old.noapp; delete from appointment1 where noapp = :old.noapp; end if; end; -----Original Message----- From: Prabu Subroto [mailto:prabu_subroto@yahoo.com] Sent: Tuesday, July 27, 2004 7:59 AM To: suse-programming-e@suse.com Subject: [suse-programming-e] Trigger on Postgres for tables syncronization Dear my friends... 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? Where Can I find a good documentation about the trigger of postgres especially the PLPGSQL of the postgres? Anybody would be so nice to tell me the steps and the command of the triggers should be in order to implement my strategy? Please.... Please.... Thank you very much in advance. __________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail -- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-programming-e
OK, it's solved...
Thank you very much for your kindness, my friend
Wenzel.
Thank you...very....very....very... much.
--- "Wenzel, Scott"
Can't help you with postgres.. You are on your own with that... There are several ways to get to your result. A very simplified trigger is below. I left the updating for you to figure out along with the insert statements.
-------------------------------------------- create or replace trigger [TRIGGER_NAME] before insert or update or delete on appointment for each row declare begin if (inserting) then if :new.done = 'Y' then [insert into appointment0] else [insert into appointment1] end if; end if;
if (updating) then [Your statements] end if;
if (deleting) then delete from appointment0 where noapp = :old.noapp; delete from appointment1 where noapp = :old.noapp; end if;
end;
-----Original Message----- From: Prabu Subroto [mailto:prabu_subroto@yahoo.com] Sent: Tuesday, July 27, 2004 7:59 AM To: suse-programming-e@suse.com Subject: [suse-programming-e] Trigger on Postgres for tables syncronization
Dear my friends...
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?
Where Can I find a good documentation about the trigger of postgres especially the PLPGSQL of the postgres?
Anybody would be so nice to tell me the steps and the command of the triggers should be in order to implement my strategy? Please....
Please....
Thank you very much in advance.
__________________________________ Do you Yahoo!? Read only the mail you want - Yahoo! Mail SpamGuard. http://promotions.yahoo.com/new_mail
-- To unsubscribe, email: suse-programming-e-unsubscribe@suse.com For additional commands, email: suse-programming-e-help@suse.com Archives can be found at: http://lists.suse.com/archive/suse-programming-e
__________________________________ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! http://promotions.yahoo.com/new_mail
participants (2)
-
Prabu Subroto
-
Wenzel, Scott