===== Cleaning =====
* Postcode Cleaning
SQL function:
CREATE OR REPLACE FUNCTION PostcodeClean (text,text,text,text) RETURNS text AS $$
$pri1=$_[0];
$pri2=$_[1];
$pri3=$_[2];
$postcode=$_[3];
if ($pri1) {return $pri1;}
if ($pri2) {return $pri2;}
if ($pri3) {return $pri3;}
if ($postcode) {
if ($postcode = ~ '\d{5}-\d{4}') {return $postcode}
if ($postcode = ~ '\d{5}') {return $postcode}
}
return undef;
$$ LANGUAGE plperl;
*State Cleaning
SQL function:
CREATE OR REPLACE FUNCTION StateClean (text,text,text,text) RETURNS text AS $$
$pri1=$_[0];
$pri2=$_[1];
$pri3=$_[2];
$state=$_[3];
if ($pri1) {return $pri1;}
if ($pri2) {return $pri2;}
if ($pri3) {return $pri3;}
if ($state) {return $state;}
return undef;
$$ LANGUAGE plperl;
*City Cleaning
SQL function:
CREATE OR REPLACE FUNCTION CityClean (text,text,text,text) RETURNS text AS $$
$pri1=$_[0];
$pri2=$_[1];
$pri3=$_[2];
$city=$_[3];
if ($pri1) {return $pri1;}
if ($pri2) {return $pri2;}
if ($pri3) {return $pri3;}
if ($city) {return $city;}
return undef;
$$ LANGUAGE plperl;
====Issues====