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 15D18D1B209 for ; Thu, 22 Jul 2004 16:21:02 -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 09366-04 for ; Thu, 22 Jul 2004 19:20:52 +0000 (GMT) Received: from 192.168.1.80 (unknown [66.207.200.34]) by svr1.postgresql.org (Postfix) with ESMTP id 324BBD1B1CF for ; Thu, 22 Jul 2004 16:20:50 -0300 (ADT) Received: by 192.168.1.80 (Postfix, from userid 500) id 6653C6A347; Thu, 22 Jul 2004 15:18:25 -0400 (EDT) Subject: Re: Converting a plperlu function to a plpgsql function From: Devin Whalen Reply-To: devin@synapticvision.com To: Jeff Eckermann , mail@joeconway.com Cc: pgsql-sql@postgresql.org In-Reply-To: <20040722190916.89900.qmail@web20824.mail.yahoo.com> References: <20040722190916.89900.qmail@web20824.mail.yahoo.com> Content-Type: text/plain Content-Transfer-Encoding: 7bit Organization: Synaptic Vision Message-Id: <1090523904.7474.195.camel@192.168.1.80> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6-2mdk Date: Thu, 22 Jul 2004 15:18:25 -0400 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/189 X-Sequence-Number: 18441 On Thu, 2004-07-22 at 15:09, Jeff Eckermann wrote: > --- 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 > > > > > > Hey, Thanks for the advice guys. The main reason that we wanted to change from a perl function was because we were having problems getting the perl library installed for postgres. We think we have solved that problem so it looks like I won't have to convert the function. However, your responses have made me realize that I can convert it. So I think I will convert it because it saves having to connect up to the database from inside the perl function. This might be a little faster?? Thanks for the help. Later -- Devin Whalen Programmer Synaptic Vision Inc Phone-(416) 539-0801 Fax- (416) 539-8280 1179A King St. West Toronto, Ontario Suite 309 M6K 3C5 Home-(416) 653-3982