isnumeric - checking if text variable is convertable to numeric

From: "SunWuKung" <Balazs(dot)Klein(at)t-online(dot)hu>
To: pgsql-general(at)postgresql(dot)org
Subject: isnumeric - checking if text variable is convertable to numeric
Date: 2006-04-24 12:31:46
Message-ID: 1145881906.855705.70740@t31g2000cwb.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I am writing a pgsql function and I would need to create a condition
based on the value of a text variable. I would need to check if
text_var is convertable to numeric type and if yes do the conversion,
if no do something else. I couldn't find out how to do that.

Something like:
IF isnumeric(text_var) Then
num_var:=Cast (text_var AS numeric);
ELSE
....
END IF;

Thanks for the help.
Balázs

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Claudio Tognolo 2006-04-24 13:37:41 Commit rules or Commit trigger
Previous Message Shane Ambler 2006-04-24 12:11:45 Re: to know