Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 0263B633237 for ; Fri, 9 Oct 2009 06:09:06 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 63480-06 for ; Fri, 9 Oct 2009 09:08:58 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f223.google.com (mail-bw0-f223.google.com [209.85.218.223]) by mail.postgresql.org (Postfix) with ESMTP id ED6C8632CB3 for ; Fri, 9 Oct 2009 06:08:57 -0300 (ADT) Received: by bwz23 with SMTP id 23so480254bwz.19 for ; Fri, 09 Oct 2009 02:08:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:cc:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=1kHTj7X/AfBNzWFj/f2FMR0NhFgxKA/JAFfC1RKGwpk=; b=i2nlp5Uuz/MHdmUK8Dpy+F15xA/w1nFVN5r9I5wl56ZYOqtMzMqT0YiBJDngwSAaFz J0l4MMYULtQZTYok03ep38iFGacceXPehx0UExzlJxS41ce4uFeXYd9mqPQ88p92mLFh +96sXneXrObpCcYCuaobMsvRF+B29yhBR1LzY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; b=QjtSTqbSPDQpQc+v8F/iwTw/wu/+sxvUYTxa8XFH7AvFUrFfnQ89dkE6/J4Ssq5eo+ slm8fz/47fVis18cWg73orq2wW2Ae7G6lSDIAPA82ne3IyiC7Lgl1fyxiLsMUcCsNV8O ULRPneDIIOelLult/wJ3ccjegfJOIIFj2siZo= Received: by 10.103.67.32 with SMTP id u32mr954942muk.133.1255079335554; Fri, 09 Oct 2009 02:08:55 -0700 (PDT) Received: from ?10.30.102.23? (100.Red-80-37-140.staticIP.rima-tde.net [80.37.140.100]) by mx.google.com with ESMTPS id y37sm2284668mug.34.2009.10.09.02.08.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 09 Oct 2009 02:08:54 -0700 (PDT) Message-ID: <4ACEFDA4.60102@gmail.com> Date: Fri, 09 Oct 2009 11:08:52 +0200 From: Alberto Asuero Arroyo User-Agent: Thunderbird 2.0.0.23 (X11/20090817) MIME-Version: 1.0 To: Dmitriy Igrishin CC: pgsql-sql@postgresql.org Subject: Re: select result into string's array References: <4ACEE6A3.4090901@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 200910/33 X-Sequence-Number: 33232 Dmitriy Igrishin wrote: > Hello. > > You should use an array constructor: > > DECLARE > m_array text[]; > [..] > BEGIN > FOR m_array IN SELECT ARRAY[col_1, col_2, col_N] FROM my_table LOOP > [..] > END LOOP; > > Regards, > Igrishin Dmitriy. > > 2009/10/9 Alberto Asuero Arroyo > > > Hi, > > I need to store the result of select into an array of string: > > /create or replace function search_engine.test/ > /(/ > /)/ > / returns integer as $$/ > /declare/ > / m_array text[];/ > /begin/ > / for m_array in select * from my_table loop/ > / raise notice 'valor 1: %',m_array;/ > / end loop;/ > / return 1;/ > /end; $$ LANGUAGE plpgsql;/ > > > This launch this errors: > > /ERROR: array value must start with "{" or dimension information > SQL state: 22P02 > Context: PL/pgSQL function "test" line 4 at FOR over SELECT rows/ > > > Is it possible do this?? May I choose another way? > > Thanks in advance > > Alberto, > > > > -- > Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org > ) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-sql > > It's has been really useful for my to solve the dinamic Record Introspection problem that I had. Thanks, Alberto