Search Postgresql Archives

Re: need trigger help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Excellent, I got it working...Thanks ;)

Abdul-Wahid

On 5/9/05, Mike Nolan <nolan@xxxxxxxxxxx> wrote:
> > So how can I create a trigger to automatically update the hash fields
> > on updates and inserts?
> 
> Something like the following works for me:
> 
> create or replace function public.my_trigger()
> returns trigger as '
> 
> NEW.hashfield = hashfunction(NEW.data1,NEW.data2);
> 
> RETURN NEW;
> END;
> ' language 'plpgsql';
> 
> --------
> create trigger my_trig
> before insert or update on my_tablename
> for each row
> execute procedure public.my_trigger();
> 
> The 'RETURN NEW' part is very important, without it your hash field won't
> get updated at all.
> --
> Mike Nolan
> 
>

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@xxxxxxxxxxxxxx


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux