Passing Stage variable into Oracle using Oracle date formats

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
RamonaReed
Participant
Posts: 26
Joined: Fri Feb 27, 2004 7:23 am
Location: WI, USA

Passing Stage variable into Oracle using Oracle date formats

Post by RamonaReed »

Hi, I am trying to write a dynamic query in Oracle using Datastage variables that get set at time of job running. I am getting errors from the way I am tying to pass the date into Oracle. I have defined a stage variable: srchQueryDateRange - that will hold the date portion of my query, the variable holds the following:

If dateFormat = 'D8' Then " and TO_CHAR(B.srvc_from_dt,\'yyyymmdd\') = ORCHESTRATE.SRVC_FROM_DT"
else If dateFormat = 'RD8' Then " and TO_CHAR(B.srvc_from_dt,\'yyyymmdd\') >= ORCHESTRATE.SRVC_FROM_DT and TO_CHAR(B.srvc_to_dt,\'yyyymmdd\') <= ORCHESTRATE.SRVC_TO_DT" else ""

My problem seems to be trying to pass the format within a variable. Can someone please tell me what I am doing wrong?

Thanks so much for any help.
Mona
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

What data type is "srchQueryDateRange " and what is the derivation for it?
the if-then-else construct you posted can't be used as the derivation for the stage variable. Also is "dateFormat" a parameter to your job?
RamonaReed
Participant
Posts: 26
Joined: Fri Feb 27, 2004 7:23 am
Location: WI, USA

Post by RamonaReed »

the datatype is varchar and the if-then-else construct is correct why can't it be used for the derivation. The derivation for the variable is " and TO_CHAR(B.srvc_from_dt,\'yyyymmdd\') = ORCHESTRATE.SRVC_FROM_DT"
OR " and TO_CHAR(B.srvc_from_dt,\'yyyymmdd\') >= ORCHESTRATE.SRVC_FROM_DT and TO_CHAR(B.srvc_to_dt,\'yyyymmdd\') <= ORCHESTRATE.SRVC_TO_DT" depending on the value in variable dateFormat
Kryt0n
Participant
Posts: 584
Joined: Wed Jun 22, 2005 7:28 pm

Post by Kryt0n »

By "stage variable" I assume you mean input parameter, you couldn't possibly pass the stage variable to oracle...

When datastage composes the query, what does the query string have for your variable section? Unless it's adjusted in 8.7, I would expect the single quotes to disappear, in 8.5 we had to use the environment variable APT_OSL_PARAMS_ESC_SQUOTE to keep our quotes within parameters.
Post Reply