Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 5A3B42E3323 for ; Sun, 23 Dec 2007 17:19:32 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 77518-10 for ; Sun, 23 Dec 2007 17:19:23 -0400 (AST) Received: from fk-out-0910.google.com (fk-out-0910.google.com [209.85.128.191]) by postgresql.org (Postfix) with ESMTP id AD8402E30CD for ; Sun, 23 Dec 2007 17:19:27 -0400 (AST) Received: by fk-out-0910.google.com with SMTP id b27so1675290fka.3 for ; Sun, 23 Dec 2007 13:19:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=jN1A3yNyQ8hlvIYofAZiZp7sXgy6yvNePn7IIExwZtw=; b=sxSUWuele9glgVnBuMQvYHKyga4MMKyOKBTT7v8s4YwXXg0hK752mMjbZvd6Wr1llyJPMh2DI8RuT338i1hxMqdnssbItdb+EBJDf13AWM21dKR5ITbcMCUN+WAz4U3S3bqnc0sC5sMoD0ARWSHsYmMogdnvEg6vpTbro10oZn8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=xKqcCvP1LdWKdohFRO2K5KkflADYuRbwQAMg27sRLlXCs1vY1P4+mDkEkryIhy2A4KB8Dv+HC9/HrTlCU3W55don2nLKgeH1gJ8luWHi2xejrU+9tOA0gSOsFokFPZ39rXApfcoFWYlDI/Kyikk47H1q5hFeqMna7Zx+ptBldLw= Received: by 10.78.167.12 with SMTP id p12mr4911620hue.20.1198444766257; Sun, 23 Dec 2007 13:19:26 -0800 (PST) Received: by 10.78.35.10 with HTTP; Sun, 23 Dec 2007 13:19:26 -0800 (PST) Message-ID: <162867790712231319i35fb31el8d4c367bc313979b@mail.gmail.com> Date: Sun, 23 Dec 2007 22:19:26 +0100 From: "Pavel Stehule" To: pgsql-sql@postgresql.org Subject: Re: returning an array as a list fo single-column rows? In-Reply-To: <20071223205557.GA14403@apartia.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20071223205557.GA14403@apartia.fr> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200712/120 X-Sequence-Number: 29812 Hello try create or replace function unpack(anyarray) returns setof anyelement as $$ select $1[i] from generate_series(array_lower($1,1), array_upper($1,1)) g(i); $$ language sql; postgres=# select * from unpack(array[1,2,3,4]); unpack -------- 1 2 3 4 (4 rows) Regards Pavel Stehule On 23/12/2007, Louis-David Mitterrand wrote: > Hi, > > is there a way to return a Pg array as a list of single-column row > values? > > I am trying to circumvent DBI's lack of support for native database > arrays and return the list of values from an ENUM as a perl array. > > Thanks, > > ---------------------------(end of broadcast)--------------------------- > TIP 7: You can help support the PostgreSQL project by donating at > > http://www.postgresql.org/about/donate >