SSIS and sending query with date to Oracle

跟風遠走 提交于 2021-01-28 06:26:59

问题


I am trying to create a flow to pull data from an Oracle table into a SQL Server table. I am sending the following query to Oracle to get the data:

select distinct CHLD.id,
       nvl(chld_c_spl, 'N'),
       to_char(chld_d_start, 'YYYY-MM-DD') chld_d_start,
       to_char(chld_d_end, 'YYYY-MM-DD') chld_d_end
  from child chld, 
       picture ptct
 where CHLD.id = PTCT.chld_id
   and nvl(chld_d_end, sysdate) >= to_date('01-JAN-2014')
   and chld_c_veri in ('HC','DR')
   and nvl(ptct_term, ptct_end) >= to_date('01-JAN-2014')

When I run the query in Oracle, I get 505 rows returned. When I execute the SSIS package, 1,504 rows are inserted. For some reason, it looks like the query SSIS passes is not looking at the where clause for the ptct table (nvl(ptct_term, ptct_end) >= to_date('01-JAN-2014')) since all the extra rows are rows that do not have a valid entry in the picture (ptct) table.

Does anyone have advice as to what is going on here? The original query used an exists clause on the ptct table instead of the join, but it didn't work so I converted to the join. When the exists clause was there, similar results were seen to those described above.


回答1:


Most probably your NLS settings are different between your Oracle query tool (sqlplus, toad...) and SSIS. Try to give your date explicitly, as to_date('2014-01-01','YYYY-MM-DD').

select distinct CHLD.id,
       nvl(chld_c_spl, 'N'),
       to_char(chld_d_start, 'YYYY-MM-DD') chld_d_start,
       to_char(chld_d_end, 'YYYY-MM-DD') chld_d_end
  from child chld, 
       picture ptct
 where CHLD.id = PTCT.chld_id
   and nvl(chld_d_end, sysdate) >= to_date('2014-01-01','YYYY-MM-DD')
   and chld_c_veri in ('HC','DR')
   and nvl(ptct_term, ptct_end) >= to_date('2014-01-01','YYYY-MM-DD')


来源:https://stackoverflow.com/questions/28732117/ssis-and-sending-query-with-date-to-oracle

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!