Re: greetings
От | Ken Kline |
---|---|
Тема | Re: greetings |
Дата | |
Msg-id | 3A980760.87DAC5AC@oldbs.com обсуждение исходный текст |
Ответ на | greetings (Ken Kline <ken@oldbs.com>) |
Ответы |
Re: greetings
|
Список | pgsql-sql |
it is to be server side code.... the code I gave you was merely an example of a cursor that I found when I did a search... http://www.armed.net/how/pg001676.htm orginally what I wanted to do was this: INSERT INTO pledge_classes (semester, year) SELECT distinct pseason, pyear from load_bros WHERE pyear is not null AND pseason is not null order by pyear, pseason; however pgsql does not allow order by in an INSERT-SELECT statement so i thought maybe I could do something like this: DECLARE CURSOR get_rows AS SELECT DISTINCT pseason, pyear FROM load_members WHERE pyear IS NOT NULL AND pseason IS NOT NULL ORDER BY pyear, pseason; BEGIN FOR rec IN get rows LOOP INSERT INTO pledge_classes (semester, year) VALUES (rec.pseason, rec.pyear); END LOOP; COMMIT; END; / Well, all the code I just showed you works in orcacle but pgsql is a little different and even though the book has an example of a cursor http://www.postgresql.org/docs/aw_pgsql_book/node142.html it does not explain before hand 1) the format of an anoymous block 2) how to loop a cursor 3) how to reference columns froma cursor row (ie rec.column_name) thanks Ken Tom Lane wrote: > Ian Lance Taylor <ian@airs.com> writes: > > PL/pgSQL does not support cursors. It also does not support goto. > > The context is pretty unclear here, but perhaps he needs ecpg not > plpgsql ... is this to be client- or server-side code? > > regards, tom lane
В списке pgsql-sql по дате отправления: