Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WSLYW-00028d-Ik for pgsql-jdbc@arkaria.postgresql.org; Tue, 25 Mar 2014 07:13:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WSLYW-0002Fv-3G for pgsql-jdbc@arkaria.postgresql.org; Tue, 25 Mar 2014 07:13:52 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WSLYV-0002Fp-Eb for pgsql-jdbc@postgresql.org; Tue, 25 Mar 2014 07:13:51 +0000 Received: from sam.nabble.com ([216.139.236.26]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WSLYN-0008Qb-Ej for pgsql-jdbc@postgresql.org; Tue, 25 Mar 2014 07:13:50 +0000 Received: from [192.168.236.26] (helo=sam.nabble.com) by sam.nabble.com with esmtp (Exim 4.72) (envelope-from ) id 1WSLYN-0007tf-6E for pgsql-jdbc@postgresql.org; Tue, 25 Mar 2014 00:13:43 -0700 Date: Tue, 25 Mar 2014 00:13:43 -0700 (PDT) From: David Johnston To: pgsql-jdbc@postgresql.org Message-ID: <1395731623187-5797359.post@n5.nabble.com> In-Reply-To: <1395731183295-5797356.post@n5.nabble.com> References: <71a63038-181d-46ea-9af6-4231d8c279a4@o15g2000vbe.googlegroups.com> <132b310f-65ae-494f-a2bb-e314c1b6c7c5@n12g2000yqh.googlegroups.com> <26b8239e-b98b-4edf-ad07-28dd9063ddd7@m37g2000yqc.googlegroups.com> <1395728007716-5797354.post@n5.nabble.com> <1395731183295-5797356.post@n5.nabble.com> Subject: Re: Prepared statement with function as argument: how to bind values? MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: 4.5 (++++) 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 David Johnston wrote > > Sivakumar wrote >> I think it's too late to respond for this issue, but i hope it will be >> useful for someone else. I also faced the same issue of binding, how i >> solved is >> >> >> String sql = "INSERT INTO >> poi(geom,latitude,longitude,description,comment) VALUES >> ( * >> ST_GeomFromText(?, 4326) * >> , ?, ?, ?, ?)"; >> stmt = conn.prepareStatement(sql); * >> stmt.setString(1, "POINT(" +lon + " " + lat + ")"); * >> stmt.setFloat(2, lon); >> stmt.setFloat(3, lat); >> stmt.setTimestamp(4, descr); >> stmt.setString(5, comment); >> >> Thanks, >> Sivakumar > Doesn't seem that much an improvement over dynamic SQL. > > INSERT INTO ... > SELECT func_outer(func_inner(val1, val2), 4326), val3 > FROM (VALUES (?,?,?)) src (val1,val2,val3); > > David J. I take the editorializing back... Reading again since the call is expecting a text for the geom then concatenating together a string seems like a necessary requirement of the solution. That said the use of select and values together is something that can be useful. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/Prepared-statement-with-function-as-argument-how-to-bind-values-tp4833351p5797359.html Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com. -- Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-jdbc