From: Theodore Petrosky <tedpet5@yahoo.com>
To: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: postgres SQL <pgsql-sql@postgresql.org>
Subject: Re: please help me with text cast to int ....
Date: Sun, 11 Jul 2004 11:52:16 -0700 (PDT)
Message-ID: <20040711185216.59130.qmail@web41002.mail.yahoo.com> (raw)
In-Reply-To: <20040711100337.Y854@megazone.bigpanda.com>
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
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: tedpet5@yahoo.com, sszabo@megazone.bigpanda.com
Subject: Re: please help me with text cast to int ....
In-Reply-To: <20040711185216.59130.qmail@web41002.mail.yahoo.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