Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

215
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda