From: Anoop G <anoopmadavoor@gmail.com>
To: pgsql-sql@postgresql.org
Subject: How I can check a substring is a valid number in postgresql ?
Date: Thu, 24 Apr 2008 19:04:50 +0530
Message-ID: <1a027d210804240634w4ee63ccdi251757231d3827bf@mail.gmail.com> (raw)
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: anoopmadavoor@gmail.com
Subject: Re: How I can check a substring is a valid number in postgresql ?
In-Reply-To: <1a027d210804240634w4ee63ccdi251757231d3827bf@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox