Search Postgresql Archives

Re: Function with RETURN TYPE RECORD Called From JAVA

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm fairly sure that postgres does not support "out" parameters:

	objCallStmt.registerOutParameter(1, 12);

Isn't allowed.

Since you only have one value coming out of the function, you could use
regular Statement or PreparedStatement client-side and rewrite your
server-side function so it returns a value thru RETURNS clause.  I'm making
assumption that you are using PL/pgsql (only language I'm familiar with).

The second is that you probably want to call the executeQuery method on the
Statement/PreparedStatement and walk through the result-set (per jdocs) it
returns.

Carl <|};-)>



-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Sumita Biswas
Sent: Sunday, May 16, 2004 7:10 PM
To: pgsql-general@postgresql.org
Cc: 'Kris Jurka'; 'Tom Lane'; 'Richard Huxton'
Subject:  Function with RETURN TYPE RECORD Called From JAVA


Hi All,

I have a Function that returns a variable of Type RECORD.
PFA the .sql file in which the Function is written.

When I execute this Function from JAVA and try to get the Return Variable in
a ResultSet object I get the following Error:

Exception in thread "main" java.lang.ClassCastException
        at com.cisco.ccm.car.general.Test.testStoredProc(Test.java:119)

Here is the JAVA Code that I am using:

---------------------------------------------------------------
	CARConnector objCARConn = new CARConnector();
	CallableStatement objCallStmt = null;
                
	objCallStmt = objCARConn.prepareCall("{ ? = call
Proc_ConferenceSummary(?,?,?,?,?) }");
	objCallStmt.registerOutParameter(1, 12);
	// '12/1/2003','1/23/2004',1,1,0,5001
	//'3/5/2004','3/5/2004',1,1,5001

	objCallStmt.setString(2,"3/5/2004");
	objCallStmt.setString(3,"5/5/2004");
	//objCallStmt.setString(3,"3/5/2004");
	objCallStmt.setInt(4,1);
	objCallStmt.setInt(5,1);
	objCallStmt.setInt(6,5001);
	objCallStmt.execute();
	ResultSet rs = (ResultSet)objCallStmt.getObject(1);//THIS IS WHERE I
GET THE CLASSCASTEXCEPTION
---------------------------------------------------------------

Please let me know in case I am doing something wrong, or there is a
different way of doing things.

Regards,
Sumita


---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
      joining column's datatypes do not match



---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo@postgresql.org so that your
      message can get through to the mailing list cleanly


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux