Datastage - Basic Programming-1
Datastage - Basic Programming-1
1
Objective
• Constant , Variables
• Functions
• Subroutines
• Operators
• Reserved Words
• System Variables
• Compiler Directives
• Job Control
• Examples
• Basic Rules
2
Constants
3
Variables
• Variables are used for storing values in memory temporarily. You can then
use the values in a series of operations.
The value of a variable can be:
• Unassigned
• A string
• An integer or floating-point number
• The null value
• A dimensioned array
• A file variable
4
Dimensioned Arrays
For example:
5
Functions
6
Statements
Functionality
• Changing program control.( for example, calling a Subroutine, or
defining a loop.)
• Assigning a value to a variable.
• Specifying the value of a constant.
• Adding comments to programs.
7
Labels
• Statement Labels -
8
Subroutines
9
Subroutines
10
Special DataStage BASIC Subroutines
11
Operators
12
Arithmetic Operators
13
Concatenating Strings
• The concatenation operator, : or Cats, links string expressions
to form compound string expressions.
• Let X = “Tarzan”
Expression
– "Hello. " : "My Name is " : X : ". What’s yours?“
• Evaluates to:
– “Hello. My name is Tarzan. What’s yours?"
Expression
– "There are " : "2" + "2" : "3" : " windows.“
• Evaluates to:
– "There are 43 windows.“
14
Extracting Substrings
15
Relational Operators
16
If Operators
17
Logical Operators
Numeric data, string data, and the null value can function as
logical data:
• The numeric value 0, is false; all other numeric values are
true.
• An empty string is false; all other character strings are true.
• The SQL null value is neither true nor false. It has the
logical value of null.
• And (or the equivalent &)
• Or (or the equivalent !)
• Not (inverts a logical value)
18
Reserved Words
19
System Variables
20
System Variables
21
Assignment Operators
22
BASIC Functions and Statements
Compiler Directives
Compiler directives are statements that determine how a routine or transform is
compiled.
To do this… Use this…
• Add or replace an identifier $Define
• Remove an identifier $Undefine
• Specify conditional compilation $IfDef and $IfNDef
• Include another program $Include
23
Compiler Directives-Example
24
Job Control
• Allows other jobs to be run and controlled from the first job
• Can be used for getting status information on the current job ,these are
useful in active stage expressions and before- and after-stage subroutines.
25
Job Control
26
Program Control
To do this… Use this…
27
Data Formatting
28
Example Case- End Case
29
Example Cats, Char
30
Example Convert ,Count
31
Example Date
32
Example For…. Next
Example
33
Example Gosub
Example
34
Example If ….Then….End
35
Example GoTo
Example GoTo
Example GoSub
36
Basic Rules
37