loops
loops
От:
"Esneiker" <eenriquez@cav.desoft.cu>
Дата:
Hello, can anybody tell me how to do loops in postgres?
Thanks.
Ing. Esneiker Enriquez Cabrera.
Excelencia en Software.
Desoft S.A. en Ciego de Ávila.
Joaquín de Agüero Esq. Calle 2. Ciego de Ávila. Cuba.
email:eenriquez@cav.desoft.cu
Re: loops
От:
hubert depesz lubaczewski <depesz@depesz.com>
Дата:
On Tue, Jun 02, 2009 at 11:32:03AM -0400, Esneiker wrote: > Hello, can anybody tell me how to do loops in postgres? As usually, the fine manual: http://www.postgresql.org/docs/current/interactive/plpgsql-control-structures.html Best regards, depesz -- Linkedin: http://www.linkedin.com/in/depesz / blog: http://www.depesz.com/ jid/gtalk: depesz@depesz.com / aim:depeszhdl / skype:depesz_hdl / gg:6749007
Re: loops
От:
John R Pierce <pierce@hogranch.com>
Дата:
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.
Re: loops
От:
Merlin Moncure <mmoncure@gmail.com>
Дата:
On Tue, Jun 2, 2009 at 12:24 PM, John R Pierce 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));