pears.DistanceBetweenPostCodes

Generated schema reference. Regenerate this page from the SQL unload; keep hand-maintained business notes in the narrative namespace.

COMMENT TO PRESERVE FORMAT ON PROCEDURE "pears"."DistanceBetweenPostCodes" IS 
{CREATE FUNCTION DistanceBetweenPostCodes 
 
/* Application Maintained Function / Procedure - DO NOT EDIT*/
 
( IN @PostCodeA CHAR(20),IN @PostCodeB CHAR(20),IN @Unit CHAR(2) ) 
RETURNS NUMERIC(11,3)
BEGIN
  DECLARE @EastingA NUMERIC(11,3);
  DECLARE @EastingB NUMERIC(11,3);
  DECLARE @NorthingA NUMERIC(11,3);
  DECLARE @NorthingB NUMERIC(11,3);
  DECLARE @Distance NUMERIC(11,3);
  SELECT FIRST "Easting","Northing" INTO @EastingA,@NorthingA FROM "PostCodeLocation" WHERE "PostCode" = "trim"(@PostCodeA);
  SELECT FIRST "Easting","Northing" INTO @EastingB,@NorthingB FROM "PostCodeLocation" WHERE "PostCode" = "trim"(@PostCodeB);
  SET @Distance = "sqrt"("power"("abs"(@NorthingA-@NorthingB),2)+"power"("abs"(@EastingA-@EastingB),2))/1000*IF @Unit = 'Mi' THEN .621371192 ELSE 1 endif;
  SET @Distance = @Distance*CAST("WPKMaintainGetSwitchValue"('POSTCODEMULT','GLOBAL','L') AS DOUBLE);
  RETURN(@Distance)
END
}
  • database/procedures/pears_distancebetweenpostcodes.txt
  • Last modified: 2026/08/07 19:24
  • by 127.0.0.1