I'm new to Postgres, and getting nowhere with a PL/Perl trigger that
I'm trying to write - hopefully, someone can give me some insight into
what I'm doing wrong. My trigger is designed to reformat /
standardize phone numbers and it looks like this:
CREATE or REPLACE FUNCTION fixphone() RETURNS trigger AS $$
$number .= $_TD->{new}{phone};
$number =~ s/(-|\.|\(|\)| )//g;
$number .= substr($number,0,3) . "." .
substr($number,3,3) . "." .
substr($number,6,4);
$_TD->{new}{phone} .= $number;
return "MODIFY";
$$ LANGUAGE plperl;
CREATE TRIGGER "cust_fixphone" BEFORE INSERT OR UPDATE ON customer
FOR EACH ROW EXECUTE PROCEDURE "fixPhone"();
CREATE TRIGGER "vend_fixphone" BEFORE INSERT OR UPDATE ON vendor
FOR EACH ROW EXECUTE PROCEDURE "fixPhone"();
All I see in my web app, when the trigger fires, is:
DBD::Pg::db do failed: server closed the connection unexpectedly
And, when I try to update a row in psql I see:
server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.
Any help would truly be appreciated. Thanks in advance
Dunc