Tuesday, March 27, 2012

date problem : dynamic SQL in an OLE DB Source component

Hello,

I have an OLEDB Source component with a Oracle OLEDB connection manager.
In my SQL statement I must do something like this ...

SELECT * FROM OracleTable
WHERE convert(datetime, OracleDate) = parameter

I've dynamicaly build the statement like this : http://blogs.conchango.com/jamiethomson/archive/2005/12/09/2480.aspx

Unfortunately this doesn't work because the variable is a datetime value and not a string.

Maybe another way is to store the date in a table in my SQL database and include it in my Oracle SQL statement ? This would mean that there are multiple connection managers being used in one SQL statement ... I have no idea if this would be possible ...

Any other options ?

Yes that would be possible but is a far far more complicated solution than it needs to be.

Keep persuing the expression solution. If the variable is a DateTime then you need to cast it as a string. Remember - the expression is populating a string property so it should return a string.

This is a string manipulation problem - pure and simple!

-Jamie

|||thanks, it works ... I now convert the date to integer format and then to string format so it can be used in the dynamic SQL query

No comments:

Post a Comment