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 AA7ECD1B20E for ; Thu, 22 Jul 2004 16:09:23 -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 00812-05 for ; Thu, 22 Jul 2004 19:09:18 +0000 (GMT) Received: from web20824.mail.yahoo.com (web20824.mail.yahoo.com [216.136.227.140]) by svr1.postgresql.org (Postfix) with SMTP id C6E06D1B1F8 for ; Thu, 22 Jul 2004 16:09:15 -0300 (ADT) Message-ID: <20040722190916.89900.qmail@web20824.mail.yahoo.com> Received: from [24.248.12.72] by web20824.mail.yahoo.com via HTTP; Thu, 22 Jul 2004 12:09:16 PDT Date: Thu, 22 Jul 2004 12:09:16 -0700 (PDT) From: Jeff Eckermann Subject: Re: Converting a plperlu function to a plpgsql function To: devin@synapticvision.com Cc: pgsql-sql@postgresql.org In-Reply-To: <410005F7.2040109@joeconway.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/188 X-Sequence-Number: 18440 --- Joe Conway wrote: > Devin Whalen wrote: > > First line: > > my @active_tables=split(/,/,$tables); > > > > Is there anyway to split a variable like the perl > split above? > > I'm no perl guru, but in 7.4 I believe this does > what you're looking for: > > regression=# select string_to_array('1,2,3',','); > string_to_array > ----------------- > {1,2,3} > (1 row) > > > Second line: > > > > if ($r=~/^-([0-9]?)([A-z_]+)/) > > { > > my $locid = $1; > > my $table = $2; PostgreSQL doesn't offer capturing parentheses. The regex library does offer that, but no-one has yet done the coding to bring that functionality into PostgreSQL. You could do it in two steps: 1. Test using a regular expression 2. locid := substr(r,1); table := substr(r,2,1-len(r)) (better check the syntax on those). > > Not sure about this one. Hopefully someone else can > chime in. Maybe a > little less efficient, but it seems like it would be > easy enough to > parse when true. > > HTH, > > Joe > > ---------------------------(end of > broadcast)--------------------------- > TIP 1: subscribe and unsubscribe commands go to > majordomo@postgresql.org > __________________________________ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail