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

211
Views
Get result after an update query

I am making the following query which works and updates the info into the database as expected. But is there a way I can get an output from Single < UpdateResult >?

public Single<UpdateResult> update(UpdateEventRequest request) {
    return client.rxUpdateWithParams(
            "UPDATE mydb.sample SET sta_cd=?, some_ts=current_timestamp WHERE id=? RETURNING sta_cd",
            new JsonArray(Arrays.asList(sta_cd, id)));
}

From the following e variable, I was hoping to get the value "10012". But it doesn't seem possible. Tried with map, flatmap and just see options available in e. The only result data in e is 'keys' which is an empty list and 'updated' which is an integer value of 1. My DB is postgres and was expecting results from from Single < UpdateResult > since am using 'RETURNING' in the query.

I have done the same for an insert operation which works but that is via the method rxQueryWithParams() and that returns a Single < ResultSet > instead. Thus wondering if this is even possible. Been having a look at docs and maybe this is not possible as an update query is returning a Single < UpdateResult > . Looking for advice if this is possible, to return data from an update query or a way around this. Please advice. Thanks.

    Single<UpdateResult> result = someClass.update("10012", "78632");

    result.subscribe(
            e -> {
                System.out.println("success: " + e); // I land here as expected
            },
            error -> {
                System.out.println("error: " + error);
            }
    );
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Because you are using RETURNING in these commands, treat these INSERT and UPDATE commands as queries.

Run them through rxQueryWithParams() so you can retrieve the results.

When you run rxUpdateWithParams(), the UpdateResult contains only the number of rows affected.

over 4 years ago · Santiago Trujillo Report
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!