Inserting a tag value into a scripted SQL query

Hello,
I am trying to add a tag value into a scripted SQL query that will work if I use a test string, SO IM CLOSE! Help me out here it is almost done.

jobnum = system.tag.read("{[PanelShop]JobNumSelect}").value
 
query = "INSERT INTO Notes (note, whoid, tstamp, attachment, filename, sticky, JobNum) VALUES (?, ?, CURRENT_TIMESTAMP, CONVERT(VARBINARY(MAX),?), ?, ?, ?)"
 
arguments = [note, user, attachmentBytes, filename, sticky, jobnum]
system.db.runPrepUpdate(query, arguments)

If I replace the “system.tag.read(”{[PanelShop]JobNumSelect}").value" with ‘test’ it works. So I am not reading into the variable the tag value correctly. I have tried this:

arguments = [note, user, attachmentBytes, filename, sticky, str(jobnum)]

type of thing to make sure its a string that gets passed but that does not seem to be the issue.

Try it without the braces. They’re not used in scripting. :wink:

jobnum = system.tag.read("[PanelShop]JobNumSelect").value
2 Likes

wow, thanks for that, easy fix. FIXED

1 Like