Hi folks,
I am a new bee to ruby/postgresql.I am using postgresql as my database server.Today, in my project I came accross a point where I need to write a trigger in plruby.In one of the materials I found the following sample code
CREATE FUNCTION trigfunc_modcount() RETURNS TRIGGER AS '
case tg["op"]
when PL::INSERT
new[args[0]] = 0
when PL::UPDATE
new[args[0]] = old[args[0]].to_i + 1
else
return PL::OK
end
new
' LANGUAGE 'plruby';
CREATE TABLE mytab (num int4, modcnt int4, descr text);
CREATE TRIGGER trig_mytab_modcount BEFORE INSERT OR UPDATE ON mytab
FOR EACH ROW EXECUTE PROCEDURE trigfunc_modcount('modcnt');
but the blog didnot specify where should i place this stuff and how I call it and etc...I am a little confused.
Any help appreciated.Thanks in advance
venkat,
venkat.bagam@rknowsys.com
|