1

I have a Carto database with column "area" where data type is "number" or numeric.

The following SQL query is to select certain rows (cartodb_ids) and update the geometry (geojsons) and area (area_updates) values of these rows

var sql2 = "SELECT draw_items_upsert(ARRAY[";
      sql2 += cartodb_ids.join(",");
      sql2 += "],ARRAY[";
      sql2 += geojsons.join(",");
      sql2 += "],"
      sql2 += "ARRAY[";
      sql2 += area_updates.join(",");
      sql2 += "]);";

However it produces the following console error :

“error [ "column "area" is of type double precision but expression is of type text" ] hint: You will need to rewrite or cast the expression.”

I’ve tried using CAST(area_updates.join AS numeric); with no success

Is it possible to use “::numeric” if so where does it fit into the query?

1 Answer 1

1

"draw_items_upsert" is a custom function and as it turns the amendment was required within that function:

 CAST('''|| area_updates[i] ||''' AS numeric)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.