Kettle的執行sql指令碼的元件

2021-08-11 14:50:26 字數 4601 閱讀 8955

kettle的執行sql指令碼的元件要是下面的上邊sql會報錯誤,無法儲存成功,下面的下邊sql就能儲存成功,這個元件對於sql是有限制的!!!

update dsjydd.t_cskqzlfx_dqst_ylts b set b.ylts = (

select c.ylts from (

select count(*) ylts,a.citycode from tenv.air_citydayaqi_publish a where a.quality in ('優','良') 

and to_char(a.timepoint,'yyyy-mm') >= (

select concat(year(sysdate),'-01') from dual

)and to_char(a.timepoint,'yyyy-mm') <= to_char(sysdate,'yyyy-mm')

and 

a.citycode in ('110000','120000','130100','130200','131000','130600',

'130900','131100','130500','130400','140100'

,'140300','140400','140500','370100','370300','370800','371400','371500','371600','371700','410100','410200'

,'410500','410600','410700','410800','410900')

group by a.citycode) c where c.citycode = b.citycode),

b.yltstb = (select case when ylts_qn = 0 then null else round((ylts_jn-ylts_qn)/ylts_qn,2) * 100 end yltstb  from (

select count(*) ylts_jn,e.citycode,

( select ylts_qn from (

select count(*) ylts_qn,p.citycode from tenv.air_citydayaqi_publish p 

where p.quality in ('優','良')

and to_char(p.timepoint,'yyyy-mm') >= to_char(to_date(concat(year(sysdate),'-01'),'yyyy-mm') - 1 year,'yyyy-mm')

and to_char(p.timepoint,'yyyy-mm-dd') <= to_char((sysdate-1 day) -1 year,'yyyy-mm-dd')

and p.citycode in ('110000','120000','130100','130200','131000','130600',

'130900','131100','130500','130400','140100'

,'140300','140400','140500','370100','370300','370800','371400','371500','371600','371700','410100','410200'

,'410500','410600','410700','410800','410900')

group by p.citycode

) d where d.citycode = e.citycode) ylts_qn

from tenv.air_citydayaqi_publish e  where e.quality in ('優','良') 

and to_char(e.timepoint,'yyyy-mm') >= (

select concat(year(sysdate),'-01') from dual)

and to_char(e.timepoint,'yyyy-mm') <= to_char(sysdate,'yyyy-mm')

and e.citycode in ('110000','120000','130100','130200','131000','130600',

'130900','131100','130500','130400','140100'

,'140300','140400','140500','370100','370300','370800','371400','371500','371600','371700','410100','410200'

,'410500','410600','410700','410800','410900')

group by e.citycode

) f where f.citycode = b.citycode)

where exists (select 1 from tenv.air_citydayaqi_publish a where a.quality in ('優','良') 

and to_char(a.timepoint,'yyyy-mm') >= (

select concat(year(sysdate),'-01') from dual

)and to_char(a.timepoint,'yyyy-mm') <= to_char(sysdate,'yyyy-mm')

and a.citycode in ('110000','120000','130100','130200','131000','130600',

'130900','131100','130500','130400','140100'

,'140300','140400','140500','370100','370300','370800','371400','371500','371600','371700','410100','410200'

,'410500','410600','410700','410800','410900')

update dsjydd.t_cskqzlfx_dqst_ylts b set b.ylts = (

select c.ylts from (

select count(*) ylts,a.citycode from tenv.air_citydayaqi_publish a where a.quality in ('優','良') 

and to_char(a.timepoint,'yyyy-mm') >= (

select concat(year(sysdate),'-01') from dual

)and to_char(a.timepoint,'yyyy-mm') <= to_char(sysdate,'yyyy-mm')

group by a.citycode) c where c.citycode = b.citycode),

b.yltstb = (select case when ylts_qn = 0 then null else round((ylts_jn-ylts_qn)/ylts_qn,2) * 100 end yltstb  from (

select count(*) ylts_jn,e.citycode,

( select ylts_qn from (

select count(*) ylts_qn,p.citycode from tenv.air_citydayaqi_publish p 

where p.quality in ('優','良')

and to_char(p.timepoint,'yyyy-mm') >= to_char(to_date(concat(year(sysdate),'-01'),'yyyy-mm') - 1 year,'yyyy-mm')

and to_char(p.timepoint,'yyyy-mm-dd') <= to_char((sysdate-1 day) -1 year,'yyyy-mm-dd')

group by p.citycode

) d where d.citycode = e.citycode) ylts_qn

from tenv.air_citydayaqi_publish e  where e.quality in ('優','良') 

and to_char(e.timepoint,'yyyy-mm') >= (

select concat(year(sysdate),'-01') from dual)

and to_char(e.timepoint,'yyyy-mm') <= to_char(sysdate,'yyyy-mm')

group by e.citycode

) f where f.citycode = b.citycode)

where exists (select 1 from tenv.air_citydayaqi_publish a where a.quality in ('優','良') 

and to_char(a.timepoint,'yyyy-mm') >= (

select concat(year(sysdate),'-01') from dual

)and to_char(a.timepoint,'yyyy-mm') <= to_char(sysdate,'yyyy-mm')

)注意的是要是讓kettle只是執行一次sql檔案的話,那麼只需要建立上面乙個執行sql指令碼的元件就行了,然後建立定時任務,kettle就能定時的執行了!!!

通過 指令碼執行 kettle 的作業 命令

執行kettle工具寫的作業在部署伺服器時,工作的時候通過 bat指令碼來執行,具體的執行規範如下 c cd c program files x86 pdi ce 5.4 0.1 130 data integration kitchen rep 同步o2o隨訪記錄到net job 同步o2o記錄到n...

kettle 入門操作 SQL指令碼

簡單對比一下這兩個控制項的功能和sql指令碼的功能差異,比較簡單,相對有點難度的就是sql及過程呼叫 kettle兩個sql指令碼控制項也是為了執行kettle,但是只限於等值sql,就是不能夠出現像sql語句中的like aa 這種 經過多次測試,目前不支援 解決辦法,建立儲存過程,通過執行指令碼...

kettle執行sql語句錯誤總結

kettle配置圖 1.元件 欄位選擇報錯 error version 7.1.0.0 12,build 1 from 2017 05 16 17.18.02 by buildguy 字段 已經被指定2次 或更多 使用同乙個名字 原因 字段選擇元件中重複選擇了同乙個字段導致報錯。處理 字段選擇中選擇...