You are on page 1of 47

AGENDA for

today :
1. Introduction to Operand
menu
2. DS Basic functions
3. Macros
4. Transforms
5. Routines
6. Simple case study
7. Functions

Operand menu :
In transformer stage to do the coding in d
Constraints, declaration of system variab

DS Functions :

These functions are developed by Basic l


for Datastage
These are mostly used in job controls.
These basic functions are divided into
1. DSgetprojectInfo
2. DSgetjobInfo
3. DSgetstageInfo
4. DSgetlinkInfo

DS Functions from operand menu :

Macros in operand menu :

These macros depends on the type of

Macros :

DSGetprojectI
nfo :
1.DSHostname
2.DSProjectName
3.DSJoblist

Syntax: Result = DSGetProjectInfo


(Info Type)

DSGetjobInfo
:
1.DSJobStatu
s
2.DSJobName
3.DSJobContr
oller
4.DSJobStartT
ime
Syntax: Result = DSGetJobInfo
(JobHandle,Info Type)

DSGetStageI
nfo :
1. DSStageName
2.
DSStageLastErr
3. DSStageType
4.
DSStageInRowNu
m
Syntax: Result
= DSGetStageInfo (JobHandle,
5. DSStageVarList
Stage Name, Info Type)

DSGetLinkInf
o:
1.
DSLinkRowCount
2. DSLinkLastErr
3. DSLinkName

Syntax:

Result = DSGetLinkInfo (JobHandle, Stage Name,


Link Name, Info Type)

DS Transforms :

These transforms converts the inpu


one form to another form.
These are two types
1.Built-in
2.SDK

DS Transforms in operand menu :

Built-in Transforms :

We can view the definitions of the buil


Using the Datastage manager.
These are again
divided into
1.String
2.Date
3.Null

String :
1.CAPITALS ("monday feb 14th") => "Monday
Feb 14th
2.DIGITS ("123abc456") =>"123456
3.LETTERS ("123abc456") =>"abc"

Date :
Transform
Input Type
Type
1.TIMESTAMP.TO.DATE Timestamp
2. TAG.TO.DATE

DATE.

Output
Date
TAG Date

Ex:

1.TIMESTAMP.TO.DATE("1996-12-05 13:46:21") =>"


2. TAG.TO.DATE("1993-02-14")=> 9177

SDK TRANSFORMS :
DATATYPE :
1. DataTypeAsciiPic9
integer.
2. DataTypePic9
EBCDIC PIC

String

Number Converts ASCII PIC 9(n) into an


String

Number

Converts ASCII or

9(n) into an integer.


Key Management Transforms
:

1. KeyMgtGetMaxKey
String,
the max
String,
column value in
String,

STRING

Gives

Routines :

A bunch of instructions in basic langu


routines.
These will not give any return value.
These are three types
1.Built-in
2.SDK
3.Examples

Routines in operand menu :

Built-in routines :
1.DSSendMail: This routine is an interlude to
the local send mail program.
2. DSWaitForFile: This routine is called to
suspend a job until a named job either exists,
or does not exist.

Writing Custom routines :

Case study on sequence generator :

In the output we will create sequence by


1. Routines
2. System variables
3. Oracle sequences

By using the
routines
:
We
generate sequence by
1. Keymgtget next value
2. KeyMgtNextValueConcurren

By using the Oracle


Sequences :

Comparison between
these above :
SNO

Procedure used to generate sequence


numbers

Time taken to generate 50000


numbers

1.

Usage of KeyMgtNextValueConcurrent

4min and 11sec

2.

Usage of KeyMgtNextValue

4min and 11sec

3.

Usage of Oracle Sequence

7min and 30sec

Functions :

Subset of routines are called as function


1.String
2.Mathemati
cal
3.Logical
3.Date &
Time
4.Null
5.Trim
6.Number
7.Raw
8.Type
Syntax:
FunctionName
(argument, argument )
conversion

Functions in operand menu :

Date Functions :

1. Iconv ( Date to internal format )


2. Oconv ( Internal format to date
EX:
DATE=ICONV("02-23-85","D")=6264

DATE=OCONV (12th April 2002 ,"D4") =12

AGENDA for
today :
1.Variable
2. Types of variables
3.Environmental variable
4.System variable
5.Stage variable
6.Execution order
7.How remove duplicates

Variabl
e:
It is temporary memory area to stor
1.Initiation
2.Condition check
3.Incriment
Example in programming languages :
C=0; C<10; C++

Types of
Variables :
1.Environmental variable (Global
2.System variable
3.Stage variable

Environmental
Variables :
The scope of the environmental vari
project .

Ex
:

1.$path
2.$apt_config_file

These env variable stored in


DSenv file.

Local
Variables :
1.Stage variables
2.System variables
3.Link variables

System
Variable :

These are predefined


variables in Datastage
transformer .
Examples:

@DATE The internal date when the program started. See the Date fu

@DAY The day of the month extracted from the value in @DATE.

@FALSE The compiler replaces the value with 0.

@WHO ,@INROWNUM , @OUTROWNUM

Stage
Variable :
These are the local variables to handle th
changed values.
By using these stage variables :

Ex for Stage
Variable :

Execution order in
transformer stage :
Environmental variable
Stage variable
Constraints
Derivations

Remove duplicates with


transformer stage :
Step:1Create two stage variable a, b
Step Derivation for a = b
:2
Step Derivation for b = key column
:3
Step Define constraint as a<>b
:4

Thank u..

You might also like