I'm trying to use scripting to get the unique values of a tag from a database. In the Database Query Browser this line works and gets the data I want:
SELECT distinct "RecipeName" FROM WaxPressParts
This doesn't work when I try to add it to scripting for a component:
queryBase = "SELECT distinct RecipeName FROM WaxPressParts "
queryClause = "WHERE (CONVERT(varchar(25), t_stamp, 126) >= ? AND CONVERT(varchar(25), t_stamp, 126) < ?)"
queryText = queryBase + queryClause + " ORDER BY t_stamp DESC"
self.props.data = system.db.runPrepQuery(queryText)
This gives a source error. Replacing 'distinct' with 'top 1000' gets rid of errors and returns the top 1000 results so I know that the rest of the script is good and 'distinct' is causing the issue. I've also tried 'unique' instead of 'distinct' and am getting the same issue. Is there a good way to get the unique values from a database while scripting on a component?