From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
---|---|
To: | John R Pierce <pierce(at)hogranch(dot)com> |
Cc: | Esneiker <eenriquez(at)cav(dot)desoft(dot)cu>, pgsql-general(at)postgresql(dot)org |
Subject: | Re: loops |
Date: | 2009-06-02 20:30:30 |
Message-ID: | b42b73150906021330x744770f8k43450ccfe8409f34@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, Jun 2, 2009 at 12:24 PM, John R Pierce <pierce(at)hogranch(dot)com> wrote:
> Esneiker wrote:
>>
>> Hello, can anybody tell me how to do loops in postgres?
>>
>
> SQL, the query language, has no such control structures. SQL is a
> 'declarative' language rather than a procedural one.
>
> pl/pgsql stored procedures do, however, as they embed SQL in a procedural
> context. depesz posted the link to the appropriate docs.
you can simulate simple loops with 'generate_series' and other set
returning functions like unnest or equivalent:
insert into foo(foo_id) select generate_series(1,10) v;
insert into foo(val) select unnest(current_schemas(true));
From | Date | Subject | |
---|---|---|---|
Next Message | Geoffrey | 2009-06-02 20:41:51 | Re: warm standby with WAL shipping |
Previous Message | Ben Chobot | 2009-06-02 20:23:29 | Re: Really out of memory? |