Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

isnumeric equivalent in ASE 12.5.4

4 posts in General Discussion Last posting was on 2009-06-08 15:47:31.0Z
SenthilKumar Posted on 2009-06-03 13:31:55.0Z
Sender: 2ff0.4a267a29.1804289383@sybase.com
From: SenthilKumar
Newsgroups: sybase.public.ase.general
Subject: isnumeric equivalent in ASE 12.5.4
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4a267b4b.3008.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 3 Jun 2009 06:31:55 -0700
X-Trace: forums-1-dub 1244035915 10.22.241.41 (3 Jun 2009 06:31:55 -0700)
X-Original-Trace: 3 Jun 2009 06:31:55 -0700, 10.22.241.41
Lines: 7
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:27812
Article PK: 77061

Hi,
I am using ASE 12.5.4. I have a scenario where I need to
check whether a set of character (5 bytes) is numeric or
not. Could someone help me on how to achieve this in
12.5.4?

Thanks in advance for your support.


Rob V [Sybase] Posted on 2009-06-03 20:26:56.0Z
Reply-To: "Rob V [Sybase]" <robv@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY>
From: "Rob V [Sybase]" <robv@DO.NOT.SPAM.sypron.nl.REMOVE.THIS.DECOY>
Newsgroups: sybase.public.ase.general
References: <4a267b4b.3008.1681692777@sybase.com>
Subject: Re: isnumeric equivalent in ASE 12.5.4
Lines: 44
Organization: Sypron BV / TeamSybase / Sybase Inc
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3350
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4a26dc90@forums-1-dub>
Date: 3 Jun 2009 13:26:56 -0700
X-Trace: forums-1-dub 1244060816 10.22.241.152 (3 Jun 2009 13:26:56 -0700)
X-Original-Trace: 3 Jun 2009 13:26:56 -0700, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:27813
Article PK: 77062

Assuming your string is in a variable @v (and is not empty) :

if @v like "%[^0-9]%"
begin
print "string is not numeric"
end
else
begin
print "string is numeric"
end


You can exclude spaces by adding a space to the pattern inside the brackets.

HTH,

Rob V.
-----------------------------------------------------------------
Rob Verschoor

Certified Sybase Professional DBA for ASE 15.0/12.5/12.0/11.5/11.0
and Replication Server 15.0.1/12.5 // TeamSybase

Author of Sybase books (order online at www.sypron.nl/shop):
"Tips, Tricks & Recipes for Sybase ASE" (ASE 15 edition)
"The Complete Sybase ASE Quick Reference Guide"
"The Complete Sybase Replication Server Quick Reference Guide"

mailto:rob@YOUR.SPAM.sypron.nl.NOT.FOR.ME
http://www.sypron.nl
Sypron B.V., Amersfoort, The Netherlands
Chamber of Commerce 27138666
-----------------------------------------------------------------

<SenthilKumar> wrote in message news:4a267b4b.3008.1681692777@sybase.com...
> Hi,
> I am using ASE 12.5.4. I have a scenario where I need to
> check whether a set of character (5 bytes) is numeric or
> not. Could someone help me on how to achieve this in
> 12.5.4?
>
> Thanks in advance for your support.


Bret Halford [Sybase] Posted on 2009-06-08 15:47:31.0Z
From: "Bret Halford [Sybase]" <bret@sybase.com>
Organization: Sybase, Inc.
User-Agent: Thunderbird 2.0.0.21 (Windows/20090302)
MIME-Version: 1.0
Newsgroups: sybase.public.ase.general
Subject: Re: isnumeric equivalent in ASE 12.5.4
References: <4a267b4b.3008.1681692777@sybase.com> <4a26dc90@forums-1-dub>
In-Reply-To: <4a26dc90@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <4a2d3293$1@forums-1-dub>
Date: 8 Jun 2009 08:47:31 -0700
X-Trace: forums-1-dub 1244476051 10.22.241.152 (8 Jun 2009 08:47:31 -0700)
X-Original-Trace: 8 Jun 2009 08:47:31 -0700, vip152.sybase.com
Lines: 22
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:27826
Article PK: 77077


Rob V [Sybase] wrote:
> Assuming your string is in a variable @v (and is not empty) :
>
> if @v like "%[^0-9]%"
> begin
> print "string is not numeric"
> end
> else
> begin
> print "string is numeric"
> end
>
>
> You can exclude spaces by adding a space to the pattern inside the brackets.
>

Good as far as it goes, but only covers positive integers.

OP, does your data include negative numbers?
Numbers with a decimal point?
E-notation numbers such as "5e8", "-5e8", "5e-8", and "-5e-8"?


tartampion Posted on 2009-06-04 16:08:36.0Z
Sender: 7160.4a243b2f.1804289383@sybase.com
From: TARTAMPION
Newsgroups: sybase.public.ase.general
Subject: Re: isnumeric equivalent in ASE 12.5.4
X-Mailer: WebNews to Mail Gateway v1.1t
Message-ID: <4a27f184.608f.1681692777@sybase.com>
References: <4a267b4b.3008.1681692777@sybase.com>
NNTP-Posting-Host: 10.22.241.41
X-Original-NNTP-Posting-Host: 10.22.241.41
Date: 4 Jun 2009 09:08:36 -0700
X-Trace: forums-1-dub 1244131716 10.22.241.41 (4 Jun 2009 09:08:36 -0700)
X-Original-Trace: 4 Jun 2009 09:08:36 -0700, 10.22.241.41
Lines: 34
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub sybase.public.ase.general:27817
Article PK: 77068

Would the following help?
suppose that the table tb1 contain the following character
data
a
-------
12345
12a45
123a4
1234a
67891
we can do the following select from it which transform the
char numeric values to integer and the non-numeric to
integer value 0


select case when a like "%[^0-9]%" then 0 else
convert(int,a) end from tb1

--------
12345
0
0
0
64891

> Hi,
> I am using ASE 12.5.4. I have a scenario where I need to
> check whether a set of character (5 bytes) is numeric or
> not. Could someone help me on how to achieve this in
> 12.5.4?
>
> Thanks in advance for your support.