Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Pgsql Sql > How I can check...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 3432 of 3661
Post > Topic >>

How I can check a substring is a valid number in postgresql ?

by anoopmadavoor@[EMAIL PROTECTED] ("Anoop G") Apr 24, 2008 at 07:04 PM

------=_Part_7980_29135660.1209044090089
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Dear All,

    How I can check a substring is a valid number in postgresql ?


example:

I have a query

select max(substring(code,2,length(code))::INT) from emp where
substring(code,0,2) = 'A';



code
========
A0001
A0002
ABC005
S0002

This query fails because of ABC002, how I can avoid this error , if there
is
a any way to check substring(code,1,length(code))  is a number ,then i can
correct the query by put it in where condition.

I want to get the result as 2(ie want to avoid checking ABC005

is there is any built in function to check the substring is a number in
postgresql?

Iam using  postgres 8.1.8

 pls help me


thanks in advance:

Anoop

------=_Part_7980_29135660.1209044090089
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<span class="HcCDpe">Dear All,<br>
<br>
&nbsp;&nbsp;&nbsp; How I can check a substring is a valid number in
postgresql ?<br>
<br>
<br>
example:<br>
<br>
I have a query <br>
<br>
select max(substring(code,2,length(code))::INT) from emp where
substring(code,0,2) = &#39;A&#39;; <br>
<br>
<br>
<br>
code <br>
========<br>
A0001<br>
A0002<br>
ABC005<br>
S0002<br>
<br>
This query fails because of </span><span class="HcCDpe">ABC002, how I can
avoid this error , if there is a any way to check </span><span
class="HcCDpe">substring(code,1,length(code))&nbsp; is a number ,then i
can correct the query by put it in where condition.<br>

<br>
I want to get the result as 2(ie want to avoid checking ABC005<br>
<br>
is there is any built in function to check the substring is a number in
postgresql?<br>
<br>
Iam using&nbsp; postgres 8.1.8 <br>
<br>
&nbsp;pls help me <br><br>
<br>
thanks in advance:<br>
<br>
Anoop</span>

------=_Part_7980_29135660.1209044090089--
 




 2 Posts in Topic:
How I can check a substring is a valid number in postgresql ?
anoopmadavoor@[EMAIL PROT  2008-04-24 19:04:50 
Re: How I can check a substring is a valid number in postgresql
yazicivo@[EMAIL PROTECTED  2008-04-24 16:53:15 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Sep 6 15:39:36 CDT 2008.