Automatically discard conditions with empty params in Products Posted May 6, 2009 Hi,I'm a newbie and I would like to know if there is a way to discard WHERE conditions when their parameters are null or empty,Example:SELECT * FROM table1 WHERE (FIELD1=$P!{PARAM1}) AND (FIELD2=$P!{PARAM2})should be executed asSELECT * FROM table1 WHERE (FIELD1=$P!{PARAM1}) if $P!{PARAM2) is null or empty (empty string for strings, 0 for numbers)In another RAD tool that we are using this feature is called "REMOVE ON EMPTY PARAMETER" I know I can "embed" this behaviour directly in the query, but it becomes a pain if the query is rather complex like:SELECT * FROM table1 WHERE( FIELD1=$P!{PARAM1} OR FIELD2=$P!{PARAM2} ) AND( FIELD5<>$P!{PARAM2} OR FIELD6>$P!{PARAM3} OR FIELD7=$P!{PARAM4} ) The feature is VERY useful if we use the same query in many parametrized contexts (it avoids building and mantaining many smaller queries)Thank you in advance, M.
Automatically discard conditions with empty params
in Products
Posted
Hi,
I'm a newbie and I would like to know if there is a way to discard WHERE conditions when their parameters are null or empty,
Example:
SELECT * FROM table1 WHERE (FIELD1=$P!{PARAM1}) AND (FIELD2=$P!{PARAM2})
should be executed as
SELECT * FROM table1 WHERE (FIELD1=$P!{PARAM1})
if $P!{PARAM2) is null or empty (empty string for strings, 0 for numbers)
In another RAD tool that we are using this feature is called "REMOVE ON EMPTY PARAMETER"
I know I can "embed" this behaviour directly in the query, but it becomes a pain if the query is rather complex like:
SELECT * FROM table1 WHERE
( FIELD1=$P!{PARAM1} OR FIELD2=$P!{PARAM2} ) AND
( FIELD5<>$P!{PARAM2} OR FIELD6>$P!{PARAM3} OR FIELD7=$P!{PARAM4} )
The feature is VERY useful if we use the same query in many parametrized contexts (it avoids building and mantaining many smaller queries)
Thank you in advance,
M.