I would like to be able to call a gateway script from a SQL SELECT query, in order to convert an error code to readable text. Something like this:
SELECT code, shared.control.codeMessage(code) AS message FROM error_log
So far, no go. Any suggestions to get something like this to work??
Left Hand Brewing Company
As long as something valid is getting returned from that function you should be able to do something like this to build out your SQL query.
fun = shared.scripts.returnSomething()
sqlQuery = “SELECT “+fun+” from sensors”
All my shared script is doing is returning a string value:
Seems a bit backward – I put a table of codes and messages in the DB, and have scripts look it up. But if that’s what you have to have, you could try the view() function from the Simulation Aids module. Feed it a dataset with the code numbers, and get a dataset with code vs message.