Re: PL/Perl returning multiple rows

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Joe Conway <mail(at)joeconway(dot)com>
Cc: Christopher Murtagh <christopher(dot)murtagh(at)mcgill(dot)ca>, 'PostgreSQL General' <pgsql-general(at)postgresql(dot)org>
Subject: Re: PL/Perl returning multiple rows
Date: 2003-11-11 19:25:48
Message-ID: 20031111192548.GC19912@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Nov 10, 2003 at 11:01:45PM -0800, Joe Conway wrote:

> create or replace function foo(text, text, text)
> returns text[] as '
> return "{\\"" . $_[0] . "\\",\\"" . $_[1] . "\\",\\"" . $_[2] . "\\"}";
> ' language plperl;

FWIW, this could be written more easily as

create or replace function foo(text, text, text)
returns text[] as '
return qq/{"/ . (join qq/","/, @_) . qq/"}/;
' language plperl;

Somewhat more readable.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Ellos andaban todos desnudos como su madre los parió, y también las mujeres,
aunque no vi más que una, harto moza, y todos los que yo vi eran todos
mancebos, que ninguno vi de edad de más de XXX años" (Cristóbal Colón)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Josué Maldonado 2003-11-11 19:46:48 update slow
Previous Message mboscia 2003-11-11 19:12:45 change conndeferrable in pg_constraint?