Re: please help me with text cast to int ....

From: Theodore Petrosky <tedpet5(at)yahoo(dot)com>
To: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>, postgres SQL <pgsql-sql(at)postgresql(dot)org>
Subject: Re: please help me with text cast to int ....
Date: 2004-07-11 18:52:16
Message-ID: 20040711185216.59130.qmail@web41002.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)megazone(dot)bigpanda(dot)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(at)postgresql(dot)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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Ruggero 2004-07-12 08:27:53 Sorting problem
Previous Message Stephan Szabo 2004-07-11 17:06:06 Re: please help me with text cast to int ....