Using Wildcards in Variables in SQLITE queries
Posted: Mon Dec 07, 2015 9:22 pm
I am creating a programming in which I would like the UI to be almost entirely interactive. So if you click on something it sends the ID of that item to a variable to be included in the WHERE clause of the SQL statements updating the card. For example: you might have several items in different classes of category all of which may be interdependent or dependent upon another. Employee, Area, sales, department, Country.
Put "*" into tArea
put "*" into temployeeID
Put "*" into tDepartment
Put "*" into tCountry
Assuming we're already connected to the DB
Put "SELECT sales FROM employee WHERE Area is "&tArea&" AND employeeID is "&tEmployeeID" AND department is "&tDepartment&" AND Country is "&tCountry&";" into tSQL
put revDataFromQuery(tab,return,tDatabaseID,tSQL) into field "X"
I think Livecode is escaping out the variables, but I'm not sure. SQL returns an error when running the query at "*".
Essentially what I would like for it to do is when the user selects something it sends the ID up to the variable changes just that variable in the query to return everything for that ID. So click on an employeeID and it returns all the information for that employee. Click on a department then employee it returns everything for that employee in that department, etc. I'm not exactly sure what I'm doing wrong and if anyone has an easier way please feel free to make a suggestion. Typed on my phone so code may have a typo or two, please excuse I've already checked for that on the program.
Thanks
Put "*" into tArea
put "*" into temployeeID
Put "*" into tDepartment
Put "*" into tCountry
Assuming we're already connected to the DB
Put "SELECT sales FROM employee WHERE Area is "&tArea&" AND employeeID is "&tEmployeeID" AND department is "&tDepartment&" AND Country is "&tCountry&";" into tSQL
put revDataFromQuery(tab,return,tDatabaseID,tSQL) into field "X"
I think Livecode is escaping out the variables, but I'm not sure. SQL returns an error when running the query at "*".
Essentially what I would like for it to do is when the user selects something it sends the ID up to the variable changes just that variable in the query to return everything for that ID. So click on an employeeID and it returns all the information for that employee. Click on a department then employee it returns everything for that employee in that department, etc. I'm not exactly sure what I'm doing wrong and if anyone has an easier way please feel free to make a suggestion. Typed on my phone so code may have a typo or two, please excuse I've already checked for that on the program.
Thanks