Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger help!

Status
Not open for further replies.

clearip

Programmer
Jan 7, 2007
1
GB
I am used to writting triggers for MSSQL but have come unstuck now I need to write one for a postgres db. If anyone can help I would be very appreciative.

I have a cdr table that receives data as follows:

insert into lookup_cdr (setup_time, gatekeeper_name, call_number, call_duration, disconnect_cause, acct_session_id, h323_id, gkip, callid, confid, caller_ip, caller_port, callee_ip, callee_port, src_info, dest_info, calling_station_id, called_station_id, dialed_number)
values ('2007-01-07 17:50:16', 'xxxxxxxxxxxxxx', '1', 0, 0, '45a132d100000001', 'root', xxx.xxx.xxx.xxx', '', '', 'xxx.xxx.xxx.xxx', '56250', 'xxx.xxx.xxx.xxx', '1720', 'root:h323_ID', '1234234334477221111111:dialedDigits', '', '', '');

at present I fire this string:

insert into lookups (msisdn, mobileno) select substr('1234234334477221111111:dialedDigits',5,5) as msisdn, substr('1234234334477221111111:dialedDigits',10,12) as mobileno where length('1234234334477221111111:dialedDigits') = 34 and 'xxx.xxx.xxx.xxx' = 'xxx.xxx.xxx.xxx'

however due to restrictions within the application I need to move this second insert on to a trigger. '1234234334477221111111:dialedDigits' would be being passed to the trigger as a value from the insert. Where as the 'xxx.xxx.xxx.xxx's would be hard coded.


I hope this makes some sort of sense!

Thanks for any help :)

Neil
 
Have you checked the Postgres Help for Triggers?

Unlike the MySQL help search for simple terms, your search should go quite fast and easy in Postgres. In the help index, just type "trigger".


Gary
gwinn7
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top