X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4B0BBD1B1C8 for ; Sun, 11 Jul 2004 15:52:22 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 19037-08 for ; Sun, 11 Jul 2004 18:52:19 +0000 (GMT) Received: from web41002.mail.yahoo.com (web41002.mail.yahoo.com [66.218.93.1]) by svr1.postgresql.org (Postfix) with SMTP id C1956D1B19C for ; Sun, 11 Jul 2004 15:52:16 -0300 (ADT) Message-ID: <20040711185216.59130.qmail@web41002.mail.yahoo.com> Received: from [151.204.106.102] by web41002.mail.yahoo.com via HTTP; Sun, 11 Jul 2004 11:52:16 PDT Date: Sun, 11 Jul 2004 11:52:16 -0700 (PDT) From: Theodore Petrosky Subject: Re: please help me with text cast to int .... To: Stephan Szabo , postgres SQL In-Reply-To: <20040711100337.Y854@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200407/62 X-Sequence-Number: 18314 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 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