(還沒試,先記下)
--You can use dynamic SQL in informix - see this link for more details.
--https://www.ibm.com/developerworks/data/library/techarticle/dm-0806mottupalli/index.html
DEFINE v_sql VARCHAR(250);
LET v_sql = "select name from employees";
IF IN_PARAMETER = 1 THEN
LET v_sql = v_sql || " WHERE active = true"
ELSE
LET v_sql = v_sql || " WHERE idboss = 3"
END IF;
PREPARE stmt FROM v_sql;
EXECUTE stmt;
FREE stmt;
--If you can't use dynamic SQL, the next best thing would be:
IF IN_PARAMETER = 1 THEN
select name from employees WHERE active = true;
ELSE
select name from employees WHERE idboss = 3;
END IF;