Cursors

From: Michael Guerin <guerin(at)rentec(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Cursors
Date: 2003-08-24 16:21:54
Message-ID: 3F48E622.8060302@rentec.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

I'm trying to convert a sql server stored procedure into a postgresql
function and I seem to get stuck on converting the cursor.

sql server snipet
DECLARE @x int, @y int
DECLARE rs CURSOR FOR
SELECT x,y from foo;
OPEN rs
FETECH NEXT FROM rs into @x, @y
WHILE (@@FETCH_STATUS =0)
BEGIN
--do something
FETECH NEXT FROM rs into @x, @y
END
CLOSE rs
DEALLOCATE rs
...

--------------------------
PostgreSQL ???
x int;
y int;
DECLARE rs CURSOR FOR
SELECT x,y from foo;
OPEN rs
FETCH NEXT FROM rs into :x, :y;
While (FOUND) loop
--do something
FETCH NEXT FROM rs into :x, :y;
END LOOP
CLOSE rs;

It complains about an error near FETCH?

Responses

  • Re: Cursors at 2003-08-24 16:45:07 from Stephan Szabo

Browse pgsql-novice by date

  From Date Subject
Next Message Stephan Szabo 2003-08-24 16:37:56 Re: Porting from MSSQL Server
Previous Message Hans Jorgensen 2003-08-24 10:13:05 Porting from MSSQL Server