select @sql='insert into '+ @table_name+ ' select HisTime,HisAllValue,HisAllUnit,HisValue,HisUnit,
case when HisStatus=''normal'' then ''0'' else ''1''  end as HisStatus,
sStatus,sProper,Memos,SenEquipNo from dbo.s_EnergyHis where substring(HisTime,1,4)+substring(HisTime,6,2)=substring('''+@create_table_date+''',1,6)'转译成oracle;
sql:='insert into '||table_name||' select HisTime,HisAllValue,HisAllUnit,HisValue,HisUnit,
case when HisStatus=''normal'' then ''0'' else ''1''  end as HisStatus,
sStatus,sProper,Memos,SenEquipNo from s_EnergyHis where substr(HisTime,1,4)+substr(HisTime,6,2)=substr('''||create_table_date||''',1,6)';
请教这样该有问题吗?

解决方案 »

  1.   


    --里面那个+号 应该有问题的,oracle里面连接要用 ||
    --从你的where 条件看,是一个6位的东西=6位的东西,因此需要将+换成||
    sql:='insert into '||table_name||' select HisTime,HisAllValue,HisAllUnit,HisValue,HisUnit,
                case when HisStatus=''normal'' then ''0'' else ''1''  end as HisStatus,
                sStatus,sProper,Memos,SenEquipNo from s_EnergyHis where substr(HisTime,1,4)||substr(HisTime,6,2)=substr('''||create_table_date||''',1,6)';
      

  2.   

    那么我执行这个sql在oracle中可以写成execute (sql);吗?
      

  3.   

    sql server中:
    select @date=getdate()
    转译成oracle是写成
    select sysdate into end_date from dual;
    还是写成date:=的形式。
      

  4.   


    select sysdate into end_date from dual;