SQL Server - Fixing Remote Edit Button

SQL Server - Fixing Remote Edit Button

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

 

More Detailed Procedure:

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

    • Related Articles

    • SQL Server - Testing database connections

      One of the past challenges with troubleshooting SQL database connections has been with having a tool to connect to the SQL database - determining if the port is available on the target server and the service is running. Starting in Windows 10, this ...
    • SQL Server - Mass Disabling of Remote Comm. Error / Comm. Error

      Sometimes a customer will want to disable all Remote Communication Errors (RCE) and Communication Errors (CE) on the system for a period of time. You can do this through the UI on the Administration tab > Devices tab > Alarm and Notification ...
    • SQL Server - Removing a Black Box (Offline) Device from the Dashboard

      If a device is offline (server can't communicate with it) for more than 15 minutes its icon will turn into a black box with a white question mark inside. If this device is from a Device Gateway that has been improperly decommissioned you can remove ...
    • SQL Server - Manual Device Deletion

      If you need to remove a device from the dashboard and it is not possible to use the Delete button on the Administration > Devices page, you can do it through SQL Management Studio. Marking a Device as Deleted In Management Studio run the following ...
    • SQL Server - Adding Templates to Bulk Upload Menu

      The steps to add a Device Template to the bulk upload menu on OpendataEE are: 1) Move the completed template into the appropriate directory. The default root device template directory is: C:\Program ...