Re: Stored Procedure returns a ResultSet

From: "sc0698" <sc0698(at)sina(dot)com>
To: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: Stored Procedure returns a ResultSet
Date: 2003-09-18 03:38:44
Message-ID: bkb9cb$26s3$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

Now the 7.4 pgsql and jdbc driver are beta version, they should have some
problems!
So I need a stable driver!

I want to use the 7.3.4 pgsql and pg73jdbc3.jar!

You say they support CallableStatement, but I can't get the right result!

the java program:

conn.setAutoCommit(false);

cstmt = conn.prepareCall(m_query);

cstmt.registerOutParameter(1, Types.OTHER);
cstmt.execute();

ResultSet resultSet = (ResultSet)cstmt.getObject(1);

the Function return refcursor:

CREATE OR REPLACE FUNCTION Fuc_test4Query()
RETURNS refcursor AS '
DECLARE
r_Result refcursor;
BEGIN
r_QuerySQL := ''select ID,Name from Handset '';
OPEN r_Result FOR EXECUTE r_QuerySQL;
return r_Result;
END;
'
language 'plpgsql';

Otherwise, the fuc_test4query1
How to do with java?
thanks!

the Function return setof

CREATE OR REPLACE FUNCTION public.fuc_test4query1()
RETURNS setof test AS
'
DECLARE
r_Result record;
BEGIN
r_QuerySQL := \'select ID,Name from Handset \';
FOR r_Result IN execute r_QuerySQL LOOP

RETURN next r_Result;

END LOOP;

return NULL;
END;
'
LANGUAGE 'plpgsql' VOLATILE;

In response to

Responses

Browse pgsql-jdbc by date

  From Date Subject
Next Message sc0698 2003-09-18 03:41:04 Re: Stored Procedure returns a ResultSet
Previous Message Barry Lind 2003-09-17 23:37:56 Re: Batch Processing - Autocommit