From: | Richard Emberson <emberson(at)phc(dot)net> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | de-reference a refcursor in JDBC???? |
Date: | 2002-04-11 14:29:31 |
Message-ID: | 3CB59DCB.5A9734E@phc.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Ok, I wanted to wrap a select statement with a PL/pgsql procedure
(information hiding, etc.)
So I have:
CREATE OR REPLACE FUNCTION user_data_select_all(BIGINT)
RETURNS REFCURSOR AS '
DECLARE
-- parameters
owner_id_p ALIAS FOR $1;
-- local variables
rc REFCURSOR;
BEGIN
OPEN rc FOR SELECT *
FROM user_data
WHERE
owner_id = owner_id_p;
RETURN rc;
END;
' LANGUAGE 'plpgsql' WITH (isstrict);
Now from within psql I get the following:
=> select user_data_select_all(12);
user_data_select_all
----------------------
<unnamed cursor 15>
(1 row)
fetch all in <unnamed cursor 15>;
which lists all of the rows.
How to do the same thing in JDBC. In JDBC I get an exception:
Bad Long <unnamed cursor 1>
at org.postgresql.jdbc2.ResultSet.toLong(ResultSet.java:1498)
at org.postgresql.jdbc2.ResultSet.getLong(ResultSet.java:257)
So the question is can I wrap a select function as return a resultset to
JDBC? How do I dereference the refcursor in JDBC??
How do other interfaces do it? Has anyone ever tried this before?
Richard
From | Date | Subject | |
---|---|---|---|
Next Message | noy | 2002-04-11 14:33:01 | Date precision problem |
Previous Message | Andrew Sullivan | 2002-04-11 14:26:41 | Re: Critical performance problems on large databases |