This is the original query, which works fine using ado.net
source and using the .net providers\\odbc data provider specified inside the source.
You can use the following steps:
Dataflow
and click Properties
.SqlCommand
for your Data Source and using the Expression builder prepare your query using SSIS variables (datetime variable in your case).Try this in your expression builder -- note that your variable must be a string, if it's not, you use (DT_WSTR,30)
to cast it. Since you're using dates, your SQL will need to handle a string-formatted date, i.e. use to_date()
in Oracle.
"SELECT a.FA_CLNT_ID, a.FA_ACCT_NM, a.ACCT_E_DT, a.POL_PER_CURR_DT, a.POL_PER_NEXT_DT, a.FA_ACCT_NUM, a.GRP_SALES_OFFC_CD, a.ACCT_C_DT
FROM gyv2M.DDM_ACCT_STRUC a
INNER JOIN
(SELECT max(DDM_ACCT_STRUC_TP) as DDM_ACCT_STRUC_TP, FA_CLNT_ID
FROM gyv2M.DDM_ACCT_STRUC
WHERE FA_DM_ROW_DT <= '"+ (DT_WSTR,30)@[User::RepDate] +"' AND DM_ROW_E_DT <= '"+ (DT_WSTR,30)@[User::RepDate] +"'
GROUP BY FA_CLNT_ID) b
ON a.DDM_ACCT_STRUC_TP = b.DDM_ACCT_STRUC_TP AND a.FA_CLNT_ID = b.FA_CLNT_ID AND FA_DM_ROW_DT <= '" +(DT_WSTR,30)@[User::RepDate] +"' AND a.DM_ROW_E_DT <='"+(DT_WSTR,30)@[User::RepDate]+"'"
Hope this helps!
Try this in your expression builder,
"SELECT a.FA_CLNT_ID, a.FA_ACCT_NM, a.ACCT_E_DT, a.POL_PER_CURR_DT, a.POL_PER_NEXT_DT, a.FA_ACCT_NUM, a.GRP_SALES_OFFC_CD, a.ACCT_C_DT
FROM gyv2M.DDM_ACCT_STRUC a
INNER JOIN
(SELECT max(DDM_ACCT_STRUC_TP) as DDM_ACCT_STRUC_TP, FA_CLNT_ID
FROM gyv2M.DDM_ACCT_STRUC
WHERE FA_DM_ROW_DT <= '"+ (DT_WSTR,30)@[User::RepDate] +"' AND DM_ROW_E_DT <= '"+ (DT_WSTR,30)@[User::RepDate] +"'
GROUP BY FA_CLNT_ID) b
ON a.DDM_ACCT_STRUC_TP = b.DDM_ACCT_STRUC_TP AND a.FA_CLNT_ID = b.FA_CLNT_ID AND FA_DM_ROW_DT <= '" +(DT_WSTR,30)@[User::RepDate] +"' AND a.DM_ROW_E_DT <='"+(DT_WSTR,30)@[User::RepDate]+"'"
Hope this works!