I have a dropdown that is populated through a query and I have “custom options” enabled for the dropdown. Basically, I want to run a query that will check to see if the selected value, of the dropdown, exists in the database (I know that the selected value is not in the DB, but the end user does not). If it does not, I want to show a popup.
My problem is, I can’t get the right SQL query syntax…
When a value is selected from the dropdown, it passes the selected value into parameter “Customer”
Client is the column I want to search in the table
The table is called DBTable
Here is my script:
customer = self.view.params.Customer
existsInDB = system.db.runScalarQuery("SELECT Client FROM DBTable WHERE Client LIKE '%s'" %customer)
if existsInDB == None:
value = "Not in DB"
else:
value = "Exists in DB"
return value
Until I can get some other things developed and working, I am just displaying “Not in DB” in a text box if the selected value is not in the database and “Exists in DB” if the selected value does exist.
Thank you in advance