Re: please help me with text cast to int .... - Mailing list pgsql-sql

From Theodore Petrosky
Subject Re: please help me with text cast to int ....
Date
Msg-id 20040711185216.59130.qmail@web41002.mail.yahoo.com
Whole thread Raw
In response to Re: please help me with text cast to int ....  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
List pgsql-sql
Thank you.... this pointed me to the problem. I have
non castable entries. I had picked up legacy data (for
the jobnumbers [that's why they were text in the first
place]) and some of the jobnumbers where 1162_01  
1162_02   so this would fail. 

The error message was giving me the correct message
however I failed to see it. Silly me, I kept thinking
that it was an error code that I didn't recognize...

Thanks again.

Ted

--- Stephan Szabo <sszabo@megazone.bigpanda.com>
wrote:
> 
> On Sun, 11 Jul 2004, Theodore Petrosky wrote:
> 
> > I give up.. what don't I understand about casting
> and
> > ints and text..
> >
> > i have a table jobinfo with:
> >
> > acode text,
> > jobnumber text default
> > nextval('public.jobinfo_seq'::text),
> > jobtitle text
> >
> > I have about 3000 rows starting with jobnumber =
> 1000.
> >
> > SELECT jobnumber, jobtitle FROM jobinfo WHERE
> > jobnumber >= 999 ORDER BY jobnumber ASC;
> 
> This is going to do a textual comparison, not an
> integer one.
> So it's looking for jobnumbers greater than the
> string '999'.
> 
> If you want to treat jobnumber as an integer,
> CAST(jobnumber as integer)
> >= 999 may be what you want.  Note, however that it
> will fail if there are
> any non-numeric jobnumber rows.  In general, storing
> numbers in strings
> that you want to act upon as numbers is a bad idea.
> 
> 
> ---------------------------(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
> 

    
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail


pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: please help me with text cast to int ....
Next
From: Rajesh Kumar Mallah
Date:
Subject: Comparing tsearch2 vectors.