X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 99E42D1EB67 for ; Sat, 1 May 2004 11:29:33 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 91167-10 for ; Sat, 1 May 2004 11:29:17 -0300 (ADT) Received: from web20803.mail.yahoo.com (web20803.mail.yahoo.com [216.136.226.192]) by svr1.postgresql.org (Postfix) with SMTP id D27C2D1EB65 for ; Sat, 1 May 2004 11:29:12 -0300 (ADT) Message-ID: <20040501142916.42206.qmail@web20803.mail.yahoo.com> Received: from [68.107.248.174] by web20803.mail.yahoo.com via HTTP; Sat, 01 May 2004 07:29:16 PDT Date: Sat, 1 May 2004 07:29:16 -0700 (PDT) From: Jeff Eckermann Subject: Re: isnumeric() function? To: Yudie Cc: pgsql-sql@postgresql.org In-Reply-To: <001b01c42ec7$c64ed040$8401a8c0@home.axiontech.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.1 tagged_above=0.0 required=5.0 tests=RCVD_IN_SORBS X-Spam-Level: X-Archive-Number: 200405/2 X-Sequence-Number: 17716 --- Yudie wrote: > Great the function works, but what does it means? > SELECT $1 ~ ''^[0-9]+$'' > > Yudie "~" is the regular expression match operator; the text inside the quotes is a regular expression. Look here for a reference: http://www.postgresql.org/docs/7.2/interactive/functions-matching.html#FUNCTIONS-REGEXP The function definition in my note was intended as an example; it won't necessarily do exactly what you want. For example, it will reject a decimal point (in that case, try SELECT $1 ~ ''^[0-9]+(\\.[0-9]+)?$''). If you are not familiar with regular expressions, consider spending a little time learning about them. They are simply the best way to do pattern matching, and if you do any amount of text processing at all, time spent learning will repay you very well. > > ----- Original Message ----- > From: "Jeff Eckermann" > To: "Yudie" ; > > Sent: Friday, April 30, 2004 9:11 AM > Subject: Re: [SQL] isnumeric() function? > > > --- Yudie wrote: > > What is isnumeric function in postgresql? > > I'm using psql version 7.2.2 > > thanks > > Yudie > > I don't think that function is included as such. > But > you could do something like: > > CREATE FUNCTION isnumeric(text) RETURNS boolean AS ' > SELECT $1 ~ ''^[0-9]+$'' > ' LANGUAGE 'sql'; > > Note that you would need to create this function for > every parameter datatype that you would intend to > use, > or else be prepared to cast your input datatype as > appropriate. > > > > > > > ---------------------------(end of > > broadcast)--------------------------- > > TIP 2: you can get off all lists at once with the > > unregister command > > (send "unregister YourEmailAddressHere" to > majordomo@postgresql.org) > > > > > > __________________________________ > Do you Yahoo!? > Win a $20,000 Career Makeover at Yahoo! HotJobs > http://hotjobs.sweepstakes.yahoo.com/careermakeover > > ---------------------------(end of > broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > > __________________________________ Do you Yahoo!? Win a $20,000 Career Makeover at Yahoo! HotJobs http://hotjobs.sweepstakes.yahoo.com/careermakeover