is_string or is_numeric

is_string or is_numeric

am 15.10.2009 11:34:18 von uYe

Hi,
I found no built in function in mysql to check whether a record is
numeric or string. Is there any trick to do so? Many thanks.




Willy


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org

Re: is_string or is_numeric

am 15.10.2009 11:43:39 von Glyn Astill

> From: sangprabv =0A> Subject: is_string or is_numeri=
c=0A> To: mysql@lists.mysql.com=0A> Date: Thursday, 15 October, 2009, 10:34=
AM=0A> Hi,=0A> I found no built in function in mysql to check whether a=0A=
> record is=0A> numeric or string. Is there any trick to do so? Many=0A> th=
anks. You could use some regex to do it... In fact, a google brin=
gs up this (http://forums.mysql.com/read.php?60,1907,241284#msg-241284) =0A=
=0ACREATE FUNCTION ISNUMERIC(myVal VARCHAR(1024))=0ARETURNS TINYINT(1) DETE=
RMINISTIC=0ARETURN myVal REGEXP '^(-|\\+)?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|=
[0-9]+)$'; =0AGlyn =0A

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=3Dgcdmg-mysql-2@m.gmane.o rg

Re: is_string or is_numeric

am 15.10.2009 11:56:32 von Claudio Nanni - TomTom

--0014853dfa8b51c72c0475f64be7
Content-Type: text/plain; charset=ISO-8859-1

Only in the case you want to know the datatype and not the actual type of
information in a char field!

If you issue:

show fields from MyTable like 'FName';

you get:
+-------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| FName | varchar(255) | YES | | NULL | |
+-------+--------------+------+-----+---------+-------+

although is not a function if you place the result into an array on the
application side you can pull the value of the Type attribute.


Hope this helps anyway!


Claudio


2009/10/15 Glyn Astill

> > From: sangprabv
> > Subject: is_string or is_numeric
> > To: mysql@lists.mysql.com
> > Date: Thursday, 15 October, 2009, 10:34 AM
> > Hi,
> > I found no built in function in mysql to check whether a
> > record is
> > numeric or string. Is there any trick to do so? Many
> > thanks.
>
> You could use some regex to do it...
>
> In fact, a google brings up this (
> http://forums.mysql.com/read.php?60,1907,241284#msg-241284)
>
> CREATE FUNCTION ISNUMERIC(myVal VARCHAR(1024))
> RETURNS TINYINT(1) DETERMINISTIC
> RETURN myVal REGEXP '^(-|\\+)?([0-9]+\\.[0-9]*|[0-9]*\\.[0-9]+|[0-9]+)$';
>
>
> Glyn
>
>
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=claudio.nanni@gmail.com
>
>


--
Claudio

--0014853dfa8b51c72c0475f64be7--

Re: is_string or is_numeric

am 15.10.2009 13:03:48 von walter harms

Do your realy need to know the differenz ? take everything as "string".
(breaks with pics/geodata but helps a lot).

re,
wh

sangprabv schrieb:
> Hi,
> I found no built in function in mysql to check whether a record is
> numeric or string. Is there any trick to do so? Many thanks.
>
>
>
>
> Willy
>
>

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql?unsub=gcdmg-mysql-2@m.gmane.org