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
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