Passing Date Param from Job to ODBC User-Defined SQL Delete

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
scottopizza
Premium Member
Premium Member
Posts: 51
Joined: Tue Feb 05, 2002 3:06 pm

Passing Date Param from Job to ODBC User-Defined SQL Delete

Post by scottopizza »

I am trying to pass a date to the ODBC user defined sql delete statement listed below from my job but it is deleting the entire table instead of only the records that meet the date criteria. If I hard code the date of 10/01/2010 in the delete statement, it works fine. Any assistance would be greatly appreciated. I have my job param defined as a Date but have also tried string. The Field in the SQL table is defined as datetime.

DELETE UHCDATA.COMORBIDITY_DEV
FROM
(SELECT C.RECORDID, C.UNIVCODE, C.DATABASEID
FROM UHCDATA.ENCOUNTER A, CAPMGT.DATES B, UHCDATA.COMORBIDITY_DEV C
WHERE A.RECORD_ID = C.RECORDID
AND A.UNIV_CODE = C.UNIVCODE
AND A.DATABASE_ID = C.DATABASEID
AND A.DISCHARGEDATE = B.DATE_ID
AND B.FULL_DATE >= #Start_Date#) D
WHERE
D.RECORDID = UHCDATA.COMORBIDITY_DEV.RECORDID
AND D.UNIVCODE = UHCDATA.COMORBIDITY_DEV.UNIVCODE
AND D.DATABASEID = UHCDATA.COMORBIDITY_DEV.DATABASEID

Thank you.
GJ_Stage
Participant
Posts: 131
Joined: Mon Oct 27, 2008 6:59 am

Post by GJ_Stage »

Try like , Pass date param as string and then chagne your query like this. to_date(#Start_Date#,'YYYYMMDD')
shawn.k
Premium Member
Premium Member
Posts: 7
Joined: Wed Oct 06, 2010 10:47 am

Re: Passing Date Param from Job to ODBC User-Defined SQL Del

Post by shawn.k »

AND B.FULL_DATE >= "#Start_Date#")
Try putting double quotes around the parameter.
shawn.k
Premium Member
Premium Member
Posts: 7
Joined: Wed Oct 06, 2010 10:47 am

Re: Passing Date Param from Job to ODBC User-Defined SQL Del

Post by shawn.k »

AND B.FULL_DATE >= "#Start_Date#")
Try putting double quotes around the parameter.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Single quotes, surely?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
scottopizza
Premium Member
Premium Member
Posts: 51
Joined: Tue Feb 05, 2002 3:06 pm

Post by scottopizza »

ray.wurlod wrote:Single quotes, surely?
Yep, the single quotes worked. Thanks everyone!
Post Reply