Re: Operations widh CURSORS

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Marcos Barreto de Castro <mbdecastro(at)yahoo(dot)com>
Cc: pgsql-general(at)hub(dot)org
Subject: Re: Operations widh CURSORS
Date: 2000-06-02 15:54:30
Message-ID: 15212.959961270@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Marcos Barreto de Castro <mbdecastro(at)yahoo(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message moebius 2000-06-02 16:06:42 recipe database
Previous Message Jeff Hoffmann 2000-06-02 15:53:02 Re: query optimiser changes 6.5->7.0