CREATE OR REPLACE FUNCTION IsNumeric(
	pstrInParam varchar(255)
) RETURNS boolean AS '
DECLARE
	--pstrInParam ALIAS FOR $1;
	i					integer;
	bNotNumeric			boolean;
BEGIN
	bNotNumeric := False;
	IF SUBSTRING(pstrInParam, 1, 1) ~ ''[0-9]'' OR SUBSTRING(pstrInParam, 1, 1) = ''-'' OR SUBSTRING(pstrInParam, 1, 1) = ''+'' THEN
	ELSE
		RETURN False;
	END IF;
	FOR i IN 2..Length(pstrInParam) LOOP
		IF NOT SUBSTRING(pstrInParam, i, 1) ~ ''[0-9]'' THEN
			IF SUBSTRING(pstrInParam, i, 1) <> ''.'' THEN
				bNotNumeric := True;
			END IF;
		END IF;
	END LOOP;
	RETURN NOT bNotNumeric;
END
'
language 'plpgsql';
