Appending values from two columns into one

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Appending values from two columns into one

Post by narasimha »

I need to take values from 2 columns from a table and put in into another table as a single column

Example

Code: Select all

I have 2 columns in table X with values

A	           B
----         ----
1	           32
1	           8	
2	           0
43	          1
0	           2
34	          1

I need to insert it into another table Y's column C as

Code: Select all

C
----
1
1
2
43
34
32
8
1
2
1
I could run the insert job twice, pulling in different column at a time.
But I was wondering if i could do this in one job or if there was a better approach to this?
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Your source extraction could be user-defined SQL.

Code: Select all

SELECT A FROM tablename UNION ALL SELECT B FROM tablename;
Naturally this requires that columns A and B have compatible data types but, then, so does inserting them into the one column in your target. If they are incompatible, use CAST to guarantee that they are in the result of the query.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
narasimha
Charter Member
Charter Member
Posts: 1236
Joined: Fri Oct 22, 2004 8:59 am
Location: Staten Island, NY

Post by narasimha »

Thanks Ray,

Your's is a better appraoch, It is better to do a union all, rather than running the job twice
Narasimha Kade

Finding answers is simple, all you need to do is come up with the correct questions.
deployDS
Premium Member
Premium Member
Posts: 45
Joined: Thu Mar 09, 2006 9:36 am

Post by deployDS »

You could also use a funnel stage. Use a copy stage to send the table data into 2 streams.

Col A would be renamed to Col C in one stream and Col B would be renamed to Col C in other stream. You can funnel them and take Col C as Col A and col B data together.

Again the same metadata assumption holds.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

The OP sure can but too bad the funnel stage is only available in PX and not server :twisted:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Not in a Server job.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

Beat you to it Craig :twisted:
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Unless, of course, one were to write one's own server Funnel stage... :twisted:
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dsdesigner
Participant
Posts: 34
Joined: Thu Jul 29, 2004 1:03 pm

Post by dsdesigner »

ray.wurlod wrote:Unless, of course, one were to write one's own server Funnel stage... :twisted: ...
Can't we use the Link Collector stage to achieve the functionality of a funnel stage?

dsdesigner
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Yes and no. There isn't a collection method in the Link Collector stage that permits "all from source A then all from source B". The (parallel) Funnel stage has a "Sequence" method that permits this mode of operation.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
dsdesigner
Participant
Posts: 34
Joined: Thu Jul 29, 2004 1:03 pm

Post by dsdesigner »

ray.wurlod wrote:Yes and no. There isn't a collection method in the Link Collector stage that permits "all from source A then all from source B". The (parallel) Funnel stage has a "Sequence" method that permits this ...
Ooops! Misread the requirement. Will work on that. Thanks
Post Reply