From: Ken Kline <ken@oldbs.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Ian Lance Taylor <ian@airs.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: greetings
Date: Sat, 24 Feb 2001 14:11:28 -0500
Message-ID: <3A980760.87DAC5AC@oldbs.com> (raw)
References: <3A974086.EF665152@oldbs.com>
<siae7c1tso.fsf@daffy.airs.com>
<11378.982997569@sss.pgh.pa.us>
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: ken@oldbs.com, tgl@sss.pgh.pa.us, ian@airs.com
Subject: Re: greetings
In-Reply-To: <3A980760.87DAC5AC@oldbs.com>
References: <3A974086.EF665152@oldbs.com> <siae7c1tso.fsf@daffy.airs.com> <11378.982997569@sss.pgh.pa.us> <3A980760.87DAC5AC@oldbs.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