how to get Max(DATE) using transformer
Moderators: chulett, rschirm, roy
how to get Max(DATE) using transformer
Hi all,
hash
I am using ODBC-->TRF---> ODBC
i want to take maxium date for lookup
how can i get in transformer for every records i want only the max dated recor
inlink.field01 inlink.field02
jkdkal 2007/12/12
jkdkal 2008/01/01
I want to take record to ouput column
outlink.field01 outlink.field01
jkdkal 2008/01/01
hash
I am using ODBC-->TRF---> ODBC
i want to take maxium date for lookup
how can i get in transformer for every records i want only the max dated recor
inlink.field01 inlink.field02
jkdkal 2007/12/12
jkdkal 2008/01/01
I want to take record to ouput column
outlink.field01 outlink.field01
jkdkal 2008/01/01
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Sort by field01 then by field02 (descending) prior to the Transformer stage and use stage variables to detect a change in field01. Constrain the output to those rows where you detect a change in field01.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
This is a DataStage function so it will only work within DataStage (in no sense will it work "in Oracle database"). It still relies on sorted data to work properly.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Hi all,
I want to select the first row as a updated one and reject the other rows, for example
inlink.field01 inlink.field02
jkdkal 2007/12/12
jkdkal 2008/01/01
jkdkal 2006/01/01
fkdajj 2005/05/04
fkdajj 2008/04/08
fkdajj 2008/08/23
I want to take record to ouput column as follows
outlink.field01 outlink.field01
jkdkal 2008/01/01
fkdajj 2008/08/23
I can use sort stage for rearranging the columns, as ray quoted " first by field01 and field02(descending).
how to use stage variable to allow only the first row
any ideas or workarround are welcomed
Thanks in advance
I want to select the first row as a updated one and reject the other rows, for example
inlink.field01 inlink.field02
jkdkal 2007/12/12
jkdkal 2008/01/01
jkdkal 2006/01/01
fkdajj 2005/05/04
fkdajj 2008/04/08
fkdajj 2008/08/23
I want to take record to ouput column as follows
outlink.field01 outlink.field01
jkdkal 2008/01/01
fkdajj 2008/08/23
I can use sort stage for rearranging the columns, as ray quoted " first by field01 and field02(descending).
how to use stage variable to allow only the first row
any ideas or workarround are welcomed
Thanks in advance
Re: how to get Max(DATE) using transformer
Hi,
Map the value like this
outlink.field01 ==> StageVar1
if StageVar1=StageVar2 then 'R' else 'P' StageChkVar
outlink.field01 ==> StageVar2
In Transformer Constraints, u can have condition as StageChkVar='P'
Other Simple Way would be have a remove duplicate stage Sort data based on first by field01 and field02(descending) and Remove duplicate key as field01 with Retain=First Record.
Hope this will help you.
Thanks.
Map the value like this
outlink.field01 ==> StageVar1
if StageVar1=StageVar2 then 'R' else 'P' StageChkVar
outlink.field01 ==> StageVar2
In Transformer Constraints, u can have condition as StageChkVar='P'
Other Simple Way would be have a remove duplicate stage Sort data based on first by field01 and field02(descending) and Remove duplicate key as field01 with Retain=First Record.
Hope this will help you.
Thanks.
Syed
---------
Wait and Watch
---------
Wait and Watch
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Re: how to get Max(DATE) using transformer
Server forum, Server post, PX advise. Hence the comment.
syeed wrote:Other Simple Way would be have a remove duplicate stage Sort data based on first by field01 and field02(descending) and Remove duplicate key as field01 with Retain=First Record.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
Hi all,
Thanks for your suggestion,
but I am using Inlink.field0, Inlink.field1 as varchar in oracle database and Outlink.field1 as number and Outlink.field2 as Timestamp
while i am using Iconv(Inlink.field1,'D-YMD[4,2,2]') or Oconv(Iconv(Inlink.field1,'D-YMD[4,2,2]'),'DQ4')
the Outlink.field1 is empty or NULL While it is pass without any of Iconv or Oconv it's working fine. I donot get why this response is occuring.
The job runs successfully without any warnings
Please clarify this professionals
Thanks for your suggestion,
but I am using Inlink.field0, Inlink.field1 as varchar in oracle database and Outlink.field1 as number and Outlink.field2 as Timestamp
while i am using Iconv(Inlink.field1,'D-YMD[4,2,2]') or Oconv(Iconv(Inlink.field1,'D-YMD[4,2,2]'),'DQ4')
the Outlink.field1 is empty or NULL While it is pass without any of Iconv or Oconv it's working fine. I donot get why this response is occuring.
The job runs successfully without any warnings
Please clarify this professionals
Since your date is in the form YYYY/MM/DD there is no need to convert to internal format. The nulls or empties are a separate issue.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Outlink will only be NULL if the input is NULL
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>