Re: handling refcursors

From: Stuart Robinson <stuart(at)zapata(dot)org>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: handling refcursors
Date: 2002-07-02 08:15:40
Message-ID: Pine.LNX.4.44.0207020114470.25929-100000@www.dreamingamerica.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)zapata(dot)org]
688 Hampshire Street
San Francisco, CA 94110
USA

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message Stuart Robinson 2002-07-02 08:38:26 not able to fetch from refcursor
Previous Message tony 2002-07-02 08:06:02 Re: upgraded from 7.1.3 to 7.2.4 and can't get JDBC to work