I have a need to create a query that will look like this:
SELECT DISTINCT a.item
FROM stsc.sku a
, stsc.item b
, stsc.loc c
WHERE a.p_abc = 'A'
AND b.p_stkclass IN ('010', '010A')
AND a.item = b.item
AND a.loc = c.loc
AND c.p_dlrgrp = 'MHC'
but the problem is that I could have many values for p_stkclass and many values for p_dlrgrp. Each time the user runs the code they can enter as many parameters as they want and I need to build, run, and return the results. Is there a way to dynamically build this query on the fly?
SELECT DISTINCT a.item
FROM stsc.sku a
, stsc.item b
, stsc.loc c
WHERE a.p_abc = 'A'
AND b.p_stkclass IN ('010', '010A')
AND a.item = b.item
AND a.loc = c.loc
AND c.p_dlrgrp = 'MHC'
but the problem is that I could have many values for p_stkclass and many values for p_dlrgrp. Each time the user runs the code they can enter as many parameters as they want and I need to build, run, and return the results. Is there a way to dynamically build this query on the fly?