Re: retun cursor

Поиск
Список
Период
Сортировка
От Madhavi Daroor
Тема Re: retun cursor
Дата
Msg-id NGBBLNBOJKEIJANJIDBNKEAFCAAA.madhavi@zoniac.com
обсуждение исходный текст
Ответ на Re: retun cursor  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Ответы Re: retun cursor  (Oliver Elphick <olly@lfix.co.uk>)
Список pgsql-general
Hi,
   I followed the steps that you told me. An it worked fine. But I have one
problem and that is......when I try to fetch all the resords of a table, it
gives me the folowing error

psqldb=# fetch all from "<unnamed cursor 4>";
less: not found

Why does this happen? and after I get this error, if I try to fetch fewer
number or records say 5, then it returns 0 records.

Does this happen because there are large number of records in the cursor?

And please explain to me how I could execute this in java.

Thanx,
Madhavi Daroor

-----Original Message-----
From: Stephan Szabo [mailto:sszabo@megazone23.bigpanda.com]
Sent: Monday, April 08, 2002 11:01 AM
To: Madhavi Daroor
Cc: pgsql-general@PostgreSQL.org
Subject: RE: [GENERAL] retun cursor


On Mon, 8 Apr 2002, Madhavi Daroor wrote:

> When I do fetch 10 from "unnamed cursor 1"
> It says Query Executed Ok. But when am I really going to see the output?
> When Will I see the records? pLease explain the process.....WHat do I
fetch
> the cursor into?

Here's a simple function and a fetch passed in through
psql -e

create table test1(a int);
CREATE
insert into test1 values (1);
INSERT 156460 1
insert into test1 values (2);
INSERT 156461 1
insert into test1 values (3);
INSERT 156462 1
insert into test1 values (4);
INSERT 156463 1
insert into test1 values (5);
INSERT 156464 1
create function testfunc1(int4) returns refcursor as '
declare
 r refcursor;
begin
 open r for select * from test1 where a>=$1;
 return r;
end;'
language 'plpgsql';
CREATE
begin;
BEGIN
select testfunc1(2);
     testfunc1
--------------------
 <unnamed cursor 1>
(1 row)

fetch 1 from "<unnamed cursor 1>";
 a
---
 2
(1 row)

fetch all from "<unnamed cursor 1>";
 a
---
 3
 4
 5
(3 rows)

end;
COMMIT




В списке pgsql-general по дате отправления:

Предыдущее
От: "Madhavi Daroor"
Дата:
Сообщение: Re: retun cursor
Следующее
От: "Papp, Gyozo"
Дата:
Сообщение: SPI_execp() failed in RI_FKey_cascade_del()