日期:2014-05-17  浏览次数:20882 次

各位,大牛,大侠请帮个忙,把下面的SQLServer(注:下面的SQLServer是错误的,大家看逻辑就可以)转化成Oracle 谢谢!
  各位,大牛,大侠,高手,请帮个忙,把下面的SQLServer(注:下面的SQLServer是错误的,大家看逻辑就可以)转化成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;   
   END
END 

------解决方案--------------------
怎么删除不掉呢,你上面的写法应该没有错啊
------解决方案--------------------
-- 原代码:
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 '
------解决方案--------------------