Search Postgresql Archives

Re: loops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jun 2, 2009 at 12:24 PM, John R Pierce <pierce@xxxxxxxxxxxx> 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));

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux