--exec dbo.p_insertnr_yxrzusertable
create proc dbo.p_insertnr_yxrzusertable
as--tbyxrz_name,flag:0 三班制,1 白班制,2 全天制後夜, 3 每週制, 4 每月制, 5 全天制前夜, 6 全天制白班
--tbyxrz_name,flagother:周,或月的第幾天
declare @time char(5),@tablename varchar(8000),@tablename1 varchar(100),@i int,@date char(10),@bc char(1)
declare @partday char(2),@partweek char(1)
select @tablename=''
set @i = 0
select @time = substring(convert(varchar,getdate(),20),12,5)
select @partday = datepart(day,getdate()),@partweek = datepart(weekday,getdate())
------------------------------
select @tablename = @tablename + b.tablename+','
from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 0
select @i = @i + count(1) from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 0
------------------------------
select @tablename = @tablename + b.tablename+','
from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_name = '燃料翻車機日誌'
select @i = @i + count(1) from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_name = '燃料翻車機日誌'
------------------------------
if (@time < '09:00') and (@time >= '08:00') begin
select @tablename = @tablename + b.tablename +','
from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 1
select @i = @i + count(1) from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 1
end;
------------------------------
if (@time < '02:00') and (@time >= '00:00') begin
select @tablename = @tablename + b.tablename +','
from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 2
select @i = @i + count(1) from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 2
----每月的預定日期的後夜生成
--/*
select @tablename = @tablename + b.tablename +','
from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 4 and a.flagother = @partday - 1
select @i= @i + count(1) from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 4 and a.flagother = @partday - 1
--*/
end;
------------------------------
if (@time < '17:00') and (@time >= '16:00') begin
select @tablename = @tablename + b.tablename +','
from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 5
select @i = @i + count(1) from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 5
end;
------------------------------
select @tablename = @tablename + b.tablename +','
from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 3 and a.flagother = @partweek - 1
select @i= @i + count(1) from tbyxrz_name a inner join tbyxrznotemodule b on a.rz_id= b.rz_id where a.rz_isinsert = 0 and a.flag = 3 and a.flagother = @partweek - 1
--print @tablename
select @date = convert(char(10),getdate(),20)
select @bc= (case when @time>'08:19' and @time <'16:19' then '0'
when @time>'00:19' and @time <'08:19' then '2' else '1' end)
while @i>0 begin
set @tablename1 = substring(@tablename,1,charindex(',',@tablename)-1)
exec( 'insert into '+ @tablename1 +'(reportdate,bc,tq,createtime,data)
select convert(char(10),getdate(),20),bc='+@bc+',''0'',getdate(),data
from tbyxrznotemodule where tablename='''+@tablename1 + '''')
exec('update a set a.bz = b.bz from '+@tablename1+
' a left outer join tbyxzb b on a.reportdate=b.time1 and a.bc=b.bc where a.reportdate='''+@date+'''')
select @tablename = stuff(@tablename,1,charindex(',',@tablename),'')
set @i = @i - 1
endgo
演算法創作 按規律插數
問題描述 給定乙個遞增或遞減的陣列 1,2,55,78,120 在陣列中插入乙個數字,要求按插入後不改變陣列遞增或遞減的規律。示例1 輸入 3 輸出 1,2,3,55,78,120 解釋 數字3比1大,比55小,將3插入後,原來的陣列依然是按照從小到大的順序排列的,不改變陣列遞增的規律。示例2 輸入...
hermite插值 數值計算筆記2 函式插值逼近
給出經過樣本點的連續函式。n 1個點對應n次多項式,盡量用內插發,並且選用已知節點使插值節點與公式中的已知節點近一些。1.lagrange差值問題的解函式是存在唯一的 2.lagrange 插值多項式 3.一般的newton插值多項式 先寫出差商表 3.等距節點的newton插值多項式 先寫出差分表...
四元數的插值方法
四元數常見的插值方法有線性插值 lerp 和球面線性插值 slerp 首先,線性插值方法 q t lerp q0,q1,t 1 t q 0 tq 1q t lerp q 0,q 1,t 1 t q 0 tq 1 qt le rp q 0 q 1 t 1 t q 0 t q1 由於這樣算出的q tq ...