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
"draw_items_upsert" is a custom function and as it turns the amendment was required within that function:
CAST('''|| area_updates[i] ||''' AS numeric)