scottr
scottr

Reputation: 65

SSIS and sending query with date to Oracle

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.

Upvotes: 1

Views: 4028

Answers (1)

Atilla Ozgur
Atilla Ozgur

Reputation: 14721

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')

Upvotes: 1

Related Questions