问题
I am doing the following in Informix to delete rows more than 20 seconds old.
delete from sometable
where someDateColumn < (current - interval (20) second to second);
However, I want to make the interval configurable in a stored procedure, but I can't do
CREATE PROCEDURE i_hate_informix (prm_timeframe int)
DELETE sometable
WHERE someDateColumn < (current - interval (prm_timeframe) second to second);
END PROCEDURE;
回答1:
I found the answer myself.
Interval can not be defined dynamically with a variable. But you can use "units second" so my procedure becomes
CREATE PROCEDURE i_hate_informix (prm_timeframe int)
DELETE sometable
WHERE someDateColumn < (current - prm_timeframe units second);
END PROCEDURE;
来源:https://stackoverflow.com/questions/920207/informix-defining-an-interval-with-a-parameter