pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alberto Asuero Arroyo <albertoasuero@gmail.com>
To: Dmitriy Igrishin <dmitigr@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: select result into string's array
Date: Fri, 09 Oct 2009 11:08:52 +0200
Message-ID: <4ACEFDA4.60102@gmail.com> (raw)
In-Reply-To: <b4399d110910090131h425602ack6fe6ae8661a975a3@mail.gmail.com>
References: <4ACEE6A3.4090901@gmail.com>
	<b4399d110910090131h425602ack6fe6ae8661a975a3@mail.gmail.com>

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 <albertoasuero@gmail.com
> <mailto:albertoasuero@gmail.com>>
>
>     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
>     <mailto: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




view thread (4+ messages)

Message-ID: <4ACEFDA4.60102@gmail.com>
Permalink:  ../4ACEFDA4.60102@gmail.com/
Also on:    postgresql.org/message-id/4ACEFDA4.60102@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: albertoasuero@gmail.com, dmitigr@gmail.com
  Subject: Re: select result into string's array
  In-Reply-To: <4ACEFDA4.60102@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox