Professional Documents
Culture Documents
>target
In source i have only one record.
I want 10 records(same record will repeat) in target.
can any one tell me the logic in transformer
Ans: using looping you ca do that to call looping you have to use @ITERATION
declare stgvar=col1
in loop you hav to mention If @ITERATION=1 then stgvar
else if @ITERATION=2 then stgvar and so on till @ITERATION=10
and in output map stgvar to out col
########################################
Que: my seq file 10 columns but in my target i want only 3
coluoumns what we can do?
Ans= 1) only pass 3 col in transformer stage
2->use oracle we can do
3->use copy we can do
4) Use Modify Stage
5)Use filter option of sequential file stage and specify the cut(UNIX)
command.
Ex: cut -d ',' -f1,5,8
(Assuming columns 1, 5 , 8 are to be loaded)
##############################################
#################################
Que: scenario based
Input id
code
------------------
111 01,02,03
222 04,05
Expected output id code
111 01
111 02
111 03
222 04
222 05
FYI, the code column here can have any number of delimited values. Its not
fixed.
ANS: We have to do Column to Row convertion i.e vertical to horizontal
pivotting
use pivot enterprise for this purpose
##############################################
#################################
Que: source has 2 fields like
COMPANY
LOCATION
IBM
HYD
TCS
BAN
IBM
CHE
HCL
HYD
TCS
CHE
IBM
BAN
HCL
BAN
HCL
CHE
LIKE THIS.......
Company
loc
TCS
HYD
count
3
BAN
CHE
IBM
HYD
BAN
CHE
HCL
HYD
BAN
CHE
Ans: sourec ---> aggregate (use group by and take count)-->target
1. lookup stage
2. join stage
3. Merge stage
In lookup stage, only matched records passed to next stage.For example:table A as a source table
table B as a reference
---------------------------------------------------------------------------EID ENAME
EID ESALARY
102 JOHN
103 7000
103 MIKE
---------------------------------------------------------------------------Result will be
EID ENAME ESALARY
103 MIKE 7000
2. In join stage,Not only matched but unmatched records also passed to next
stage depand on which type of join we are using. Suppose if we use left
outer join
table A as a source table
table B as a reference
---------------------------------------------------------------------------EID ENAME
EID ESALARY
102 JOHN
103 7000
103 MIKE
---------------------------------------------------------------------------Result will be
EID ENAME ESALARY
102 JOHN
Output
-----------------------------------------------------------------------------------------id,name
id,name
1,a
1 a,c,e
2,b
2 b,w
1,c
3 f
3,f
1,e
2,w
Ans:
1. Convert column to row. do horizontal pivotting
Seq ---> Horizontal Pivot---->Dataset
2. Sort data based on id and , select key change column = True ( To Generate
Group ids)
in transformer check
create 2 stage var
stg1=name
stg2= if keycolumnchage=1 then stg1 else stg2:',':stg1
map stg2 in name field
Seq-----> Sort-->Tfm----> RM ---->
Dataset
3.You can use create logic in transformer[use link sort ] and the use RD after
that
seq->transformer-->remote duplicate-->dataset
In Transformer stage
STEP1:DO LINK SORT->IT WILL SORT THE DATA IN ASSE ORDER
STEP2:USE STAGE VARIABLE S,S1 AND GIVE THIS CONDITION......
S=
SID1= ID
HERE OUT IS------> ID
NAME
A,C
A,C,E
B,W
In RMDUP stage :
DULICATE RETAIN= LAST
drag column to output dataset
##############################################
###############
Que: convert single column to multiple column
source
----------------------ID
Mobile
1 samsung
1 nokia
1 ercisson
2 iphone
2 motrolla
3 lava
3 blackberry
3 reliance
Expected Output
-------------------------------------ID Mobile1 Mobile2 Mobile3
1
2
3
iphone motrolla
lava
blackberry reliance
And:
1. Convert Row to column Do vertical pivotting
Seq file----> vertical pivot----->TFM2-----> dataset
In vertical pivot mention pivot colum, index , array size
##############################################
######################
Que: How Unix shell scripts used in datastage
Ans:
A) Go to --> job Properties--> select Before-job Subroutine--> as
Execsh--> Under input text box give UNIX command. / FIle path
In Above case UNIX command executed Before the job Execution.
Go to --> job Properties--> select After-job Subroutine--> as
Execsh--> Under input text box give UNIX command.
In Above case UNIX command executed After the job Execution.
#############################################
Que: my input is like below
empno sal
------------------------------ravi 1000
raju 2000
srinu 3000
rao 500
i want o/p like
empno sal
---------------------ravi 1000
ravi 1000
raju 2000
raju 2000
raju 2000
raju 2000
srinu 3000
srinu 3000
srinu 3000
srinu 3000
srinu 3000
srinu 3000
rao 500
can any one explain how can i achieve this
ANS: u can apply pad string in transformer stage
col2
col3
NULL
NULL
col4
col2
col3
col4
NULL
NULL
-----------------------------------------------------------------------------------------------1 a
1 a b c NULL
1b
2 k l m NULL
ac
1 NULL
##############################################
###########################
Que: Input:
Dummy
------a
a
a
O/p: Dummy
------3
Ans: 1. use aggregator stage (count function)
2. With d help of transformer (using stgvar)
##############################################
##
Que: Datastage Real time scenario
source table -----name--- A A B B B C C D In source table data like thi
s but I want traget table like this name count A 1 A 2 B 1 B 2 B 3 C 1 C 2 D 1
pls any one one solve this........
Ans: 1. Using transformer
1st one is using loop variables in transformation.
seq---->aggregator ----> tfm-->out
use aggregator stage or using Database you can take count
take count from aggregator
pass output to tfm.
In looping declation would be:
@ITERATION<=count
Seq
C3
C4
C5
--- -----------------------------
<NULL>
999
1000 12
<NULL>
1000 13
1000 18
<NULL>
1001 5
<NULL>
1001 8
1001 10
<NULL> <NULL>
111
<NULL>
<NULL>
<NULL>
Y
777
666
<NULL>
555
Basically i have sorted it acocrding to id and seq. now i want is the id, last seq
number and the last non-null values for the rest of the columns.
my desired result is
ID Seq C3 C4
C5
--------------------------RUN OK
test_seq
WARNING
test_seq1
FAILED
testseq2
Output :
Jobstatus Jobname
----------------------RUN OK test_seq
WARNING test_seq1
FAILED test_seq3
We are using datastage server jobs.(7.5v) on Windows server.
Ans:
We had splitted the single source link into two links using Transformer
constraints as Mod(@inrownum,2) = 0 into one link(it contains data as
test_seq
test_seq1
test_seq2
and the Mod(@inrownum,2) <> 0 into second link.
RUN OK
WARNING
FAILED
We are not sure how to combine these two links to get my desired output. i.e
Output :
JObstatus Jobname
----------------------RUN OK test_seq
WARNING test_seq1
FAILED test_seq3
Can anyone help me on this.
You can do it the way you specified but would need to add a "key" which
could be the DIV by two.
Alternatively, you keep keep every odd row in a Stage Variable and output on
every even row
Seqfile-------->Transformer------->output
IBM
pooja
TCS
nandini WIPRO 1
krish
IBM
pooja
TCS
Ans:
1. seq--->tfm--->out
curr= name:company
val=if curr <> prev then 1 else val+1
prev=curr
o.p = val
name,company,val
##############################################
######################
QUe: scenario is like i'm having a record 1234"13233434%343434^23232!
1212$23232 in the above record all the special characters must be
removed.how can we do it in datastage 8.0.1.can any one please ans this?
thanx in advance
AnS:
##############################################
###########################
Que: I hav source like this .
deptno,sal
1,2000
2,3000
3,4000
1,2300
4,5000
5,1100
i want target like this
target1
1,2000
3,4000
4,5000
target2
2,3000
1,2300
5,1100 with out using transformer
Ans:
1.
tgt1____
|
source------transformer
|_____tgt2
in transformer
- sal
- sal
##############################################
##############################