Column concatenation help
Moderators: chulett, rschirm, roy
Column concatenation help
DS Gurus,
I have an oracle source table
id name1 name2 name3 name4....nameN code
100 sam rob dan NULL ven xyz
101 lob NULL jen lar del ABC
I want the output in the Oracle target table to be
id names code
100 sam,rob,dan,unknown,...,ven XYZ
101 lob,unknown,jen,lar,...,del ABC
Basically, i need to check the column values (There may be n number of columns) and it is null, I need to return like 'unknown' else returns the column value only.
Please let me know, how can i do this???
Thx
I have an oracle source table
id name1 name2 name3 name4....nameN code
100 sam rob dan NULL ven xyz
101 lob NULL jen lar del ABC
I want the output in the Oracle target table to be
id names code
100 sam,rob,dan,unknown,...,ven XYZ
101 lob,unknown,jen,lar,...,del ABC
Basically, i need to check the column values (There may be n number of columns) and it is null, I need to return like 'unknown' else returns the column value only.
Please let me know, how can i do this???
Thx
Or you could do it with a user-defined query on the OCI stage
Code: Select all
select id, nvl(name1,'unknown'), nvl(name2,'unknown'), ...
from tableX;
Jim Paradies
Thanks for all you reply.
The real issue is, i have more than 100 columns and need to process around 10 million records and the problem here is i need to check nvl condition for all the columns. one more issue is except key columns i need to concatenate all the other columns into one single column at the output table. Any more suggestions.
The real issue is, i have more than 100 columns and need to process around 10 million records and the problem here is i need to check nvl condition for all the columns. one more issue is except key columns i need to concatenate all the other columns into one single column at the output table. Any more suggestions.
How about reading this topic
viewtopic.php?p=159175&sid=93faa1a04763 ... a65#159175
which is actively being discussed right now.
In your transformer, you could mass-apply a function to existing derivations. Check it out in the Transformer stage help. Write a NVL type function in DS Manager that can be used to replace NULLs with a passed value.
Not to pick a nit, but there are advantages to reading other posts to gain insight, maybe during a coffee break or something. Something learned today could be applied months from now.![Wink :wink:](./images/smilies/icon_wink.gif)
viewtopic.php?p=159175&sid=93faa1a04763 ... a65#159175
which is actively being discussed right now.
In your transformer, you could mass-apply a function to existing derivations. Check it out in the Transformer stage help. Write a NVL type function in DS Manager that can be used to replace NULLs with a passed value.
Not to pick a nit, but there are advantages to reading other posts to gain insight, maybe during a coffee break or something. Something learned today could be applied months from now.
![Wink :wink:](./images/smilies/icon_wink.gif)
Kenneth Bland
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
Rank: Sempai
Belt: First degree black
Fight name: Captain Hook
Signature knockout: right upper cut followed by left hook
Signature submission: Crucifix combined with leg triangle
If you use Ken's suggestion you will end up with two columns - KEY and DATA. The DATA column will look something like
You could then apply a function to the DATA column like this
which would give you a result like this
Now why you would put something like that in the database, I don't know!
Code: Select all
,field1,field2,,
Code: Select all
tmp = Arg1
Convert "," to @FM in tmp
Ans = ""
For i = 1 to DCount(tmp,@FM)
If tmp<i> = "" Then
Ans := "unknown"
End Else
Ans := tmp<i>
End
Next i
Code: Select all
unknownfield1field2unknownunknown
Jim Paradies
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Yes, you DO need to check somehow, somewhere. It's unavoidable unless you can absolutely guarantee that a particular column can never have a null value - so you can skip that column from your checks.colorblue wrote:Thanks for all you reply.
The real issue is, i have more than 100 columns and need to process around 10 million records and the problem here is i need to check nvl condition for all the columns. one more issue is except key columns i need to concatenate all the other columns into one single column at the output table. Any more suggestions.
Use stage variables extensively; this will aid the null checks (and allow for exception reporting if required) and will aid the construction of your single everything_except_the_key_is_in_here column, perhaps a few columns at a time to facilitate future maintenance, and definitely to avoid issues with the maximum length of an expression.
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.