Re: retun cursor

From: "Madhavi Daroor" <madhavi(at)zoniac(dot)com>
To: "Stephan Szabo" <sszabo(at)megazone23(dot)bigpanda(dot)com>
Cc: <pgsql-general(at)PostgreSQL(dot)org>
Subject: Re: retun cursor
Date: 2000-04-08 16:05:35
Message-ID: NGBBLNBOJKEIJANJIDBNCEAFCAAA.madhavi@zoniac.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
This is what I got when I executed the statements outside the
BEGIN......END block
psqldb=# select f();
f
--------------------
<unnamed cursor 2>
(1 row)

psqldb=# fetch all from "<unnamed cursor 2>";
NOTICE: PerformPortalFetch: portal "<unnamed cursor 2>" not found
FETCH

What does the above statement mean? How do I call the function in Java? Is
there no way i could directly call the function in java.

Thanx,
Madhavi Daroor

-----Original Message-----
From: Stephan Szabo [mailto:sszabo(at)megazone23(dot)bigpanda(dot)com]
Sent: Monday, April 08, 2002 11:01 AM
To: Madhavi Daroor
Cc: pgsql-general(at)PostgreSQL(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Madhavi Daroor 2000-04-08 16:26:15 Re: retun cursor
Previous Message Jigishu P Bhatt 2000-04-08 15:49:38 Problem of CREATE LANGUAGE