Alarm notification pipeline Calculated Roster, referencing tag within

I’m running a SQL query inside of a Calculated alarm notification roster and I have everything working properly EXCEPT I can only get it to work if I use an actual integer where “udt parameter here” is specified below.

data = system.db.runQuery("SELECT column_a FROM table_1 WHERE column_b = 3 AND column_c = *udt parameter here*", "DB")

     for row in data:
		    builder.email([row["column_a"]]).add()
		 
		# use the builder object's build() function to create the finished list of data
		userList = builder.build()
		return userList

I’ve tried doing a read block:

faultqv = system.tag.read("[.]/LINES/PARAMS/LINES NUMBER")
	fault = faultqv.value

Making the code:

data = system.db.runQuery("SELECT column_a FROM table_1 WHERE column_b = 3 AND column_c = 'fault' ", "DB")

     for row in data:
		    builder.email([row["column_a"]]).add()
		 
		# use the builder object's build() function to create the finished list of data
		userList = builder.build()
		return userList

But that didn’t appear to work properly either.

What can I do to reference the tag value within the “runQuery”? I’m using 8.0.12

As long as you’re pushing in an integer value into the query string, you should be able to use python’s string interpolation. As an example, using your query, it would look like:

fault = system.tag.readBlocking(["[.]/LINES/PARAMS/LINES NUMBER"])[0].value

query = "SELECT column_a FROM table_1 WHERE column_b = 3 AND column_c = %d" % (fault)
data = system.db.runQuery(query, "DB")

for row in data:
	builder.email([row["column_a"]]).add()
		 
	# use the builder object's build() function to create the finished list of data
	userList = builder.build()
	return userList

(Note: I just assigned the string to the query variable to make it easier to read, you could just put it straight into the .runQuery())