Re: Cursor Issue?? - Mailing list pgsql-general

From DracKewl
Subject Re: Cursor Issue??
Date
Msg-id 1122991109.837662.306080@g44g2000cwa.googlegroups.com
Whole thread Raw
In response to Re: Cursor Issue??  (Roman Neuhauser <neuhauser@sigpipe.cz>)
List pgsql-general
Hey Roman,

Thanks for your reponse's!

I made it happen in MicrosoftSQL using the first code below.  The only
difference is I had to create variables.  Which I'm having a hard time
trying to replicate it in psql.

__________Microsoft Code___________
USE test
GO
DECLARE @qty INT, @Length varchar(20), @Width varchar(40)
DECLARE cursor1 SCROLL CURSOR FOR
SELECT * from Parts
OPEN cursor1
  FETCH FIRST FROM cursor1
  INTO @qty, @Length, @Width
  INSERT INTO PartsTemp (qty, Length, Width)
    VALUES (@qty, @Length, @Width)
CLOSE cursor1
DEALLOCATE cursor1
GO


__________psql Code___________
(These declaration of vaiables don't work)
DECLARE c_qty INT;
DECLARE c_Length FLOAT;
DECLARE c_Width FLOAT;

BEGIN;
DECLARE cursor1 CURSOR FOR SELECT * FROM Parts;
FETCH FIRST FROM cursor1 INTO c_qty, c_Length, c_Width;
INSERT INTO partstemp VALUES (c_qty, c_Length, c_Width);
CLOSE cursor1;
COMMIT;

Got any ideas using variable to transfer singular rows?


pgsql-general by date:

Previous
From: Jon
Date:
Subject: Going beyond sql
Next
From: Chris Travers
Date:
Subject: Re: [pgsql-advocacy] New MySQL to PostgreSQL Migration Guide