Thread: trigger question

trigger question

From
"Glenn John Ogapong y Genoves"
Date:
Hello,
 
I am new in this list, and I am wondering if someone has
used postgreSQL trigger mechanism where each time an update
to a database table is done, dynamic parameters can be retrieved
from trigger function defined.
 
 
Thank you very much.
 
-glennJ
 
 

Re: trigger question

From
"Glenn John Ogapong y Genoves"
Date:
thanks very much.
 
let me send again my question:
 
trigger question:
  using c language in implementing functions called by trigger,
  how can we get the values of the added, deleted or updated
  row(s) and use it inside the c function?
 
Thanks very much
 
----- Original Message -----
Sent: Wednesday, May 07, 2003 12:55 AM
Subject: RE: [GENERAL] trigger question

Here is a copy of my function that updates table from another table upon insert

 

CREATE FUNCTION public.insert_userinfo() RETURNS trigger AS 'DECLARE

      sempty varchar(30):=''Password'';

      sop       varchar(2):=''=='';

      uname varchar(30);

      sstatus varchar(20):=''Active'';

       sdhcp   varchar(20):=''DHCP'';

      sframe varchar(30):=''Framed-IP-Address'';

BEGIN

 

IF NEW.status=sstatus THEN

 

 

INSERT INTO radcheck(username,attribute,op,value) VALUES

(NEW.username,sempty,sop,NEW.password);

INSERT INTO usergroup(username,groupname) VALUES

(NEW.username,NEW.groupname);

IF NEW.ipaddress!=sdhcp THEN

INSERT INTO radreply(username,attribute,op,value) VALUES (NEW.username,sframe,sop,NEW.ipaddress);

ELSE END IF;

 

 

End If;

Return NEW;

END;

LANGUAGE 'plpgsql' VOLATILE;

 

here is the trigger

 

CREATE TRIGGER insertdata BEFORE INSERT ON public.masteraccounts FOR EACH ROW EXECUTE PROCEDURE insert_userinfo();

 

 

 

-----Original Message-----
From: Glenn John Ogapong y Genoves [mailto:glennj@ntsp.nec.co.jp]
Sent: Tuesday, May 06, 2003 11:06 AM
To: pgsql-general@postgresql.org
Subject: [GENERAL] trigger question

 

Hello,

 

I am new in this list, and I am wondering if someone has

used postgreSQL trigger mechanism where each time an update

to a database table is done, dynamic parameters can be retrieved

from trigger function defined.

 

 

Thank you very much.

 

-glennJ