# IA Scripting: Error adding SQLTags to configuration store

**URL:** <https://forum.inductiveautomation.com/t/ia-scripting-error-adding-sqltags-to-configuration-store/8261>\
**Category:** Ignition\
**Created:** [April 3, 2014, 6:28pm UTC](https://forum.inductiveautomation.com/t/ia-scripting-error-adding-sqltags-to-configuration-store/8261 "2014-04-03T18:28:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [April 3, 2014, 6:28pm UTC](https://forum.inductiveautomation.com/t/ia-scripting-error-adding-sqltags-to-configuration-store/8261/1 "2014-04-03T18:28:12Z")

</div>

I ran into a problem where the tag exists (or not) in my SQLTag structure but the tag.exists is not (or is) seeing the tag. Is there a chance the internal database got corrupted before the SQLTag was completely created?

When I first ran this code (see below), an SQL Query timed out on me while I was trying to monitor the database tables. The tags were not created yet, but I was still getting the same error. I imported the tags in from a test project but it is still generating the same error.

The console is generating the following error:

> [@](#):
>
> [ERROR] 1:06:10 PM Provider[default] Error adding SQLTags to configuration store.
> 
> java.lang.IllegalArgumentException: Tag name collision. Tag with name 'AlarmState' already exists in 'folder "01044651SKYCD94eio1Value"'  
> at com.inductiveautomation.ignition.gateway.sqltags.providers.AbstractStoreBasedTagProvider$AddTagsTask.processNodes(AbstractStoreBasedTagProvider.java:961)  
> at com.inductiveautomation.ignition.gateway.sqltags.providers.AbstractStoreBasedTagProvider$AddTagsTask.run(AbstractStoreBasedTagProvider.java:904)  
> at com.inductiveautomation.ignition.gateway.sqltags.providers.AbstractStoreBasedTagProvider.runInConfigLock(AbstractStoreBasedTagProvider.java:1391)  
> at com.inductiveautomation.ignition.gateway.sqltags.providers.AbstractStoreBasedTagProvider.addTags(AbstractStoreBasedTagProvider.java:650)  
> at com.inductiveautomation.ignition.gateway.sqltags.providers.RedundantProviderWrapper.\_addTags(RedundantProviderWrapper.java:64)  
> at sun.reflect.GeneratedMethodAccessor483.invoke(Unknown Source)  
> at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)  
> at java.lang.reflect.Method.invoke(Unknown Source)  
> ...

Gateway Timer script:

```auto
...
	#AlarmState tag
	sTag = "AlarmState"
	sTagPath = sParentPath + "/" + sTag
	if not system.tag.exists(sTagPath):
		system.tag.addTag(parentPath=sParentPath, name=sTag, tagType="DB", dataType="Boolean")
		system.tag.write(sTagPath, 0)
...
```

Ignition Platform 7.5.11 (b1526)  
SQL Bridge Module 5.5.5 (b289) Activated  
Vision Module 6.5.11 (b928) Activated  
IA Labs Scripting Module 1.5.0 (b8) Free  
Mobile Module 1.5.6 (b239) Trial  
ActiveX Module 2.5.0 (b198) Free  
Symbol Factory Module 2.6.0 (b46) Trial  
Reporting Module 1.5.3 (b229) Activated

---

<div class="post-metadata">

**Author:** ![adamaustin](https://avatars.discourse-cdn.com/v4/letter/a/5f8ce5/32.png) [@adamaustin](https://forum.inductiveautomation.com/u/adamaustin)\
**Post date:** [April 14, 2014, 5:51pm UTC](https://forum.inductiveautomation.com/t/ia-scripting-error-adding-sqltags-to-configuration-store/8261/2 "2014-04-14T17:51:13Z")

</div>

With Greg Simpson’s help, we narrowed this down to the fact that we needed to prefix the tag path and folder name with the specific SQLTag provider when checking to see if the tag exists and also when creating the new tags with addTag:

```auto
...
   sParentPath = "[MySQLTagProvider]" + sParentPath

   #AlarmState tag
   sTag = "AlarmState"
   sTagPath = sParentPath + "/" + sTag
   if not system.tag.exists(sTagPath):
      system.tag.addTag(parentPath=sParentPath, name=sTag, tagType="DB", dataType="Boolean")
      system.tag.write(sTagPath, 0)
...
```

Thanks, Greg!
