Senarios Ds

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 31

1.

I have a file having CITY column having 100 records I want the Target as First letter
starts with A and B and Remaining records as a rejected output.
2. I have a source file like this I want out put as like
Source file
Target1
10
10
20
20
10
30
10
Target2
10
10
20
10
30
20
3. I have a source file like this I want out put as like
Source file
Target1
10
10
20
20
10
10
Target2
10
30
20
30
4. I have a source file like this I want out put as like
Source file
Target1
10
10
20
20
10
10
10
10
10
20
20
Target2
30 30

5. I have a source file like this I want out put as like without using link petitioner
Source file
Target1
1
1
2
4
3
7
4
Target2
5
2

6
7
8
9 3

5
8
Target3

6. I have a source file like this I want out put as like without using link petitioner

Source file
1
2
3
4
5
6
7
8
9

Target1
even records
Target2
odd records

7. I want the count of the Each department number with out using Aggregator
Source File:
Target
DEPTNO, SAL

Count

10, 1000
10, 1100
10, 1200
20, 1100
20, 1200
30, 1200
30, 1300
30, 1400

1
2
3
1
2
1
2
3

8. I want the sum of the Each department number salary with out using Aggregator
Source File:
Target
DEPTNO, SAL

Count

10, 1000
10, 1100
10, 1200
20, 1100
20, 1200
30, 1200
30, 1300
30, 1400

1000
2100
3300
1100
2300
1200
2500
3900

9. I want the count of Each Deptno and Avg sal for Each Deptno using Aggregator

10. I want the count of the Each department number


Source File:
Target
DEPTNO, SAL

Deptno, Sum_Sal

10, 1000
10, 1100
10, 1200
20, 1100
20, 1200
30, 1200
30, 1300
30, 1400

10, 3300
20, 2300
30, 3900

11. Find The Output With out PIVOTE stage


Source File:
SNO, MATHS, PHYSICS, CHEMISTRY
101, 70, 80, 90
102, 65, 55, 75

Target
SNO, MARKS
101, 70
101, 80
101, 90
102, 65
102, 55
102, 75

12.
Source:
EMPNO, SAL
101, 1000
101, 1100
101, 1000
101, 10000
102, 1100
102, 1300
102, 1200
102, 1500

Target
Empno,jan,feb,mar,april
101, 1000, 1100, 1000, 10000
102, 1100, 1300, 1200, 1500

Source File:
EMPNO, SAL
101, 1000
101, 1100
101, 1000
101, 10000
102, 1100
102, 1300
102, 1200
102, 1500

Target
Empno, Format
101, 1000
101, 1000, 1100
101, 1000, 1100, 1000
101, 1000, 1100, 1000, 10000
102, 1100
102, 1100, 1300
102, 1100, 1300, 1200
102, 1100, 1300, 1200, 1500

13.

14.

Source File:
DEPTNO, SAL
10, 1000
10, 1100
10, 1200
20, 1100
20, 1200
30, 1200
30, 1300
30, 1400

Target1:
How to Capture Third Duplicate
from Each Deptno?

Source File:
DEPTNO, SAL
10, 1000
10, 1100
10, 1200
20, 1100
20, 1200
30, 1200
30, 1300
30, 1400

Target
Deptno,count,padding,padding
10,1,00001000,0010
10,2,00001100,0010
10,3,00001200,0010
20,1,00001100,0020
20,2,00001200,0020
30,1,00001200,0030
30,2,00001300,0030
30,3,00001400,0030

Source File:
DEPTNO, SAL
10, 1000
10, 1100
10, 1200
20, 1100
20, 1200
30, 1200
30, 1300
30, 1400

Target
Deptno,count,sum_Sal,padding
10,1,1000,0010
10,2,2100,0010
10,3,3300,0010
20,1,1100,0020
20,2,2300,0020
30,1,1200,0030
30,2,2500,0030
30,3,3900,0030

Source File:
Empno, Ename, Date
100, sudheer, 2010-1-5
101, kumar, 2010-10-2
103, lsk, 2010-1-2

Target
Empno, Ename, Date
100, sudheer, 2010-01-05
101, kumar, 2010-10-02
103, lsk, 2010-01-02

Source File:
Empno, Ename, Date
100, sudheer, 2010-01-05

Target
Empno, Ename, Date
100, sudheer, 2010-1-5

Target2:
Remaining records as a Rejected
output

15.

16.

17.

18.

101, kumar, 2010-10-02


103, lsk, 2010-01-02

101, kumar, 2010-10-2


103, lsk, 2010-1-2

Source File:

Target

Empno, Ename, Email


100, sudheer, sudheer@gmail.com
101, kumar, lsk.4a4@gmail.com
102, lsk, sudheer.4a4@gmail.com

Empno, Ename, Email


100, sudheer, sudheer
101, kumar, lsk.4a4
102, lsk, sudheer.4a4

19.

20. I want the out put like this


Source File
EMPNO, ENAME, MGRNAME
101, Siva, Thiru
102, Thiru, Gandhi
21. I want the out put like this
Source File
File1
File2 File3
1
11
25
2
12
26
3
13
27
:
:
:
:
:
:
10
25
40
22. I want the out put like this
Source File
Empno, Ename, Detno,Sal, City

Target File
EMPNO, ENAME, MGRNAME
101, Shiva,Thiru,Gandhi
102, Thiru, Gandhi, Gandhi
Target
File1 count File2 count File3 count
1
1
11
1
25
1
2
2
12
2
26
2
3
3
13
3
27
3
:
:
:
:
:
:
:
:
:
:
:
:
10
10
25
15
40 15
Target
File1
City name starts with A
File2
Empno, Ename, Deptno, Max_Sal, City
File3
<>File1 and <>File 2

23. In my Target, I have 10 records but I want to store only one record. (Ex: 5th Record)

24. I want the out put like this


Source File:
Year

q1sales

q2sales

q3sales

q4sales

2000

8000

9000

7000

6000

2001

4000

5000

2000

3000

2002

1000

2000

4000

8000

Target:
2001

2002 2003

q1

q1

q1

q2

q2

q2

q3

q3

q3

q4

q4

q4

25. I have a sequential file stage and transformer after that the data is going to target as :
containing name start with s
Source File:
Empno, Ename, Sal, Deptno
100, sudheer, 1000, 10
101, kumar, 5000, 10
102, sudha, 2000, 20
103, manu, 6000, 30
104, suresh, 10245, 40

26.
Source File
Eid

Ename

Target
Format

1-A,B,C

2-D,F

3-E

27.
Source File

Target

Eid

Ename

Format

2-D

3-E

1-A

28.
Source File
Chaar
sudheer
kumar
lak
manu
madhu
manoj
29.
Source File

o/p:target

a3

aaa

b4

bbbb

c5

ccccc

30.
Source File

Target:

Jan Feb Mar


1
4
6

Jan=11

Feb=11

Mar=13

31.
Source

Target

Calname-varchar

Calname-varchar

mphasis

MphasiS

satyam

SatyaM

techmahindra

TechmahindrA

wipro

WiprO

ibm

IbM

32. My source file is sequential file,in sequential file records is a,b,c,d,1,2,3.The expected output is abcd,1
abcd,2
abcd,3

33.

In my Source File:
a,b,c,d
x,y,t,l

Here a,b,c,d are columns and x,y,t,l are data in them.


Now I want in this place of t the value as p.Do it in datastage and unix
34. I/p source
-----------cid, acc1, acc2, amou1, amou2
10, SBI, ICICI, 10000, 20000

O/p target
------------1target: 10, SBI, 10000
2target: 10, ICICI, 20000

35. I have file like this


i/p
Name, seq, desc
DWH, 02, ware
DWH, 01, data
DWH, 03, house
TCS, 01, Tata
TCS, 03, services
TCS, 02, consultancy
and I want the output like this
TCS
Tataconsultancy services
DWS Dataware house
36.
Sourec File

Target

Phdetails

phddetails

3129985603912

312-9985603912

254625621365
123456789

254-625621365
123456789

37.
Sourec File

Target

Phdetails

phdcode

phdnumber

312-9985603912

312

9985603912

2546-25621365

2546

25621365

123456789

000

123456789

38. How to Remove The 3rd Record From Source usung source file Stage?
39. Create a datastage job for following output.(with out any warning or fatal error).

SOURCE:
EMPNO

TARGET:
DEPTNO

100
101
102
103
104
105
106

10
20
30
20
20
30
10

DEPTNO

COUNT

10
20
30

2
3
2

40. Create a datastage job for increasing the employee salary (i.e., 10% increment for deptno=10,
12.5% for deptno=20 and 14.25% for deptno=30).
41. Create a datastage job for following output. (with out using Transformer)
Source having 5 records, target 3files also should have 5 records.
SOURCE:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

101

20

102

22-JUL-1997

102

30

103

16-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

TARGET1:

TARGET2:

TARGET3:

1file

2file

3file

EMPNO DEPTNO

EMPNO

MGR

EMPNO

HIREDATE

100

10

100

101

100

10-JAN-1999

101

20

101

102

101

22-JUL-1997

102

30

102

103

102

16-AUG-1996

103

20

103

104

103

05-DEC-1995

104

30

104

NULL

104

30-OCT-1992

42. Create a datastage job for getting unique records to target.


SOURCE:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

101

20

102

22-JUL-1997

102

30

103

16-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

102

30

103

17-AUG-1996

103

20

104

06-DEC-1995

100

10

101

12-JAN-1999

Here EMPNO is key column (observe hiredate)


TARGET:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

101

20

102

22-JUL-1997

102

30

103

16-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

43. Create a datastage job for getting unique records to target.


SOURCE:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

101

20

102

22-JUL-1997

102

30

103

16-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

102

30

103

17-AUG-1996

103

20

104

06-DEC-1995

100

10

101

12-JAN-1999

Here EMPNO is key column (observe hiredate)


TARGET:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

12-JAN-1999

101

20

102

22-JUL-1997

102

30

103

17-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

44. Create a datastage job for create sequence numbers. ( From 234)
SOURCE:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

101

20

102

22-JUL-1997

102

30

103

16-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

SEQNO

EMPNO

DEPTNO

MGR

HIREDATE

234

100

10

101

10-JAN-1999

235

101

20

102

22-JUL-1997

236

102

30

103

16-AUG-1996

237

103

20

104

05-DEC-1995

238

104

30

NULL

30-OCT-1992

TARGET:

45. Create a datastage job for create sequence numbers. ( From 345 increment by 10)
SOURCE:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

101

20

102

22-JUL-1997

102

30

103

16-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

SEQNO

EMPNO

DEPTNO

MGR

HIREDATE

345

100

10

101

10-JAN-1999

355

101

20

102

22-JUL-1997

365

102

30

103

16-AUG-1996

375

103

20

104

05-DEC-1995

385

104

30

NULL

30-OCT-1992

TARGET:

46. Create a datastage job for separate the employees by deptno.(with out using Transformer). (create
multiple jobs with different stages)
SOURCE:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

101

20

102

22-JUL-1997

102

30

103

16-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

102

30

103

17-AUG-1996

103

20

104

06-DEC-1995

100

10

101

12-JAN-1999

EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

100

10

101

12-JAN-1999

EMPNO

DEPTNO

MGR

HIREDATE

101

20

102

22-JUL-1997

103

20

104

05-DEC-1995

103

20

104

06-DEC-1995

EMPNO

DEPTNO

MGR

HIREDATE

102

30

103

16-AUG-1996

104

30

NULL

30-OCT-1992

102

30

103

17-AUG-1996

TARGET10:

TARGET20:

TARGET30:

47. Create a datastage job for arranging ascending and descending order of employees by their
respective deptno.
SOURCE:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

101

20

102

22-JUL-1997

102

30

103

16-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

102

30

103

17-AUG-1996

103

20

104

06-DEC-1995

100

10

101

12-JAN-1999

TARGET asc:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

100

10

101

12-JAN-1999

101

20

102

22-JUL-1997

103

20

104

05-DEC-1995

103

20

104

06-DEC-1995

102

30

103

16-AUG-1996

104

30

NULL

30-OCT-1992

102

30

103

17-AUG-1996

TARGET desc:
EMPNO

DEPTNO

MGR

HIREDATE

102

30

103

16-AUG-1996

104

30

NULL

30-OCT-1992

102

30

103

17-AUG-1996

101

20

102

22-JUL-1997

103

20

104

05-DEC-1995

103

20

104

06-DEC-1995

100

10

101

10-JAN-1999

100

10

101

12-JAN-1999

48. Create a datastage job for get the following target. (create multiple jobs using different stages)
SOURCE 2 TABLES EMP, DEPT
EMP SOURCE:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

101

20

102

22-JUL-1997

102

30

103

16-AUG-1996

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

108

60

109

10-JAN-2009

DEPT SOURCE:
DEPTNO

DEPTNAME

10

SALES

20

FINANCIAL

30

TELECOM

40

BANKING

50

HEALTH

TARGET:
EMPNO

DEPTNO

DEPTNAME

100

10

SALES

101

20

FINANCIAL

102

30

TELECOM

103

20

FINANCIAL

104

30

TELECOM

108

60

NULL

49. Create a datastage job for generating 50 records(rows).


Each row should have 2 columns like

NO

NAME

10
GNAN
11
GNAN
12
GNAN
13
GNAN
14

50. Create a datastage job for extract only 10 records from the source ( source have 100 records)(create
multiple jobs using different stages)
51. Create a datastage job for decrement the salaries of emp by 5% whose deptno not in the DEPT
table.
52. Create a datastage job for combining the data from more than 2 files.
SOURCE10:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

100

10

101

12-JAN-1999

EMPNO

DEPTNO

MGR

HIREDATE

101

20

102

22-JUL-1997

103

20

104

05-DEC-1995

103

20

104

06-DEC-1995

EMPNO

DEPTNO

MGR

HIREDATE

102

30

103

16-AUG-1996

104

30

NULL

30-OCT-1992

102

30

103

17-AUG-1996

EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

100

10

101

12-JAN-1999

101

20

102

22-JUL-1997

103

20

104

05-DEC-1995

103

20

104

06-DEC-1995

102

30

103

16-AUG-1996

104

30

NULL

30-OCT-1992

SORUCE20:

SORUCE30:

TARGET:

102

30

103

17-AUG-1996

53. Create a datastage job for following output


SORUCE:
EMPNO

DEPTNO

MGR

HIREDATE

100

10

101

10-JAN-1999

103

20

104

05-DEC-1995

104

30

NULL

30-OCT-1992

TARGET: (single column)


EMPNO+DEPTNO+MGR+HIREDATE
100+10+101+10-JAN-1999
103+20+104+05-DEC-1995
104+30+NULL+30-OCT-1992

54. Create a datastage job for following output by using following source
SORUCE: (single column)
EMPNO+DEPTNO+MGR+HIREDATE
100+10+101+10-JAN-1999
103+20+104+05-DEC-1995
104+30+NULL+30-OCT-1992
TARGET:
EMPNO

MGR

100

101

103

104

104

NULL

55 . Create a sequence job for above 55a and 55b jobs. For 55a job input is 55b job output.
56. Create a datastage job for compare two datasets and observe new record, update record and delete
record.
Before Dataset:
SSN

NAME

ADDRESS

A123 John

Boston, US

B234 Michael

Minneapolis, US

C345 Smith

Michigan, US

D456 Clark

New York, US

After Dataset:
SSN

NAME

ADDRESS

A123 John

New jersy, US

B234 Michael

Minneapolis, US

D456 Clark

New York, US

E567 Gnan

Mumbai, IND

F678 Ganesh

Hyderabad, IND

57. Create a datastage job for extract only last 10 records from the source (source have 100 records)
58. If I want information in a separate file for your job name, invocation id, job start date time, host,
project name. How will you do this?
59. Source file/table having 1 Lakh records. I want to write 10% of these records into separate file/table
(with out using transformer). How will you do this?

Answers for scenarios

1)

sq

filter

ds
Here sq means sequence file

In filter we writing condition


filter
where classes= city like A%
and
where classes= city like B%

2)

target1

Sq

sort

filter

Reject data
Target 2
Sort:In sort we can use
Create key change column=true
Filter :Where classes= key change=1
Where classes= key change=0

3)
Aggregater

filter

ds tg1

sq

Aggregater:-

reject

Group=deptno
aggreation
aggregation type=count row
lount output column=count
operation
allow null = false
filter:where classes=count<>1

where classes=count=1
reaming reject data

4)
Sq

copy

lookup

filter1

aggregater
filter2
Copy:First taking copy with that data using agg,lookup give the connection
Agg:Aggregation type=count row
Count output column=count
Fiter1
Where clause=count=1
Filter2
Where clause=<>1
Where clause=1
Looup
In constrain give as a continues, continues
In looup drag & drop same column

T1
5)

sq

transformer
T2

T3
In constrains we can write condition
MOD[@inrownum,3]=0

Here 0 means t1 link,1 means

MOD[@inrownum,3]=1

t2 link in target ,2 means t3

MOD[@inrownum,3]=2
T1
6)

sq

transformer
T2

In constrains we can write condition


MOD[@inrownum,2]=0

Here 0 means t1 link,1 means

MOD[@inrownum,2]<>1

t2 link in target .

7)

sq

transformer
T

Here some much different. We want to create variables in stage variables.


Here s1& s2 are the variable creation in stage variable.
Stage variable
If dslink8.deptno=s2 then S2+1 else 1

S1

Ds link8.deptno

S2

Ds link
Ds link8.deptno

deptno

Ds link8.sal

Sal

S1

8)

targercount

sq

transformer
T

Stage variable
If dslink8.deptno=s2 then s1+ds link8.sal else ds link8.sal

S1

Ds link8.deptno

S2

Ds link
Ds link8.deptno

deptno

Ds link8.sal

Sal

S1

target

10)

agg
sq

target

agg:gourp key =deptno


agg type=calculation
column for calculation=sal
sum output column=sum_sal

11)
Sq

copy

funnel

ds(t)

In copy to funnel we can take the 3 output links.

Copy :Option
Force=false

In output column
Output name
Dslink5
Dslink6

Ds link5) In this place of output columns change in to maths


column write as marks

Dslink7

Ds link5) In this place of output columns


change in to physics column write as marks

Ds link5) In this place of output columns change in to


chemistry column write as marks

Then drag and drop the output data in copy to funnel.


Funnel:Options
Tunnel type=continuous funnel
Output drag and drop to output column then we getting

Target as sno,marks tow columns only.

13) sqt/rtg
Stage variable
If dslink3.deptno=s2 then s1:ds link3.sal else dslink3.sal

S1

Ds link3.deptno

S2

: means concatenation option

Ds link
Ds link3.deptno

Deptno

Ds link3.sal

Sal

S1

Target

15) sqt/rtg
Stage variable
If dslink3.deptno=s2 then s1+1 else 1

S1

Ds link3.deptno

S2

Ds link
Ds link3.deptno

Deptno

S1

Count

Right(str(0,7):dslink3.sal,10)

Padding sum_sal

Right(str(0,7):dslink3.deptno,10)

padding

Here we have the Right(),str(),field(),trim(),left() functions are in


Functions
String operation in the area we have

16) sqt/r tg
Stage variable
If dslink3.deptno=s3 then s1+1 else 1

S1

If Ds link3.deptno=s3 then s2+dslink3.sal else dslink3.sal

S2

Dslink3.deptno

S3

Ds link
Ds link3.deptno

deptno

Ds link3.sal

sal

S1

count

trim(s2,0,R)

sum_sal

Right(str(0,4):dslink3.deptno,4)

padding

17)sqt/r tg
Stage variable
Right(str(0,2):Field(ds link3.date,-,2),2)

S1

Right(0,2):trim(Right(ds link3.date,2):-:L),2)

S2

Ds link
Ds link3.empno

empno

Ds link3.ename

ename

Ds link3.date

Date

S1

Sv_month

s2

sv_date

Left(dslink3.date,4):-:s1:-:s2)

Sv_hire date

19) sqt/rtg

Stage variable
Field(ds link3.email,@,1)

S1

Field(ds link3.email,_,1)

S2

Ds link
Ds link3.deptno

deptno

Ds link3.ename

ename

Ds link3.email

email

S1

Sv_email

s2

sv_email2

21) sqt/rtg
Ds link
Ds link3.d1

D1

@inrownum

Count

Ds link3.d2

D2

@inrownum

Count

Ds link3.d3

D3

@inrownum

Count

22)

filter

copy

terget1

Reference link
Sq

copy

lookup

Terget3

aggreg

copy

sqfiltercopy agglookuptg
Filter:Filter
Where clause=city like A%
agg:grouping key
group=empno
group=ename
group=deptno
group=city
aggregation
aggregation type=calculation
column for calculation=sal
maximum value output column=max_sal

Terget2

lookup table
Empno
Ename
Deptno
City
Max_sal

Empno
Ename
Deptno
City

In lookup condition must have


Constrain
=continue,=continue

26) sqsort --t/r --remove duplicates tg


First we want to sort the data like sort processing stage or (In transformer we have stage
properties at top menu 1st stage properties-input-partitioning- partition type-hash
Sort-perform sort

)
Stage variable

If dslink3.deptno=s2 then s1:,:ds link3.ename else ds link3.ename

S1

Ds link3.deptno

S2

Ds link
Ds link3.deptno

deptno

Ds link3.ename

ename

S1

target

Next Remove duplicates processing stage

Remove duplicates
Key=deptno
Option
Duplicate to retain=last

27) sq--t/r --tg


Stage variable
If dslink3.deptno=s2 then s1 else ds link3.ename

S1

Ds link3.deptno

S2

Ds link
Ds link3.deptno

deptno

Ds link3.ename

ename

S1

target

29) sq--t/r tg
Stage variable
str(s2,ds link3.num)

S1

ds link3.name

S2

Ds link
Ds link3.name

Name

Ds link3.num

num

S1

target

34)sq-t/r-tg

35)
Here we want use processing stages sq,--sort ,---t/r ,--tg
Sort:Key=name
Key=seq
t/r:Stage variable
If dslink7.name=s3 then s1:ds link7.desc else ds link7.desc

S1

Ds link7.name

S3

Ds link
Ds link7.name

Name

Ds link7.seq

Seq

Ds link7.desc

Desc

S1

target

37) sqt/rtg

Stage variable
Field(ds link3.phdetails,-,2)<>s3

S2

Field(ds link3.phdetails, ,2)

S3

If s2=1 then Field(ds link3.phdetails, -,1)else Right(str(0,3),3)

S4

If s2=1 then Field(ds link3.phdetails, -,2)else Field(ds link3.phdetails,-,1)

S5

Ds link
Ds link3.phdetails

Phdetails

S4

Phcode

S5

phnum

You might also like