Re: Operations widh CURSORS - Mailing list pgsql-general

From Tom Lane
Subject Re: Operations widh CURSORS
Date
Msg-id 15212.959961270@sss.pgh.pa.us
Whole thread Raw
In response to Operations widh CURSORS  (Marcos Barreto de Castro <mbdecastro@yahoo.com>)
List pgsql-general
Marcos Barreto de Castro <mbdecastro@yahoo.com> writes:
>   I am issuing a "BEGIN WORK" statement, after that I
> am issuing "DECLARE c_cursor FOR SELECT * FROM table".
> When, after that, I issue "DECLARE c_cursor1 FOR
> SELECT COUNT(*) FROM table" I get a segmentation
> fault.

Seems to work fine for me ... what version are you using?

            regards, tom lane


regression=# create table foo(f1 int);
CREATE
regression=# insert into foo values(1);
INSERT 277673 1
regression=# insert into foo values(2);
INSERT 277674 1
regression=# insert into foo values(3);
INSERT 277675 1
regression=# insert into foo values(4);
INSERT 277676 1
regression=# begin;
BEGIN
regression=# DECLARE c_cursor CURSOR FOR SELECT * FROM foo;
SELECT
regression=# DECLARE c_cursor1 CURSOR FOR SELECT count(*) FROM foo;
SELECT
regression=# fetch 1 from c_cursor;
 f1
----
  1
(1 row)

regression=# fetch 1 from c_cursor1;
 count
-------
     4
(1 row)

regression=# fetch 1 from c_cursor;
 f1
----
  2
(1 row)

regression=# fetch 1 from c_cursor;
 f1
----
  3
(1 row)

regression=# fetch 1 from c_cursor;
 f1
----
  4
(1 row)

regression=# fetch 1 from c_cursor1;
 count
-------
(0 rows)

regression=# fetch 1 from c_cursor;
 f1
----
(0 rows)

regression=# end;
COMMIT

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: query optimiser changes 6.5->7.0
Next
From: Richard Moon
Date:
Subject: Anybody got Postgress Binaries working on NT ?