If the Remote Edit button sends you to an error page or the wrong Device Gateway here is how to fix it.
Run the following query to generate a complete picture of the tables used to generate the remote edit URLs.
select d.name,d.device_id, ns.name_space_id,t.tag_id,t.label
from eg.device d,
eg.name_space ns,
eg.tag t
where d.device_id = ns.obj_id and
ns.name_space_id = t.name_space_id
You have two choices depending on the objective:
1) If you want to use the existing eg.name_space and eg.tag records from the deleted devices to fix the 404 errors, run the following two queries replacing the obj_id's with the appropriate obj_id's for the devices you are dealing with.
update eg.name_space set obj_id=81094701 where obj_id = 1398
update eg.name_space set obj_id=81094714 where obj_id = 1610
2)The following queries will prevent Remote Edit URLs from being generated for the deleted devices, but will not fix the 404 errors:
delete from eg.tag where name_space_id = 1401
delete from eg.name_space where name_space_id = 1401
1) Start SQL Management Studio and connect to the database containing the erroneous data.
2) Run query:
select * from eg.tag order by name_space_id
3) Examine returned rows for duplicate name_space_id entries. Every occurrence of duplicates is a problem instance.
4) For each problem instance:
a) Note that the duplicate rows will each have a unique tag_id. Identify the smaller tag_id of the duplicates.
b) Run the query:
delete from eg.tag where tag_id = <smaller of the two tag_ids>
c) Triggers initiated by this deletion will cause the deletion of one row in the following tables: EG.TAG, EG.CONT_ADDR, EG.OBJ.
d) Note that a row may be deleted from EG.AUDIT as well. No worries if that doesn't happen.
e) Identify the obj_id for an update by running the following query:
select * from eg.name_space where name_space_id = <the name_space_id of the remaining row in the eg.tag table>
f) Update eg.name_space with correct values for Name and Descr by running the following query:
update eg.name_space set name = (select name from eg.device where device_id = <obj_id from step E above>),
descr = (select descr from eg.device where device_id = <obj_id from step E above>)
where obj_id = <obj_id from step E above>
G) Update eg.name_space with the correct value for obj_id by running the following query:
update eg.name_space set obj_id = <obj_id from step E above>
where name_space_id = <the name_space_id from the remaining row in the eg.tag table from step E above>
Fixed a Remote Edit at Navteq by below
--select * from eg.tag order by tag_id
--select * from eg.device order by name
--19233692 19233691 DEVICE_205 Leon - UPS 80 kVA UPS in Leon, MX NULL NULL 1 1 60000
--19231573 19231572 DEVICE_205_1260898791720 Powerware 9390 UPS (Deleted)1260898791720 80 kVA UPS NULL NULL 1 1 60000
--update eg.name_space set obj_id=19233692 where obj_id=19231573