Update changed rows

This commit is contained in:
Rafa de la Torre 2019-05-27 11:54:38 +02:00
parent 982ddfdeff
commit a8d57abda6

View File

@ -76,6 +76,8 @@ DECLARE
src_hash_table_name NAME; src_hash_table_name NAME;
dst_hash_table_name NAME; dst_hash_table_name NAME;
update_set_clause TEXT;
num_rows BIGINT; num_rows BIGINT;
err_context text; err_context text;
BEGIN BEGIN
@ -126,27 +128,21 @@ BEGIN
RAISE NOTICE 'INSERTED % row(s)', num_rows; RAISE NOTICE 'INSERTED % row(s)', num_rows;
-- Deal with modified rows: ids in source and dest but different hashes -- Deal with modified rows: ids in source and dest but different hashes
/* update_set_clause := __CDB_GetUpdateSetClause(colnames, 'changed');
UPDATE syncdes dst SET EXECUTE format('
the_geom = changed.the_geom, UPDATE %1$s dst SET %2$s
the_geom_webmercator = changed.the_geom_webmercator,
id = changed.id,
elevation = changed.elevation,
latitude = changed.latitude,
longitude = changed.longitude,
name = changed.name
FROM ( FROM (
SELECT cartodb_id,the_geom,the_geom_webmercator,id,elevation,latitude,longitude,name SELECT cartodb_id,%3$s
FROM radar_stations src FROM %4$s src
WHERE cartodb_id IN WHERE cartodb_id IN
(SELECT sh.cartodb_id FROM src_sync_615543 sh (SELECT sh.cartodb_id FROM %5$I sh
LEFT JOIN dst_sync_615543 dh ON sh.cartodb_id = dh.cartodb_id LEFT JOIN %6$I dh ON sh.cartodb_id = dh.cartodb_id
WHERE sh.hash <> dh.hash) WHERE sh.hash <> dh.hash)
) changed ) changed
WHERE dst.cartodb_id = changed.cartodb_id; WHERE dst.cartodb_id = changed.cartodb_id;
*/ ', fq_dest_table, update_set_clause, quoted_colnames, src_table, src_hash_table_name, dst_hash_table_name);
--GET DIAGNOSTICS num_rows = ROW_COUNT; GET DIAGNOSTICS num_rows = ROW_COUNT;
--RAISE NOTICE 'MODIFIED % row(s)', num_rows; RAISE NOTICE 'MODIFIED % row(s)', num_rows;
-- Cleanup -- Cleanup
--EXECUTE format('DROP TABLE IF EXISTS %I', src_hash_table_name); --EXECUTE format('DROP TABLE IF EXISTS %I', src_hash_table_name);