I am developing a mechanism that uploads records to CartoDB - first by importing the records to a new table, and then insert the records from the new table to an existing table.
The problem is that the existing table may already contain some of the records (each record has a unique record_id) - in this case I would like to override the existing values with the values of the new record.
This could be done in two steps, by deleting the existing records (whose record_id is in the new table) and then insert all the records from the new table.
The SQL MERGE command should allow to do that in a single command. Is this command supported by CartoDB? Can you give an example with the exact the syntax? (I am getting a 'Syntax error at or near "MERGE"').
-
This may be for you stackoverflow.com/questions/17267417/…user30184– user301842015年04月20日 15:17:05 +00:00Commented Apr 20, 2015 at 15:17
1 Answer 1
According to this, MERGE is not implemented in PostgreSQL 9.3.4, the version that CartoDB runs on. You can check the version by running SELECT version()
in the SQL editor in your account.
-
Atomicity is not so important in my case, so I solved it by doing two commands, following: stackoverflow.com/questions/17267417/… (even without the lock).Oren– Oren2015年04月21日 01:24:34 +00:00Commented Apr 21, 2015 at 1:24