Suppose I have a table like:
TBL_CONDITIONS
| ID | WHERE_CLAUSE |
|----|---------------------------------------|
| 1 | fruit = 'apple' |
| 2 | delicious = 'T' |
| 3 | fruit = 'apple' AND gluten_free = 'T' |
| 4 | delicious = 'F' |
I'd like to be able to select the where clause on this table based on user input. Say the user selected "3". The stored procedure is written thusly:
BEGIN
SELECT * FROM SAMPLE WHERE (SELECT WHERE_CLAUSE
FROM TBL_CONDITIONS WHERE ID = 3);
END;
Unfortunately, this doesn't work. Is there a way to run this type of query? Or another way to accomplish the same task?