I think I have a pretty easy one here - just can't get it to work and am looking for some help.
I have a dropdown that contains a list of part names. The Data field is bound to a Named Query that is grabbing these names from a SQL table. I also have a button that, when pressed, sets the Selected Value of the dropdown to -1 so that I can clear the dropdown.
Desired functionality:
I would like to filter a Power Table based on the Selected Sting Value of the dropdown UNLESS the Selected Value of the dropdown is -1, in which case I would like to SELECT ALL for my Power Table.
This is something we do in the Ignition Database and Scripting Training Class #ad
It sounds like:
Your Power Table is filtering using a WHERE clause, which is looking to match your parameter (original source = selected dropdown value)
When the selected dropdown value is -1 you want it to return all data
So the where clause should be evaluating for the parameter match, OR the parameter being -1 (because if the param provided is -1 you no longer need the other half of the WHERE logic to apply)
If that is what you are after the change is primarily in the query for the Power Table.
And full disclosure, I took the Database and Scripting Class a couple months ago which was phenomenal. I was just having a brain cramp and needed a nudge to shake some of the cobwebs loose, which you have provided - so thank you!
Here is my revised query which seems to be running as I need it to now:
SELECT HI.TransactionID, HI.HardwareID, H.BagName, HI.TransactionAmount,
HI.TransactionNotes, HI.TransactionPerson, HI.TransactionTime
FROM Hardware_Inventory HI
INNER JOIN Hardware H ON HI.HardwareID = H.BagID
WHERE :HardwareIDParam = HI.HardwareID OR :HardwareIDParam = -1
ORDER BY HI.TransactionTime DESC