Re: handling refcursors - Mailing list pgsql-jdbc

From Stuart Robinson
Subject Re: handling refcursors
Date
Msg-id Pine.LNX.4.44.0207020114470.25929-100000@www.dreamingamerica.com
Whole thread Raw
In response to handling refcursors  (Stuart Robinson <stuart@zapata.org>)
Responses not able to fetch from refcursor
List pgsql-jdbc
I think I figured out what the problem is.

I wasn't not putting cursorName in quotes, like so:

rs = ps.executeQuery("fetch all from \"" + cursorName + "\"");

Thanks anyhow.

Regards,
Stuart

On Tue, 2 Jul 2002, Stuart
Robinson wrote:

> I'm trying to use a function that returns a refcursor in a web
> application.
>
> I followed the example code I found at this URL (as suggested on this
> mailing list):
>
> http://fts.postgresql.org/db/mw/msg.html?mid=1354157.
>
> I wound up writing this code inside of my base factory class:
>
> System.out.println("-- SQL: " + stmt);
> ps = con.prepareStatement(stmt);
> ps = bindSelectStmt(ps, obj, selectCase);
> ResultSet rs = ps.executeQuery();
> rs.next();
> String cursorName = rs.getString(1);
> System.out.println("-- CURSOR NAME: " + cursorName);
> rs = ps.executeQuery("fetch all from " + cursorName);
>
> But when I try running that, I get the following output from
> Tomcat:
>
> -- SQL: SELECT get_examples_by_entry_id(?)
> -- CURSOR NAME: <unnamed cursor 1>
> java.sql.SQLException: ERROR:  parser: parse error at or near "<"
>
> I believe the exception is caused by the cursor name, which I know from
> the system-out to be:
>
> <unnamed cursor 1>
>
> Any ideas as to what's going on here?
>
> Thanks in advance.
>
> Regards,
> Stuart
>
>

--
Stuart P. Robinson [stuart@zapata.org]
688 Hampshire Street
San Francisco, CA 94110
USA




pgsql-jdbc by date:

Previous
From: Stuart Robinson
Date:
Subject: handling refcursors
Next
From: Stuart Robinson
Date:
Subject: not able to fetch from refcursor