Informix defining an INTERVAL with a parameter

邮差的信 提交于 2019-12-11 03:21:31

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!