0

I have a PreparedStatement and CallableStatement:

String sql = "INSERT INTO parcels (cadastr,the_geom,status_id) VALUES(?,PolygonFromText(?, 4326),?)";
PreparedStatement stmt = ce.prepareStatement(sql);
stmt.setString(1, ts.getPackage().getSpecifyParcels().getExistParcel()
        .get(0).getCadastralNumber());
stmt.setString(2, WKT);
// stmt.setString(3, deleted);
stmt.setInt(3, status_id);
stmt.execute();
stmt.close();

java.sql.CallableStatement proc1 = ce
        .prepareCall("{call insert_into_wgs()}");
proc1.execute();
proc1.close();

Its possible to execute this query and function insert_into_wgs() in one statement?

1 Answer 1

1

Use the RETURNING keyword!

INSERT INTO parcels (cadastr,the_geom,status_id) 
VALUES (?, PolygonFromText(?, 4326), ?)
RETURNING insert_into_wgs()
Sign up to request clarification or add additional context in comments.

5 Comments

Thank for answer. But unfortunately insert_into_wgs() works with results of INSERT query(
Why you use SELECT instead VALUES?
Replaced my previous answer with a real solution
Because I copied it from rs.'s solution ;) His post is already deleted btw. Fixed.
So i gonna use this: INSERT INTO parcels (cadastr,the_geom,status_id) VALUES( ?,PolygonFromText(?, 4326),? )RETURNING insert_into_wgs() ????

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.