Re: Cursor Issue??

From: "DracKewl" <bradbudge(at)hotmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Cursor Issue??
Date: 2005-08-02 13:58:29
Message-ID: 1122991109.837662.306080@g44g2000cwa.googlegroups.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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?

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Peter Wilson 2005-08-02 14:05:19 Re: feeding big script to psql
Previous Message Magnus Hagander 2005-08-02 13:55:21 Re: unicode error on win32 Was: Re: pgmonitor