Using Functions
Total Page:16
File Type:pdf, Size:1020Kb
TIBCO WebFOCUS® Using Functions Release 8207 May 2021 DN4501670.0521 Copyright © 2021. TIBCO Software Inc. All Rights Reserved. Contents 1. How to Use This Manual ...................................................... 17 Available Languages .................................................................17 Operating Systems .................................................................. 17 2. Introducing Functions .........................................................19 Using Functions .....................................................................19 Types of Functions ...................................................................20 WebFOCUS-specific Functions.................................................... 22 Simplified Analytic Functions..................................................... 22 Simplified Character Functions....................................................23 Character Functions.............................................................25 Variable Length Character Functions...............................................28 Character Functions for DBCS Code Pages......................................... 29 Maintain-specific Character Functions..............................................30 Data Source and Decoding Functions..............................................31 Simplified Date and Date-Time Functions...........................................33 Date Functions................................................................. 33 Standard Date Functions................................................... 33 Legacy Date Functions..................................................... 35 Date-Time Functions.............................................................36 Maintain-specific Date and Time Functions......................................... 38 Maintain-specific Standard Date and Time Functions............................38 Maintain-specific Legacy Date Functions......................................39 Simplified Conversion Functions.................................................. 39 Format Conversion Functions.....................................................40 Maintain-specific Light Update Support Functions....................................42 Simplified Numeric Functions.....................................................42 Numeric Functions..............................................................42 Maintain-specific Script Functions.................................................45 Simplified Statistical Functions................................................... 45 Machine Learning (Python-based) Functions........................................ 45 Simplified System Functions......................................................46 System Functions...............................................................47 Using Functions 3 Contents Simplified Geography Functions...................................................49 Character Chart for ASCII and EBCDIC ..................................................50 3. Accessing and Calling a Function ..............................................59 Calling a Function ................................................................... 59 Supplying an Argument in a Function ...................................................61 Argument Types................................................................ 61 Argument Formats.............................................................. 62 Argument Length................................................................63 Number and Order of Arguments..................................................64 Verifying Function Parameters.................................................... 64 Calling a Function From a DEFINE, COMPUTE, or VALIDATE Command .......................67 Calling a Function From a Dialogue Manager Command ...................................68 Assigning the Result of a Function to a Variable.....................................69 Branching Based on the Result of a Function....................................... 70 Calling a Function From an Operating System RUN Command......................... 72 Calling a Function From Another Function ............................................... 73 Calling a Function in WHERE or IF Criteria ...............................................73 Using a Calculation or Compound IF Command......................................75 Calling a Function in WHEN Criteria .................................................... 75 Calling a Function From a RECAP Command .............................................76 Storing and Accessing an External Function ............................................. 78 Storing and Accessing a Function on z/OS..........................................78 Storing and Accessing a Function on UNIX..........................................79 Storing and Accessing a Function on Windows...................................... 79 4. Simplified Analytic Functions ................................................. 81 FORECAST_MOVAVE: Using a Simple Moving Average .....................................81 FORECAST_EXPAVE: Using Single Exponential Smoothing ................................. 87 FORECAST_DOUBLEXP: Using Double Exponential Smoothing ..............................90 FORECAST_SEASONAL: Using Triple Exponential Smoothing ...............................92 FORECAST_LINEAR: Using a Linear Regression Equation ..................................97 PARTITION_AGGR: Creating Rolling Calculations ........................................ 100 PARTITION_REF: Using Prior or Subsequent Field Values in Calculations ....................110 4 Contents INCREASE: Calculating the Difference Between the Current and a Prior Value of a Field ...... 114 PCT_INCREASE: Calculating the Percentage Difference Between the Current and a Prior Value of a Field .......................................................................118 PREVIOUS: Retrieving a Prior Value of a Field ...........................................121 RUNNING_AVE: Calculating an Average Over a Group of Rows ............................ 123 RUNNING_MAX: Calculating a Maximum Over a Group of Rows ........................... 126 RUNNING_MIN: Calculating a Minimum Over a Group of Rows ............................ 129 RUNNING_SUM: Calculating a Sum Over a Group of Rows ................................132 5. Simplified Character Functions .............................................. 135 CHAR_LENGTH: Returning the Length in Characters of a String ........................... 136 CONCAT: Concatenating Strings ......................................................137 DIFFERENCE: Measuring the Phonetic Similarity Between Character Strings ................ 139 DIGITS: Converting a Number to a Character String ......................................142 GET_TOKEN: Extracting a Token Based on a String of Delimiters ..........................144 INITCAP: Capitalizing the First Letter of Each Word in a String .............................145 LAST_NONBLANK: Retrieving the Last Field Value That is Neither Blank nor Missing .........146 LEFT: Returning Characters From the Left of a Character String ...........................148 LOWER: Returning a String With All Letters Lowercase ...................................150 LPAD: Left-Padding a Character String .................................................151 LTRIM: Removing Blanks From the Left End of a String .................................. 153 OVERLAY: Replacing Characters in a String ............................................ 154 PATTERNS: Returning a Pattern That Represents the Structure of the Input String ...........156 POSITION: Returning the First Position of a Substring in a Source String ................... 158 POSITION: Returning the Position of a Search String in a Source String .................... 160 Regular Expression Functions ........................................................161 Using Regular Expressions on z/OS..............................................162 REGEX: Matching a String to a Regular Expression................................. 162 REGEXP_COUNT: Counting the Number of Matches to a Pattern in a String............ 165 REGEXP_INSTR: Returning the First Position of a Pattern in a String...................169 REGEXP_REPLACE: Replacing All Matches to a Pattern in a String.................... 172 REGEXP_SUBSTR: Returning the First Match to a Pattern in a String.................. 174 REPEAT: Repeating a String a Given Number of Times ...................................176 Using Functions 5 Contents REPLACE: Replacing a String .........................................................177 RIGHT: Returning Characters From the Right of a Character String .........................179 RPAD: Right-Padding a Character String ................................................181 RTRIM: Removing Blanks From the Right End of a String .................................183 SPACE: Returning a String With a Given Number of Spaces ...............................184 SPLIT: Extracting an Element From a String ............................................ 185 SUBSTRING: Extracting a Substring From a Source String ................................186 TOKEN: Extracting a Token From a String .............................................. 188 TRIM_: Removing a Leading Character, Trailing Character, or Both From a String ............ 190 UPPER: Returning a String With All Letters Uppercase ................................... 193 6. Character Functions .........................................................195 Character