In this article instead of developing or doing any modifications s we
have discussed earlier we are going to discuss to do some creations of
rows and columns with help of Column Generator and Row Generator stages in Datastage.
Consider following Table
Step #1: Design your job structure like below.

Configure above table with input sequential file sf_emp_data.
Step #2: Double click on Column Generator stage following window will pop up.

Here mention the column name which you want to add or generate against Column To Generate. Mention Column Method as Explicit.
Step #3: Now we have to define Metadata for this newly generated column. For this purpose go under Input tab, then column and right click on newly added column i.e. Unique_Id, click on Properties. Following window will pop up.

Here in Properties pane we can add properties like its initial value, by how much value it should get increment, its final value etc. for Unique_Id . Refer above image for example.
Step #4: Do the required output mapping. Refer below image.

Step #5: Compile and Run the job. View Output on target Dataset file ds_trgt_column as shown below.

In this way we have created a new column named Unique_Id having initial value as 3 and incremented by 1 for next record. This column will help to distinguish records as ID column has some repeated values in above table.
This stage is specially used for testing purpose. We are going to study this stage step by step in detail with one simple example or job.
Step #1: Design your job design like below.

Sort stage is just used to sort the created records for simplicity purpose.
Step #2: Double click on Row Generator stage following window will pop up. Here just mention the Number Of Records want to generate.

Step #3: Mention the column names with Metadata to generate the records. See the below image for reference.

You can set the properties of the each column in Edit Column Meta Data as we have discussed in Step 3 of Column Generator article above.
Step #4: Compile and Run the job. View Output on target sequential file sf_tgt_se. You will get the following output.

As we set Increment value 1 for each column, you can see each column value is increased by 1. As we didn’t specify any Initial Value for any column, it takes default value which you can notice in above output. For String column, the repetition of characters depends upon the length specified for that column.
1. Column Generator:
It’s a Development/Debug stage which has one input link and one output link. This stage adds column value for each record. Let’s study this stage in detail with following example.Consider following Table
ID
|
Fname
|
Lname
|
Loc
|
LanID
|
Email
|
Date
|
1
|
Jach
|
Simmons
|
LA
|
JS524
|
Letsc@gmail.com
|
20140101
|
2
|
Shumas
|
Jane
|
Las
|
Sj145
|
Jaene@ymail.com
|
20130623
|
3
|
Jonty
|
Waughn
|
Syd
|
JW927
|
JontyW@sdbh.com
|
20131123
|
3
|
Suhana
|
Safar
|
Mexico
|
SS99
|
Sas@gmail.com
|
20130631
|
4
|
Abc
|
Cde
|
Mex
|
ab254
|
lmn@gmail.com
|
20131225
|
4
|
Shumas
|
Jane
|
Jane
|
Sj145
|
Jaene@ymail.com
|
20130625
|

Configure above table with input sequential file sf_emp_data.
Step #2: Double click on Column Generator stage following window will pop up.

Here mention the column name which you want to add or generate against Column To Generate. Mention Column Method as Explicit.
Step #3: Now we have to define Metadata for this newly generated column. For this purpose go under Input tab, then column and right click on newly added column i.e. Unique_Id, click on Properties. Following window will pop up.

Here in Properties pane we can add properties like its initial value, by how much value it should get increment, its final value etc. for Unique_Id . Refer above image for example.
Step #4: Do the required output mapping. Refer below image.

Step #5: Compile and Run the job. View Output on target Dataset file ds_trgt_column as shown below.

In this way we have created a new column named Unique_Id having initial value as 3 and incremented by 1 for next record. This column will help to distinguish records as ID column has some repeated values in above table.
2. Row Generator:
We have seen Column Generator stage in above article. Here we are going to discuss about Row generator Stage in Datastage.This stage is specially used for testing purpose. We are going to study this stage step by step in detail with one simple example or job.
Step #1: Design your job design like below.

Sort stage is just used to sort the created records for simplicity purpose.
Step #2: Double click on Row Generator stage following window will pop up. Here just mention the Number Of Records want to generate.

Step #3: Mention the column names with Metadata to generate the records. See the below image for reference.

You can set the properties of the each column in Edit Column Meta Data as we have discussed in Step 3 of Column Generator article above.
Step #4: Compile and Run the job. View Output on target sequential file sf_tgt_se. You will get the following output.

As we set Increment value 1 for each column, you can see each column value is increased by 1. As we didn’t specify any Initial Value for any column, it takes default value which you can notice in above output. For String column, the repetition of characters depends upon the length specified for that column.
No comments:
Post a Comment