Re: [GENERAL] A history procedure that prevents duplicate entries

2009-08-19 Thread Alban Hertroys
On 16 Aug 2009, at 17:38, Madison Kelly wrote: Besides that, you don't need the SELECT statement or the RECORD- type variable as the data you need is already in the NEW and OLD records. But, you only have an OLD record when your trigger fired from an UPDATE, so you need to check whether

Re: [GENERAL] A history procedure that prevents duplicate entries

2009-08-16 Thread Alban Hertroys
On 16 Aug 2009, at 4:24, Madison Kelly wrote: Hi all, ... CREATE FUNCTION history_radical() RETURNS trigger AS $$ DECLARE hist_radical RECORD; BEGIN SELECT INTO hist_radical * FROM public.radical WHERE rad_id=new.rad_id; I assume you mean to

Re: [GENERAL] A history procedure that prevents duplicate entries

2009-08-16 Thread Bastiaan Wakkie
Hi Madi, I think you want to use foreign keys which can give you these checks. So add a foreign key to create a link between rad_id of both tables. regards, Bastiaan Madison Kelly wrote: Hi all, I've been using a procedure to make a copy of data in my public schema into a history schema

Re: [GENERAL] A history procedure that prevents duplicate entries

2009-08-16 Thread Madison Kelly
Alban Hertroys wrote: On 16 Aug 2009, at 4:24, Madison Kelly wrote: Hi all, ... CREATE FUNCTION history_radical() RETURNS trigger AS $$ DECLARE hist_radical RECORD; BEGIN SELECT INTO hist_radical * FROM public.radical WHERE rad_id=new.rad_id; I assume you

[GENERAL] A history procedure that prevents duplicate entries

2009-08-15 Thread Madison Kelly
Hi all, I've been using a procedure to make a copy of data in my public schema into a history schema on UPDATE and INSERTs. To prevent duplicate entries in the history, I have to lead in the current data, compare it in my program and then decided whether something has actually changed