Validating Whole Numbers
Is there a quick way to validate whole numbers for instance you can validate
a number
if (is_numeric($x)
{
output
}
else
{
output
}
Thanks in advance
How about:
WHERE x ~ '^[0-9]*$'
"Krog, Kenneth" wrote:
Show quoted text
Is there a quick way to validate whole numbers for instance you can validate
a numberif (is_numeric($x)
{
output
}
else
{
output
}Thanks in advance
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
WHERE x ~ '^[0-9]*$'
You might want to change that asterick to a plus:
WHERE x ~ '^[0-9]+$'
so you don't get a false negative for an empty string.
Greg Sabino Mullane greg@turnstep.com
PGP Key: 0x14964AC8 200203042125
-----BEGIN PGP SIGNATURE-----
Comment: http://www.turnstep.com/pgp.html
iD8DBQE8hC3FvJuQZxSWSsgRAmxnAJ9f/63H8JYnDjYc5VeVpOyrNxQm0ACaAjOY
3rmFQpTMVK+SrXJx7kOt9S0=
=PTUa
-----END PGP SIGNATURE-----
Import Notes
Resolved by subject fallback