Re: Prepared statement with function as argument: how to bind values? - Mailing list pgsql-jdbc

From David Johnston
Subject Re: Prepared statement with function as argument: how to bind values?
Date
Msg-id 1395731183295-5797356.post@n5.nabble.com
Whole thread Raw
In response to Prepared statement with function as argument: how to bind values?  (alexbruy <alexander.bruy@gmail.com>)
Responses Re: Prepared statement with function as argument: how to bind values?
List pgsql-jdbc
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.








--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Prepared-statement-with-function-as-argument-how-to-bind-values-tp4833351p5797356.html
Sent from the PostgreSQL - jdbc mailing list archive at Nabble.com.


pgsql-jdbc by date:

Previous
From: Michael Paquier
Date:
Subject: Postgres jdbc build broken with plain ant since e7c2c93
Next
From: David Johnston
Date:
Subject: Re: Prepared statement with function as argument: how to bind values?