Re: Converting a plperlu function to a plpgsql function - Mailing list pgsql-sql

From Jeff Eckermann
Subject Re: Converting a plperlu function to a plpgsql function
Date
Msg-id 20040722190916.89900.qmail@web20824.mail.yahoo.com
Whole thread Raw
In response to Re: Converting a plperlu function to a plpgsql function  (Joe Conway <mail@joeconway.com>)
Responses Re: Converting a plperlu function to a plpgsql function  (Devin Whalen <devin@synapticvision.com>)
Re: Converting a plperlu function to a plpgsql function  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
--- Joe Conway <mail@joeconway.com> 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


pgsql-sql by date:

Previous
From: Joe Conway
Date:
Subject: Re: Converting a plperlu function to a plpgsql function
Next
From: Devin Whalen
Date:
Subject: Re: Converting a plperlu function to a plpgsql function