Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1ZLcLy-0001bm-6H for pgsql-jdbc@arkaria.postgresql.org; Sat, 01 Aug 2015 19:21:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84) (envelope-from ) id 1ZLcLx-00045B-AA for pgsql-jdbc@arkaria.postgresql.org; Sat, 01 Aug 2015 19:21:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZLcLv-000452-Sl for pgsql-jdbc@postgresql.org; Sat, 01 Aug 2015 19:21:51 +0000 Received: from rad0.itstriangle.com ([199.38.107.90]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84) (envelope-from ) id 1ZLcLr-0003jo-2V for pgsql-jdbc@postgresql.org; Sat, 01 Aug 2015 19:21:49 +0000 Received: from itstriangle.com (localhost [127.0.0.1]) by rad0.itstriangle.com (8.14.4/8.14.4) with ESMTP id t71JLbdl020298; Sat, 1 Aug 2015 15:21:38 -0400 Received: FROM [192.168.157.52] ([216.220.4.222]) BY itstriangle.com WITH ESMTP ; Sat, 1 Aug 2015 15:21:36 -0400 Message-ID: <55BD1F39.6090103@ttc-cmc.net> Date: Sat, 01 Aug 2015 13:34:17 -0600 From: dmp User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Firefox/24.0 SeaMonkey/2.21 MIME-Version: 1.0 To: Alex Wang , PostgreSQL JDBC Subject: Re: Re: need advice about out parameter settings while calling stored procedure in Java code References: <91b75bc23fbe41adba69c52ed4c2213f@shmbx01.ebaotech.com> <9d8eb7ea086c4bb7afd4408da5dfde74@shmbx01.ebaotech.com> <8cb5377a03194a98a1ce405ca75beb85@shmbx01.ebaotech.com> In-Reply-To: <8cb5377a03194a98a1ce405ca75beb85@shmbx01.ebaotech.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-jdbc Precedence: bulk Sender: pgsql-jdbc-owner@postgresql.org Alex Wang wrote: > Hi Vladimir/Dave, > > Thanks for your kind reply. I am migrating a huge platform from Oracle (11g) to > Postgresql (Postgres Plus Advanced Server 9.3.1.3). Here are the details about > the issue I encountered for your reference which I hope they are clear enough > for your analysis. > > I have a stored procedure inside a package (/myPackage)/ whose SQL snippet is: > > /PROCEDURE p_myprocedure(a character varying, b character varying, c character > varying, d character varying, OUT o1 text, OUT o2 text) IS/ > > ~ > ~ > ~ > > Thanks & regards, > Alex Hello Alex, I'm not sure and as John indicated that this report and fix is required in this forum. The code example provided below works fine when used directly with a 9.4.1 server installation and 9.4-1200.jdbc4. This was just recently demostrated in this forum for meta data on CallableStatements. The only difference is the FUNCTION rather then your PROCEDURE definition/ call. danap. Complete Workable Code Sample Method. public void test(Connection connection) { // Method Instances String sqlStatementString; Statement sqlStatement; CallableStatement cstmt; try { sqlStatement = connection.createStatement(); sqlStatementString = "CREATE OR REPLACE FUNCTION sum_n_product(x int, y int, OUT sum int, OUT prod int) AS $$" + " SELECT (x + y) AS sum, (x * y) AS prod; $$ LANGUAGE SQL;"; System.out.println(sqlStatement); sqlStatement.execute(sqlStatementString); // Execute Function. cstmt = connection.prepareCall("{call sum_n_product(?,?,?,?)}"); cstmt.registerOutParameter(3, Types.INTEGER); cstmt.registerOutParameter(4, Types.INTEGER); cstmt.setInt(1, 2); cstmt.setInt(2, 5); cstmt.execute(); int x1 = cstmt.getInt(3); int x2 = cstmt.getInt(4); System.out.println("x1: " + x1); System.out.println("x2: " + x2); // Drop Function. sqlStatementString = "DROP FUNCTION sum_n_product(int, int, OUT int, OUT int);"; System.out.println(sqlStatementString); sqlStatement.execute(sqlStatementString); cstmt.close(); sqlStatement.close(); } catch (SQLException sqle) { System.out.println("SQL Exeception" + sqle); } } -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc