+ -
当前位置:首页 → 问答吧 → 关于存储过程里的datetime比较

关于存储过程里的datetime比较

时间:2011-11-10

来源:互联网

大家好,谁能帮忙写一个简单的存储过程。

传入参数datetime a 和 int key

从table中根据key选出一条记录,key是pk,这条记录中b也是datetime类型。

将a和b做对比,如果b晚于a,则执行特定insert 语句,否则执行update语句。

非常感谢

作者: maximo   发布时间: 2011-11-10

建议参考手册中先自己写一下,然后有什么问题可以把你的代码和问题一起贴出来大家讨论分析。

作者: ACMAIN_CHM   发布时间: 2011-11-10

SQL code
create procedure sp_test(a1 datetime ,key1 int)
begin
declae temp datetime;
select b into temp from table where key=key1;
if timestampdiff(s,a,b)>0 then
  insert into xxxx; 
else
  update xxx;
end if;
end

作者: rucypli   发布时间: 2011-11-11

相关阅读 更多