From: | Thomas(dot)K(dot)Hill at t-online(dot)de (Thomas Hill) |
---|---|
To: | |
Subject: | [Pljava-dev] stuck with procedures having out parameters |
Date: | 2012-10-23 21:00:12 |
Message-ID: | 5087055C.3000304@t-online.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pljava-dev |
Hi,
coming from Apache Derby and having implemented some stored procedures
using Java code there I am currently looking at plJava.
I successfully ported/re-used a method not taking any parameter and only
returning a String in PostgreSQ, i.e. the following works as expected:
public static String CURRENT_CLIENTID() throws SQLException {
String vcFKClientID = "000";
return vcFKClientID;
}
CREATE OR REPLACE FUNCTION rte."CURRENT_CLIENTID"()
RETURNS character varying AS
'onlyPostgreSQLPk.Functions.CURRENT_CLIENTID'
LANGUAGE java VOLATILE SECURITY DEFINER
COST 100;
ALTER FUNCTION rte."CURRENT_CLIENTID"()
OWNER TO postgres;
=> select rte."CURRENT_CLIENTID"() returns '000'
However I am not able to figure out why I am getting error message
"Unable to find static method allDatabasesPk.Procedures.SP_getNextID
with signature (Ljava/lang/String;)I" when doing the following:
(exactely the same Java code which works fine in my Apache Derby
environment)
public static void SP_getNextID(int iNextVal[], String vcIDName)
throws SQLException {
Connection conn = getDefaultConnection();
Statement stmt = conn.createStatement(ResultSet.TYPE_FORWARD_ONLY,
ResultSet.CONCUR_UPDATABLE);
String cSQL = "SELECT \"LastValue\" \n" + "FROM rte.\"TBL_IDs\" \n"
+ "WHERE \"IDName\" = '" + vcIDName + "'\n";
ResultSet rs = stmt.executeQuery(cSQL);
while (rs.next()) {
iNextVal[0] = rs.getInt(1) + 1;
rs.updateInt("LastValue", iNextVal[0]);
rs.updateRow();
}
rs.close();
stmt.close();
return;
}
CREATE OR REPLACE FUNCTION rte."SP_getNextID"(OUT "iNextID" integer, IN
"vcIDName" character varying)
RETURNS integer AS
'allDatabasesPk.Procedures.SP_getNextID'
LANGUAGE java VOLATILE SECURITY DEFINER
COST 100;
ALTER FUNCTION rte."SP_getNextID"(character varying)
OWNER TO postgres;
Can someone please point me in the right direction. I have consulted the
user guide and searched the internet but didn't actually find an example
showing the use of OUT parameters or a combination of IN and OUT parameters.
Thanks a lot in advance
Thomas
From | Date | Subject | |
---|---|---|---|
Next Message | Hal Hildebrand | 2012-10-23 21:30:26 | [Pljava-dev] stuck with procedures having out parameters |
Previous Message | Hal Hildebrand | 2012-10-23 14:16:44 | [Pljava-dev] help :pljava sqlj.install_jar('path', 'jarname', true) running infinitely |