DataStage Functions
DataStage Functions
Functions
This appendix describes the functions that are available from the expression editor under the Function menu item. You would typically use these functions when defining a column derivation in a Transformer stage. The functions are described by category. This set includes functions that take string arguments or return string values. If you have NLS enabled, the arguments strings or returned strings can be strings or ustrings. The same function is used for either string type. The only exceptions are the functions StringToUstring () and UstringToString ().
Description
Returns a date by adding an integer to a baseline date Returns a date from the given julian date Returns the number of days from source date to the given date Returns the hour portion of a time
Arguments
number (int32) [baseline date] juliandate (uint32) source_date given_date time
Output
date
DateFromJulianDay DaysSinceFromDate
HoursFromTime
hours (int8)
B-1
Functions
Name
JulianDayFromDate MicroSecondsFromTime
Description
Returns julian day from the given date Returns the microsecond portion from a time Returns the minute portion from a time Returns the day of the month given the date Returns the month number given the date Returns the date of the specified day of the week soonest after the source date Returns the date of the specified day of the week most recent before the source date Returns the second portion from a time Returns the number of seconds between two timestamps Returns the system time and date as a formatted string Returns the time given the number of seconds since midnight Returns a timestamp form the given date and time Returns the timestamp from the number of seconds from the base timestamp Returns a timestamp from the given unix time_t value Returns a unix time_t value from the given timestamp
Arguments
date time
Output
julian date (int32) microseconds (int32) minutes (int8) day (int8) month number (int8) date
PreviousWeekdayFromDate
date
SecondsFromTime SecondsSinceFromTimestamp
TimeDate
TimeFromMidnightSeconds
seconds (dfloat)
TimestampFromDateTime
timestamp
TimestampFromSecondsSince
timestamp
TimestampFromTimet
timet (int32)
timestamp
TimetFromTimestamp
timestamp
timet (int32)
B-2
Functions
Name
WeekdayFromDate
Description
Returns the day number of the week from the given date. Origin day optionally specifies the day regarded as the first in the week and is Sunday by default Returns the day number in the year from the given date Returns the year from the given date Returns the week number in the year from the given date
Arguments
date [origin day]
Output
day (int8)
YeardayFromDate
date
day (int16)
YearFromDate YearweekFromDate
date date
Date, Time, and Timestamp functions that specify dates, times, or timestamps in the argument use strings with specific formats: For a date, the format is %yyyy-%mm-%dd For a time, the format is %hh:%nn:%ss, or, if extended to include microseconds, %hh:%nn:%ss.x where x gives the number of decimal places seconds is given to. For a timestamp the format is %yyyy-%mm-%dd %hh:%nn:%ss, or, if extended to include microseconds, %yyyy-%mm-%dd %hh:%nn:%ss.x where x gives the number of decimal places seconds is given to. This applies to the arguments date, baseline date, given date, time, timestamp, and base timestamp. Functions that have days of week in the argument take a string specifying the day of the week, this applies to day of week and origin day.
B-3
Logical Functions
Functions
Logical Functions
The following table lists the functions available in the Logical category (square brackets indicate an argument is optional):
Name
Not
Description
Returns the complement of the logical value of an expression Returns the bitwise AND of the two integer arguments Returns the bitwise OR of the two integer arguments Returns the bitwise Exclusive OR of the two integer arguments Returns a string containing the binary representation in "1"s and "0"s of the given integer Returns the integer made from the string argument, which contains a binary representation of "1"s and "0"s. Returns an integer with specific bits set to a specific state, where origfield is the input value to perform the action on, bitlist is a string containing a list of comma separated bit numbers to set the state of, and bitstate is either 1 or 0, indicating which state to set those bits.
Arguments
expression
Output
Complement (int8)
BitAnd
number (uint64)
BitOr
number (uint64)
BitXOr
number (uint64)
BitExpand
number (uint64)
string
BitCompress
number (string)
number (uint64)
SetBit
number (uint64)
B-4
Functions
Mathematical Functions
Mathematical Functions
The following table lists the functions available in the Mathematical category (square brackets indicate an argument is optional):
Name
Abs Acos
Description
Absolute value of any numeric expression Calculates the trigonometric arc-cosine of an expression Calculates the trigonometric arc-sine of an expression Calculates the trigonometric arc-tangent of an expression Calculates the smallest integer value greater than or equal to the given decimal value Calculates the trigonometric cosine of an expression Calculates the hyperbolic cosine of an expression Outputs the whole part of the real division of two real numbers (dividend, divisor) Calculates the result of base 'e' raised to the power designated by the value of the expression Calculates the absolute value of the given value Calculates the largest integer value less than or equal to the given decimal value Calculates a number from an exponent and mantissa Returns the absolute value of the given integer
Arguments
number (int32) number (dfloat)
Output
result (dfloat) result (dfloat)
Asin
number (dfloat)
result (dfloat)
Atan
number (dfloat)
result (dfloat)
Ceil
number (decimal)
result (int32)
Cos
number (dfloat)
result (dfloat)
Cosh Div
Exp
number (dfloat)
result (dfloat)
Fabs Floor
Ldexp
result (dfloat)
Llabs
result (int64)
B-5
Mathematical Functions
Functions
Name
Ln
Description
Calculates the natural logarithm of an expression in base 'e' Returns the log to the base 10 of the given value Returns the greater of the two argument values Returns the lower of the two argument values Calculates the modulo (the remainder) of two expressions (dividend, divisor) Negate a number Calculates the value of an expression when raised to a specified power (expression, power) Return a psuedo random integer between 0 and 2321 Returns a random number between 0 232-1 Calculates the trigonometric sine of an angle Calculates the hyperbolic sine of an expression Calculates the square root of a number Calculates the trigonometric tangent of an angle Calculates the hyperbolic tangent of an expression
Arguments
number (dfloat)
Output
result (dfloat)
number (dfloat) number 1 (int32) number 2(int32) number 1 (int32) number 2 (int32) dividend (int32) divisor (int32)
Neg Pwr
Rand
result (uint32)
Random Sin
number (dfloat)
Tanh
number (dfloat)
result (dfloat)
B-6
Functions
Description
Returns true when an expression does not evaluate to the null value Returns true when an expression evaluates to the null value Change an in-band null to out of band null Returns an empty string if input column is null, otherwise returns the input column value Returns zero if input column is null, otherwise returns the input column value Returns specified value if input column is null, otherwise returns the input column value Assign a null value to the target column
Arguments
any
Output
true/false (int8)
IsNull
any
true/false (int8)
MakeNull
NullToEmpty
NullToZero
input column
NullToValue
SetNull
true = 1 false = 0
Number Functions
The following table lists the functions available in the Number category (square brackets indicate an argument is optional):
Name
MantissaFromDecimal
Description
Returns the mantissa from the given decimal
Arguments
number (decimal)
Output
result (dfloat)
B-7
Raw Functions
Functions
Name
MantissaFromDFloat
Description
Returns the mantissa from the given dfloat
Arguments
number (dfloat)
Output
result (dfloat)
Raw Functions
The following table lists the functions available in the Raw category (square brackets indicate an argument is optional):
Name
RawLength
Description
Returns the length of a raw string
Arguments
input string (raw)
Output
Result (int32)
String Functions
The following table lists the functions available in the String category (square brackets indicate an argument is optional):
Name
AlNum
Description
Return whether the given string consists of alphanumeric characters Returns 1 if string is purely alphabetic Return the string after reducing all consective whitespace to a single space Compares two strings for sorting
Arguments
string (string)
Output
true/false (int8)
Alpha CompactWhiteSpace
Compare
result (int8)
ComparNoCase ComparNum
Case insensitive comparison of two strings Compare the first n characters of the two strings
string1 (string) string2 (string) string1 (string) string2 (string) length (int16)
result (int8)
B-8
Functions
String Functions
Name
Convert
Description
Converts specified characters in a string to designated replacement characters Count number of times a substring occurs in a string Count number of delimited fields in a string Change all uppercase letters in a string to lowercase Enclose a string in double quotation marks Return 1 or more delimited substrings
Arguments
fromlist (string) tolist (string) expression (string) string (string) substring (string) string (string) delimiter (string) string (string) string (string) string (string) delimiter (string) occurrence (int32) [number (int32)]
Output
result (string)
Count
result (int32)
Dcount
result (int32)
Index
string (string) substring (string) occurrence (int32) string (string) number (int32)
result (int32)
Left
result (string)
Length of string in characters Return 1 if string can be converted to a number Return the string padded with the optional pad character and optional length Rightmost n characters of string
string (string) string (string) string (string) padlength (int32) string (string) number (int32)
Right
result (string)
Soundex
Returns a string which identifies a set of words that are (roughly) phonetically alike based on the standard, open algorithm for SOUNDEX evaluation Return a string of N space characters Enclose a string in single quotation marks Repeat a string
string (string)
result (string)
B-9
String Functions
Functions
Name
StripWhiteSpace Trim
Description
Return the string after stripping all whitespace from it Remove all leading and trailing spaces and tabs plus reduce internal occurrences to one
Arguments
string (string) string (string) [stripchar (string)] [options (string)]
Output
result (string) result (string)
Remove all trailing spaces and tabs Remove all leading spaces and tabs Returns a string with leading and trailing whitespace removed Change all lowercase letters in a string to uppercase
string (string)
result (string)
L Removes leading occurrences of character. T Removes trailing occurrences of character. B Removes leading and trailing occurrences of character. R Removes leading and trailing occurrences of character, and reduces multiple occurrences to a single occurrence. A Removes all occurrences of character. F Removes leading spaces and tabs. E Removes trailing spaces and tabs. D Removes leading and trailing spaces and tabs, and reduces multiple spaces and tabs to single ones.
B-10