日期:2014-05-17 浏览次数:20918 次
-- 原代码:
Oracle 谢谢!
create procedure upTabValue
@tabName varchar(50),
@ID int ,
@curTime datetime
AS
declare @curWHeight float
declare @preWHeight float
BEGIN
set @curWHeight = (select waterHeight from @tabName where ID = @ID);
set @preWHeight = (select waterHeight from @tabName where ID = @ID -1);
set @time = (select getInfoTime from newestData where WellCode=@tabName);
if @preWHeight is not NULL and @curWHeight is NOT NULL and abs(@curWHeight-@preWHeight) > 2
BEGIN
update @tabName set waterHeight = @preWHeight where ID = @ID;
if @time = @curTime
update newestData set waterHeight = @preWHeight; -- 应该有where 条件吧?否则整个表的数据都更新的哦!
END
END
-- 对应Oracle代码
CREATE OR REPLACE PROCEDURE uptabvalue(
i_tabname varchar2,
i_id number,
i_curtime date
)
is
v_curWHeight number(38,4);
v_preWHeight number(38,4);
v_time date;
BEGIN
v_curWHeight := null;
v_curWHeight := null;
v_time := null;
BEGIN
EXECUTE IMMEDIATE 'SELECT waterHeight from '
------解决方案--------------------