Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

218
Views
Postgresql jdbc executeUpdate() or getUpdateCount() return affected row

JDBC executeUpdate() and getUpdateCount() should return affected row number. Following java code calls a MySql stored procedure and variable "rc" is assigned to "1" which means 1 row was inserted:

CallableStatement stmt = conn.prepareCall("{call insertData(?)}");
stmt.setInt(1, i);
int rc = stmt.executeUpdate(); // returns 1
rc = stmt.getUpdateCount(); // returns 1

the MySql stored procedure called:

CREATE PROCEDURE insertData(IN i INT)
BEGIN
INSERT INTO table_name(column_name) VALUES(i);
END //

Everything works as expected. Now want the similar Java code to work with a PostgreSql function or procedure and make executeUpdate() or getUpdateCount() act the same and return affected row. New row is inserted into Postgresql table but executeUpdate() or getUpdateCount() always return 0.

create procedure insertData(i integer) as $$
begin
INSERT INTO table_name(column_name) VALUES(i);
end; $$ language plpgsql;

How can I make executeUpdate() or getUpdateCount() return affected row when calling a Postgresql function or procedure?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!