agora inbox for pljava-dev@postgresql.org  
help / color / mirror / Atom feed
Subject: [Pljava-dev] stuck with procedures having out parameters
Date: Tue, 23 Oct 2012 23:00:12 +0200
Message-ID: <5087055C.3000304@t-online.de> (raw)

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





view thread (4+ messages)  latest in thread

Message-ID: <5087055C.3000304@t-online.de>
Permalink:  ../5087055C.3000304@t-online.de/
Also on:    postgresql.org/message-id/5087055C.3000304@t-online.de

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pljava-dev@postgresql.org
  Subject: Re: [Pljava-dev] stuck with procedures having out parameters
  In-Reply-To: <5087055C.3000304@t-online.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox