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?

asked Feb 16, 2022 at 13:55

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)
answered Feb 16, 2022 at 17:40

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.