2013년 10월 23일 수요일

"is number" function on postgresql

-- Function: is_number(text)

CREATE OR REPLACE FUNCTION is_number(num text)
  RETURNS boolean AS
$BODY$
BEGIN
RETURN textregexeq(num,E'^-*[[:digit:]]+(\\.[[:digit:]]+)?$');
END;
$BODY$
  LANGUAGE plpgsql IMMUTABLE;

if you need more detail, use a exception logic to convert data type to numeric.