17,086
社区成员
发帖
与我相关
我的任务
分享
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)'
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)';
select sysdate into end_date from dual;
select @date=getdate()
select sysdate into end_date from dual;
--里面那个+号 应该有问题的,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)';