+ All Categories
Home > Documents > Transformation Language Reference -...

Transformation Language Reference -...

Date post: 29-Apr-2018
Category:
Upload: doanquynh
View: 216 times
Download: 3 times
Share this document with a friend
234
Transformation Language Reference INFORMATICA ® POWERMART ® 5 INFORMATICA ® POWERCENTER ® 5 (V ERSION 5.1)
Transcript
Page 1: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Transformation Language Reference

INFORMATICA® POWERMART® 5INFORMATICA® POWERCENTER® 5(VERSION 5.1)

Page 2: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Informatica PowerMart/PowerCenter Transformation Language ReferenceVersion 5.1.0 June 2001

Copyright (c) 2001 Informatica Corporation.All rights reserved. Printed in the USA.This software and documentation contain proprietary information of Informatica Corporation, they are provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright law. Reverse engineering of the software is prohibited. No part of this document may be reproduced or transmitted in any form, by any means (electronic, photocopying, recording or otherwise) without prior consent of Informatica Corporation.Use, duplication, or disclosure of the Software by the U.S. Government is subject to the restrictions set forth in the applicable software license agreement as provided in DFARS 227.7202-1(a) and 227.7702-3(a) (1995), DFARS 252.227-7013(c)(1)(ii) (OCT 1988), FAR 12.212(a) (1995), FAR 52.227-19, or FAR 52.227-14 (ALT III), as applicable.The information in this document is subject to change without notice. If you find any problems in the documentation, please report them to us in writing. Informatica Corporation does not warrant that this documentation is error free.Informatica, PowerMart, PowerCenter, PowerChannel, PowerConnect, PowerPlug, PowerBridge, and MX are trademarks or registered trademarks of Informatica Corporation in the United States and in jurisdictions throughout the world. All other company and product names may be trade names or trademarks of their respective owners.Portions of this software are copyrighted by MERANT, 1991-2000.Apache SoftwareThis product includes software developed by the Apache Software Foundation (http://www.apache.org/).The Apache Software is Copyright (c) 1999-2000 The Apache Software Foundation. All rights reserved.Redistribution and use in source and binary forms of the Apache Software, with or without modification, are permitted provided that the following conditions are met:1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.3. The end-user documentation included with the redistribution, if any, must include the following acknowledgment: “This product includes software developed by the Apache Software Foundation (http://www.apache.org/).”Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear.4. The names “Xerces” and “Apache Software Foundation” must not be used to endorse or promote products without prior written permission of the Apache Software Foundation.5. Products derived from this software may not be called “Apache”, nor may “Apache” appear in their name, without prior written permission of the Apache Software Foundation.THE APACHE SOFTWARE IS PROVIDED “AS IS” AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.The Apache Software consists of voluntary contributions made by many individuals on behalf of the Apache Software Foundation and was originally based on software copyright (c) 1999, International Business Machines, Inc.,http://www.ibm.com. For more information on the Apache Software foundation, please see http://www.apache.org/.DISCLAIMER: Informatica Corporation provides this documentation “as is” without warranty of any kind, either express or implied, including, but not limited to, the implied warranties of non-infringement, merchantability, or use for a particular purpose. The information provided in this documentation may include technical inaccuracies or typographical errors. Informatica could make improvements and/or changes in the products described in this documentation at any time without notice.

Page 3: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Table of Contents

������������� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ��

������� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ��

About Informatica Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xii

About this Book . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xiv

About PowerCenter and PowerMart . . . . . . . . . . . . . . . . . . . . . . . . . . .xiv

Document Conventions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv

Other Informatica Resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvi

Accessing the Informatica Webzine . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvi

Visiting the Informatica Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . .xvi

Visiting the Informatica Developer Network . . . . . . . . . . . . . . . . . . . . .xvi

Obtaining Technical Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

New Features and Enhancements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xviii

Version 5.1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xviii

Version 5.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xix

���������������������������������� � � � � � � � � � � � � � � � � � � � � � �

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Transformation Language Components . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Transformation Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

Internationalization and the Transformation Language . . . . . . . . . . . . . . 3

Expression Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Expression Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

General Rules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

Adding Comments to Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

������������������� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �

DD_DELETE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

DD_INSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

DD_REJECT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

�LL L

Page 4: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DD_UPDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

FALSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

NULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Null Values in Aggregate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Null Values in Filter Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

Nulls with Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

TRUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

������������������� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ��

Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Using Arithmetic Operators to Convert Data . . . . . . . . . . . . . . . . . . . . 19

String Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Nulls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

Nulls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

������� ��!������� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �"

System Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

PROC_RESULT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

$$$SessStartTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

SYSDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

SESSSTARTTIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

�������"��#����� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � ��

Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Date/Time Datatype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

Julian Day, Modified Julian Day, and the Gregorian Calendar . . . . . . . . 32

Dates in the Year 2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

Dates in Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Dates in Flat Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

Default Date Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

�LY 7DEOH�RI�&RQWHQWV

Page 5: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Date Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

TO_CHAR Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

TO_DATE and IS_DATE Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . 41

Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

Tips . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Understanding Date Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

�������$��%��������� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �

Function Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

Aggregate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

Aggregate Functions and Nulls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

Character Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

Date Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51

Numerical Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

Scientific Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

Special Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

Test Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

Variable Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

ABORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

ADD_TO_DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

ASCII . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

AVG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

CEIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

CHR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

CHRCODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

CONCAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

COS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

COSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

COUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

CUME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

DATE_COMPARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

DATE_DIFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

DECODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

7DEOH�RI�&RQWHQWV�� Y

Page 6: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83

FIRST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

FLOOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86

GET_DATE_PART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

IIF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

INITCAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

INSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

ISNULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

IS_DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98

IS_NUMBER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

IS_SPACES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

LAST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

LAST_DAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

LENGTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108

LN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

LOOKUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

LOWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

LPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114

LTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

MAX (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

MAX (Numbers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

MEDIAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

MIN (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

MIN (Numbers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

MOVINGAVG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

MOVINGSUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

PERCENTILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133

POWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136

ROUND (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

ROUND (Numbers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

RPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142

RTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

SETCOUNTVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

SET_DATE_PART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

SETMAXVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

�YL 7DEOH�RI�&RQWHQWV

Page 7: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SETMINVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

SETVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155

SIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

SIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

SINH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

SQRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

STDDEV . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

SUBSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163

SUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

TAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

TANH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

TO_CHAR (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

TO_CHAR (Numbers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174

TO_DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 176

TO_DECIMAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

TO_FLOAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

TO_INTEGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

TO_NUMBER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183

TRUNC (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184

TRUNC (Numbers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187

UPPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

VARIANCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

&����'���&��%��������(���)�*��������� � � � � � � � � � � � � � � � � � � � � � ���

Aggregate Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

Character Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

Date Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

Numeric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

Scientific Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

Special Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

Test Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

Variable Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

+�'��� � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � � �,�

7DEOH�RI�&RQWHQWV�� YLL

Page 8: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

�YLLL 7DEOH�RI�&RQWHQWV

Page 9: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

List of Tables

Table 1-1. Reference Qualifiers in Transformation Language . . . . . . . . . . . . . . . . . . . . . . . . . . 4

Table 3-1. Operators in the Transformation Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

Table 3-2. Arithmetic Operators in the Transformation Language . . . . . . . . . . . . . . . . . . . . . 19

Table 3-3. Converting Data with Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

Table 3-4. Comparison Operators in the Transformation Language . . . . . . . . . . . . . . . . . . . . 22

Table 3-5. Logical Operators in the Transformation Reference . . . . . . . . . . . . . . . . . . . . . . . . 23

Table 4-1. Datatype Expansion for $$$SessStartTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

Table 5-1. RR Format String Conversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Table 5-2. Differences Between RR and YY Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . 34

Table 5-3. Date Format Strings in the Transformation Reference . . . . . . . . . . . . . . . . . . . . . . 37

Table 5-4. Date Functions that Use Date Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

Table 5-5. TO_CHAR Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

Table 5-6. TO_DATE and IS_DATE Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

/LVW�RI�7DEOHV�� L[

Page 10: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

�[ /LVW�RI�7DEOHV

Page 11: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Preface

Welcome to PowerMart and PowerCenter, Informatica’s integrated suite of software products that deliver an open, scalable solution addressing the complete life cycle for data warehouse and analytic application development. Both PowerMart and PowerCenter combine the latest technology enhancements for reliably managing data repositories and delivering information resources in a timely, usable manner.

The metadata repository coordinates and drives a variety of core functions including extraction, transformation, loading, and management. The Informatica Server can extract large volumes of data from multiple platforms, handle complex transformations, and support high-speed loads. PowerMart and PowerCenter can simplify and accelerate the process of moving data warehouses from development to test to full production.

�[L

Page 12: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

About Informatica Documentation

The complete set of printed documentation for PowerMart and PowerCenter includes the following books:

♦ Designer Guide. Provides information needed to use the Designer. Includes information to help you create mappings, mapplets, and transformations. Also includes a description of the transformation datatypes used to process and transform source data.

♦ Getting Started. Provides basic tutorials for getting started. Also contains documentation about the sample repository.

♦ Installation and Configuration Guide. Provides information needed to install and configure the Informatica tools, including details on environment variables and database connections.

♦ Metadata Reporter Guide. Provides information on how to install and use the web-based Metadata Reporter to generate reports on the metadata in PowerMart and PowerCenter repositories.

♦ Repository Guide. Provides information needed to administer the repository using the Repository Manager or the pmrep command line program. Includes details on functionality available in the Repository Manager, such as creating and maintaining repositories, folders, users, groups, and permissions and privileges.

♦ Session and Server Guide. Provides information to help you create and run sessions in the Server Manager, as well as administer the Informatica Server. Also contains information on tuning sessions and the Informatica Server for better performance.

♦ Transformation Language Reference. Provides syntax descriptions and examples for each transformation function provided with PowerMart and PowerCenter.

♦ Troubleshooting Guide. Provides error messages that you might encounter while using PowerMart or PowerCenter. Each error message includes one or more possible causes and actions that you can take to correct the condition.

Documentation available with our other products includes:

♦ Informatica® Metadata Exchange SDK User Guide. Provides information about the second generation of Metadata Exchange interfaces for PowerMart and PowerCenter repositories.

♦ Informatica® PowerChannel™ User Guide. Provides information on how to transport compressed and encrypted data through a secure channel.

♦ PowerCenter™ Integration Server for BW Installation Guide. Provides information to install and configure PCISBW for loading source data into a SAP Business Warehouse. It also contains basic instructions for loading into BW.

♦ PowerConnect™ for IBM® DB2® Installation Guide. Provides information on setting up a mainframe environment to work with PowerCenter, including connectivity issues for mainframe and DB2 databases.

vi Preface

Page 13: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� PowerConnect™ for IBM® MQSeries® User and Administrator Guide. Provides information to install PowerConnect for IBM MQSeries, build mappings, extract data from message queues, and load data to message queues.

� PowerConnect™ for PeopleSoft® User and Administrator Guide. Provides information to install PowerConnect for PeopleSoft, extract data from PeopleSoft, build mappings, and run sessions to load PeopleSoft source data into your data warehouse.

� PowerConnect™ for SAP™ R/3® User and Administrator Guide. Provides information to install PowerConnect for SAP R/3, extract data from SAP R/3, build mappings, and run sessions to load SAP R/3 data into a data warehouse.

� PowerConnect™ for Siebel® User and Administrator Guide. Provides information to install PowerConnect for Siebel, extract data from Siebel systems, build mappings, and run sessions to load Siebel source data into a data warehouse.

� PowerPlug™ User Guide. Provides information on how to use PowerPlug to extract metadata from leading data modeling tools and import it into PowerMart/PowerCenter repositories through Informatica Metadata Exchange SDK.

� PowerBridge™ for Hyperion® Essbase® Server User Guide. Provides information on how to use PowerBridge to export multi-dimensional metadata from PowerMart/PowerCenter repositories into the Hyperion Integration Server through Informatica Metadata Exchange SDK.

$ERXW�,QIRUPDWLFD�'RFXPHQWDWLRQ�� [LLL

Page 14: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

About this Book

The Transformation Language Reference is written for the developers who are responsible for building mappings to load a data warehouse. The Transformation Language Reference assumes you have knowledge of SQL, relational database concepts, and the interface requirements for your supporting applications.

The online help and Adobe Acrobat versions of this book contain material for PowerMart 5.1/ PowerCenter 5.1. The printed version of this book contains material for PowerMart 5.0/ PowerCenter 5.0. To view printed material for the new features in PowerMart 5.1/PowerCenter 5.1, refer to the PowerMart/PowerCenter Supplemental Guide.

The material in this book is available for online use.

About PowerCenter and PowerMartThis guide contains information about both PowerMart and PowerCenter. The documentation explicitly mentions software features that differ between the two products.

If You Are Using PowerCenterWith PowerCenter, you receive all product functionality, including the ability to register multiple servers, share metadata across repositories, and partition data.

A PowerCenter license lets you create a single repository that you can configure as a global repository, the core component of a data warehouse.

When this guide mentions a PowerCenter Server, it is referring to an Informatica Server with a PowerCenter license.

If You Are Using PowerMartThis version of PowerMart includes all features except distributed metadata, multiple registered servers, and data partitioning. Also, the various options available with PowerCenter (such as PowerCenter Integration Server for BW, PowerConnect for IBM DB2, PowerConnect for IBM MQSeries, PowerConnect for SAP R/3, PowerConnect for Siebel, and PowerConnect for PeopleSoft) are not available with PowerMart.

When this guide mentions a PowerMart Server, it is referring to an Informatica Server with a PowerMart license.

�[LY 3UHIDFH

Page 15: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Document ConventionsThis guide uses the following formatting conventions:

,I�\RX�VHH« ,W�PHDQV«

italicized text� 7KH�ZRUG�RU�VHW�RI�ZRUGV�DUH�HVSHFLDOO\�HPSKDVL]HG�

boldfaced text� (PSKDVL]HG�VXEMHFWV�

italicized monospaced text� 7KLV�LV�WKH�YDULDEOH�QDPH�IRU�D�YDOXH�\RX�HQWHU�DV�SDUW�RI�DQ�RSHUDWLQJ�V\VWHP�FRPPDQG��7KLV�LV�JHQHULF�WH[W�WKDW�VKRXOG�EH�UHSODFHG�ZLWK�XVHU�VXSSOLHG�YDOXHV�

-����� 7KH�IROORZLQJ�SDUDJUDSK�SURYLGHV�DGGLWLRQDO�IDFWV�

����� 7KH�IROORZLQJ�SDUDJUDSK�SURYLGHV�VXJJHVWHG�XVHV�

.������� 7KH�IROORZLQJ�SDUDJUDSK�QRWHV�VLWXDWLRQV�ZKHUH�\RX�FDQ�RYHUZULWH�RU�FRUUXSW�GDWD��XQOHVV�\RX�IROORZ�WKH�VSHFLILHG�SURFHGXUH�

monospaced text� 7KLV�LV�D�FRGH�H[DPSOH�

bold monospaced text� 7KLV�LV�DQ�RSHUDWLQJ�V\VWHP�FRPPDQG�\RX�HQWHU�IURP�D�SURPSW�WR�H[HFXWH�D�WDVN�

$ERXW�WKLV�%RRN�� [Y

Page 16: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Other Informatica Resources

In addition to the product manuals, Informatica provides these other resources:

� Informatica Webzine

� Informatica web site

� Informatica Developer Network

� Informatica Technical Support

Accessing the Informatica WebzineThe Informatica Documentation Team delivers an online journal, the Informatica Webzine. This journal provides solutions to common tasks, conceptual overviews of industry-standard technology, detailed descriptions of specific features, and tips and tricks to help you develop data warehouses. You can access the webzine at:

http://www.informatica.com/webzine

The Informatica Webzine is a password-protected site. Informatica has an online registration form for login accounts to its webzine and web support. To register for an account, go to the following URL:

http://www.informatica.com/support/webpaswdreq.html

If you have any questions, please email [email protected].

To better serve your needs, the Informatica Documentation Team welcomes all comments and suggestions. You can send comments and suggestions to:

[email protected]

Visiting the Informatica Web SiteYou can access Informatica’s corporate web site at http://www.informatica.com. The site contains information about Informatica, its background, upcoming events, and locating your closest sales office. You will also find product information, as well as literature and partner information. The services area of the site includes important information on technical support, training and education, and implementation services.

Visiting the Informatica Developer Network The Informatica Developer Network is a web-based forum for third-party software developers. You can access the Informatica Developer Network at http://devnet.informatica.com. The site contains information on how to create, market, and support customer-oriented add-on solutions based on Informatica’s interoperability interfaces.

�[YL 3UHIDFH

Page 17: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Obtaining Technical SupportThere are many ways to access Informatica technical support. You can call or email your nearest Technical Support Center listed below or you can use our WebSupport Service.

Both WebSupport and our Customer Site require a user name and password. To receive a user name and password, please contact us at [email protected] or call 650-687-6300.

1RUWK�$PHULFD���6RXWK�$PHULFD� $IULFD���$VLD���$XVWUDOLD���(XURSH�

,QIRUPDWLFD�&RUSRUDWLRQ������:��%D\VKRUH�5G��3DOR�$OWR��&$�������3KRQH���������������)D[���������������+RXUV����D�P������S�P���S�V�W�HPDLO��VXSSRUW#LQIRUPDWLFD�FRP

,QIRUPDWLFD�6RIWZDUH�/WG���:DOWKDP�3DUN:DOWKDP�5RDG��:KLWH�:DOWKDP0DLGHQKHDG��%HUNVKLUH6/���713KRQH�8.�����������������*HUPDQ\�����������������6ZLW]HUODQG�����������������)D[������������������+RXUV����D�P������S�P���J�P�W�HPDLO��VXSSRUWBXN#LQIRUPDWLFD�FRP

2WKHU�,QIRUPDWLFD�5HVRXUFHV�� [YLL

Page 18: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

New Features and Enhancements

This section describes new features and enhancements to PowerMart and PowerCenter.

Version 5.1The following list describes new features and enhancements in PowerMart 5.1/PowerCenter 5.1.

Performance Enhancements� High precision decimal arithmetic. The Informatica Server optimizes data throughput to

increase performance of sessions using the Enable Decimal Arithmetic option.

� To_Decimal and Aggregate functions. The Informatica Server uses improved algorithms to increase performance of To_Decimal and all aggregate functions such as percentile, median, and average.

� Cache management. The Informatica Server uses better cache management to increase performance of Aggregator, Joiner, Lookup, and Rank transformations.

� Partition sessions with sorted aggregation. You can partition sessions with Aggregator transformation that use sorted input. This improves memory usage and increases performance of sessions that have sorted data.

Relaxed Data Code Page ValidationWhen enabled, the Informatica Client and Informatica Server lift code page selection and validation restrictions. You can select any supported code page for source, target, lookup, and stored procedure data.

Designer Features and Enhancements� Debug mapplets. You can debug a mapplet within a mapping in the Mapping Designer.

You can set breakpoints in transformations in the mapplet.

� Support for slash character (/) in table and field names. You can use the Designer to import source and target definitions with table and field names containing the slash character (/). This allows you to import SAP BW source definitions by connecting directly to the underlying database tables.

Server Manager Features and Enhancements� Continuous sessions. You can schedule a session to run continuously. A continuous

session starts automatically when the Load Manager starts. When the session stops, it restarts immediately without rescheduling. Use continuous sessions when reading real time sources, such as IBM MQSeries.

�[YLLL 3UHIDFH

Page 19: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� Partition sessions with sorted aggregators. You can partition sessions with sorted aggregators in a mapping.

� Register multiple servers against a local repository. You can register multiple PowerCenter Servers against a local repository.

Version 5.0The following list describes new features and enhancements in PowerMart 5.0/PowerCenter 5.0.

Designer Features and Enhancements� Debugger. You can debug a mapping from the Mapping Designer. Using the Debugger

Wizard, choose to run the Debugger against an existing session in debug mode or create a debug session. Before you debug a mapping, set breakpoints in the mapping where you want the Informatica Server to evaluate data and error conditions. The Debugger pauses when a breakpoint evaluates to true, and you can change transformation output data.

� Double-click folder icon to open the folder and tool. When you double-click a folder icon in the Navigator window, the Designer opens the folder and displays the last tool that was active within that folder.

� Find in Workspace tool. You can search for text strings in tables, columns, or ports across all open objects in the workspace.

� Full screen view. You can view the workspace over the entire screen. The Designer hides the menu, the Navigator and Output windows, and the title bar to maximize the workspace window.

� Invalid mapping icon. The Designer displays a new icon for invalid mappings in the Navigator window.

� Lookup cache. You can use a dynamic lookup cache in a Lookup transformation. When you use a dynamic lookup cache, the Informatica Server updates the lookup cache during the session run. Also, you can share persistent lookup caches within and across mappings by naming the cache files.

� Mapping parameters and variables. Create mapping parameters and variables in a mapplet or mapping to make mappings more flexible. Mapping parameters and variables represent values in mappings and mapplets. Use mapping parameters and variables to reduce the overhead of creating multiple mappings when only certain attributes of a mapping need to change.

� New Designer shortcut keys. New shortcut keys allow you to cut, copy, paste, and delete rows when you edit a repository object.

� New workspace look. You can select two colors to create a color gradient for the title bars of repository objects. Other components of the workspace, such as links, arrows, and tool title, also have a sharper, three-dimensional look.

� Object import and export. You can export objects from a repository and import objects into a repository. When you export a repository object, the Designer or Server Manager

1HZ�)HDWXUHV�DQG�(QKDQFHPHQWV�� [L[

Page 20: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

creates an XML file describing the repository metadata. Use the XML file to import repository objects into a repository. You can export and import sources, targets, transformations, mapplets, mappings, and sessions.

� Preview data. The Designer allows you to preview data for relational sources, flat file sources, and relational targets.

� Retain relationships and source or target definition descriptions when re-importing a source or target definition. When you re-import a source or target definition, you have the option of retaining primary and foreign key relationships and source or target descriptions.

� Resizable Expression Editor. You can resize the Expression Editor by dragging the corner of the dialog box.

� Router transformation. The Designer allows you to use a Router transformation to test data based on multiple conditions. The Router transformation allows you to route groups of data to a transformation or a target.

� Save mappings and mapplets under a different name. The Designer allows you to save mappings and mapplets under a different name within the same folder.

� XML sources and targets. You can use XML data as a source or target. You can create source and target definitions from an XML, DTD, or XML schema file and use them in mappings. When you run a session, you can read data from an XML source file and validate it against a DTD. You can also write data from any type of source to an XML file.

Informatica Server Enhancements� Expanded pmcmd capability. You can use the command line program pmcmd to specify a

parameter file when you start a session or batch. This allows you to change the values of session parameters, and mapping parameters and variables at runtime.

� Parallel data processing. Available with PowerCenter only. If you run the Informatica Server on a symmetric multi-processing system, you can use multiple CPUs to process a session concurrently. You configure partitions in the session properties based on source qualifiers. The Informatica Server reads, transforms, and writes partitions of data in parallel for a single session.

� Process session data using threads. The Informatica Server runs on two processes: the Load Manager process and the DTM process. The DTM process creates threads to perform session tasks, such as reading, transforming, and writing data as well as performing pre-and post-session operations.

Metadata ReporterThe Metadata Reporter is a web-based application that enables you to run reports against repository metadata. With the Metadata Reporter, you can access information about your repository without having knowledge of SQL, the transformation language, or the underlying tables in the repository.

�[[ 3UHIDFH

Page 21: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Repository Manager Features and Enhancements� Compare Folders. You can compare the contents of folders in the same repository or across

different repositories.

� Copy and Replace Folder Wizard. You can maintain shortcuts from local to global repositories when you copy and replace folders. When copying folders, you can select the shared folder to associate shortcuts.

� Display user privileges. The Manage Privileges dialog box displays all user and group privileges so you can assign and revoke privileges by selecting the appropriate option.

� pmrep. A command-line utility for Windows NT/2000 that allows you to perform repository tasks and change session-related parameters. Using pmrep, you can connect to, back up, delete, and restore a repository. Additional pmrep commands allow you to update database connectivity information for a repository, update email address information for session notification email, and update server variables.

Server Manager Features and Enhancements� Additional email variables. With new email variables, you can configure post-session

email to include information, such as the mapping used during the session.

� Additional server variables. You can configure several new server variables when registering a server. Server variables such as $PMSuccessEmailUser allow you to configure sessions without hard-coding information.

� Copy session. You can copy sessions across folders and repositories using the Copy Session Wizard in the Server Manager.

� Enhanced user security. You can set read, write, and execute permissions for users and groups to restrict access to database, FTP, and external loader connections.

� Global validation of sessions. You can validate a specified set of sessions in a folder or validate all of the invalid sessions in a folder.

� Read-only privileges for sessions. You can set user and group permissions and privileges that allow users to view, but not edit, session properties.

� Session parameters. Create session parameters to reuse sessions. You can create parameters for database connections, reject files, and file sources and targets. You can also use a built-in session parameter for the session log. Define session parameters in the session parameter file.

� Sybase IQ 12 External Loader. You can use Sybase IQ 12 external loaders to load multibyte data. Null characters and delimiters can be up to four bytes long.

� Teradata External Loader. You can use Teradata external loaders to load single-byte data. The Teradata external loader uses ASCII-based single-byte code pages.

Transformation Language EnhancementsYou can use two new built-in system variables with PowerMart and PowerCenter:

1HZ�)HDWXUHV�DQG�(QKDQFHPHQWV�� [[L

Page 22: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� SESSSTARTTIME. Returns the system date value on the machine hosting the Informatica Server when the server initializes the session. You can use SESSSTARTTIME within any function that accepts transformation date/time datatypes using the transformation language.

� $$$SessStartTime. Returns the system date value on the machine hosting the Informatica Server when the server initializes the session. You can use $$$SessStartTime at the mapping level in the filter condition, user-defined join, or SQL override of a source qualifier. You can also use $$$SessStartTime in session-level overrides for mapping attributes.

You can also use four new variable functions with mapping variables:

� SetCountVariable. Counts the number of evaluated rows and increment or decrement a mapping variable for each row.

� SetMaxVariable. Evaluates the value of a mapping variable to the higher of two values.

� SetMinVariable. Evaluates the value of a mapping variable to the lower of two values.

� SetVariable. Sets the value of a mapping variable to a specified value.

�[[LL 3UHIDFH

Page 23: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� � � � � � � �

The Transformation Language

This chapter provides a general overview of the transformation language. It includes the following topics:

� Overview, 2

� Expression Syntax, 4

� Adding Comments to Expressions, 7

� Reserved Words, 8

For information about supported datatypes and data conversions, see “Datatype Reference” in the Designer Guide.

��

Page 24: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Overview

PowerCenter and PowerMart provide a transformation language to help you write expressions to transform source data. The transformation language includes SQL-like functions so you can write expressions that modify data or test whether data matches conditions. You can write expressions in the following transformations:

� Aggregator

� Expression

� Filter

� Rank

� Router

� Update Strategy

Transformation Language ComponentsThe transformation language includes the following components to help you create simple or complex transformation expressions:

� Functions. Over 60 SQL-like functions allow you to change data in a mapping.

� Operators. Use transformation operators to create transformation expressions to perform mathematical computations, combine data, or compare data.

� Constants. Use built-in constants to reference values that remain constant, such as TRUE.

� Mapping parameters and variables. Create mapping parameters for use within a mapping or mapplet to reference values that remain constant throughout a session, such as a state sales tax rate. Create mapping variables in mapplets or mappings to write expressions referencing values that change from session to session. See “Mapping Parameters and Variables” in the Designer Guide for details.

� Local and system variables. Use built-in variables to write expressions that reference value that vary, such as the system date. You can also create local variables in transformations.

� Return values. You can also write expressions that include the return values from Lookup, Stored Procedure, and External Procedure transformations.

For details on creating expressions and local variables in the Designer, see “Transformations” in the Designer Guide.

Transformation ExpressionsWith the transformation language, you can create a transformation expression that takes the data from a port and changes it. For example, you might use the AVG function to calculate the average salary of all your employees, or the SUM function to calculate the total sales for a specific branch. Then, during a session, the Informatica Server writes results to the target tables based on the update strategies you define.

�� &KDSWHU����7KH�7UDQVIRUPDWLRQ�/DQJXDJH

Page 25: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

You can create an expression as simple as a port, such as ORDERS, or a numeric literal, such as 10. You can also write complex expressions that include functions nested within functions, or combine different ports using the transformation language operators.

For a detailed discussion of how transformation expressions are evaluated, see “Transformations” in the Designer Guide.

Internationalization and the Transformation LanguageTransformation language functions can handle character data in either ASCII or Unicode data movement mode. Use Unicode mode to handle multibyte character data. The return values of the following functions and transformations depend on the code page of the Informatica Server and the data movement mode:

� INITCAP

� LOWER

� UPPER

� MIN (Date)

� MIN (Number)

� MAX (Date)

� MAX (Number)

� Any function that uses conditional statements to compare strings, such as IIF and DECODE

MIN and MAX also return values based on the sort order associated with the Informatica Server code page.

When you validate an invalid expression in the expression editor, a dialog box displays the expression with an error indicator, “>>>>”. This indicator appears to the left of and points to the part of the expression containing the error. For example, if the expression a = b + c contains an error at c, the error message displays:

a = b + >>>> c

Transformation language functions that evaluate character data are character-oriented, not byte-oriented. For example, the LENGTH function returns the number of characters in a string, not the number of bytes. The LOWER function returns a string in lowercase according to the code page of the Informatica Server.

2YHUYLHZ�� �

Page 26: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Expression Syntax

Although the transformation language is based on standard SQL, it is not exactly like SQL. For example, SQL supports the keywords AS and FROM for nonaggregate functions and ALL and DISTINCT for aggregate functions, but the transformation language does not. On the other hand, the transformation language supports an optional filter condition for aggregate functions, while SQL does not.

You can create an expression that is as simple as a port (such as ORDERS) or a numeric literal (such as 10). You can also write complex expressions that include functions nested within functions, or combine different columns using the transformation language operators.

Expression ComponentsExpressions can consist of any combination of the following components:

� Ports (input, input/output, variable)

� String literals, numeric literals

� Constants

� Functions

� Local and system variables

� Mapping parameters and mapping variables

� Operators

� Return values

Ports and Return ValuesWhen you write an expression that includes a port or return value from an unconnected transformation, use the reference qualifiers in Table 1-1:

Table 1-1. Reference Qualifiers in Transformation Language

5HIHUHQFH�4XDOLILHU�

'HVFULSWLRQ

�(;7 5HTXLUHG�ZKHQ�\RX�ZULWH�DQ�H[SUHVVLRQ�WKDW�LQFOXGHV�D�UHWXUQ�YDOXH�IURP�DQ�([WHUQDO�3URFHGXUH�WUDQVIRUPDWLRQ��7KH�JHQHUDO�V\QWD[�LV�:EXT.external_procedure_transformation(argument1, argument2, ...)

�/.3 5HTXLUHG�ZKHQ�\RX�FUHDWH�DQ�H[SUHVVLRQ�WKDW�LQFOXGHV�WKH�UHWXUQ�YDOXH�IURP�DQ�XQFRQQHFWHG�/RRNXS�WUDQVIRUPDWLRQ��7KH�JHQHUDO�V\QWD[�LV�:LKP.lookup_transformation(argument1, argument2, ...)7KH�DUJXPHQWV�DUH�WKH�ORFDO�SRUWV�XVHG�LQ�WKH�ORRNXS�FRQGLWLRQ��7KH�RUGHU�PXVW�PDWFK�WKH�RUGHU�RI�WKH�SRUWV�LQ�WKH�WUDQVIRUPDWLRQ��7KH�GDWDW\SHV�IRU�WKH�ORFDO�SRUWV�PXVW�H[DFWO\�PDWFK�WKH�GDWDW\SH�RI�WKH�/RRNXS�SRUWV�XVHG�LQ�WKH�ORRNXS�FRQGLWLRQ�

�� &KDSWHU����7KH�7UDQVIRUPDWLRQ�/DQJXDJH

Page 27: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

String and Numeric LiteralsYou can include numeric or string literals.

Be sure to enclose string literals within single quotation marks. For example:

’Alice Davis’

String literals are case-sensitive and can contain any character except a single quotation mark. For example, the following string is not allowed:

’Joan’s car’

To return a string containing a single quote, use the CHR function:

’Joan’ || CHR(39) || ’s car’

Do not use single quotation marks with numeric literals. Just type the number you want to pass. For example:

.05

or

$$Sales_Tax

-�����For details on constants, functions, local and system variables, mapping parameters and variables, and operators see corresponding chapters in this guide.

�6' 2SWLRQDO��3RZHU0DUW�����H[SUHVVLRQV�RQO\���4XDOLILHV�D�VRXUFH�WDEOH�SRUW�LQ�DQ�H[SUHVVLRQ��7KH�JHQHUDO�V\QWD[�LV�:SD.source_table.column_name

�6(4 5HTXLUHG�ZKHQ�\RX�FUHDWH�DQ�H[SUHVVLRQ�WKDW�LQFOXGHV�D�SRUW�LQ�D�6HTXHQFH�*HQHUDWRU�WUDQVIRUPDWLRQ��7KH�JHQHUDO�V\QWD[�LV�:SEQ.sequence_generator_transformation.CURRVAL

�63 5HTXLUHG�ZKHQ�\RX�ZULWH�DQ�H[SUHVVLRQ�WKDW�LQFOXGHV�WKH�UHWXUQ�YDOXH�IURP�DQ�XQFRQQHFWHG�6WRUHG�3URFHGXUH�WUDQVIRUPDWLRQ��7KH�JHQHUDO�V\QWD[�LV�:SP.stored_procedure_transformation( argument1, argument2, [,

PROC_RESULT]) 7KH�DUJXPHQWV�PXVW�PDWFK�WKH�DUJXPHQWV�LQ�WKH�XQFRQQHFWHG�6WRUHG�3URFHGXUH�WUDQVIRUPDWLRQ�

�7' 5HTXLUHG�ZKHQ�\RX�UHIHUHQFH�D�WDUJHW�WDEOH�LQ�D�3RZHU0DUW�����/22.83�IXQFWLRQ��7KH�JHQHUDO�V\QWD[�LV�LOOKUP(:TD.SALES.ITEM_NAME, :TD.SALES.ITEM_ID, 10, :TD.SALES.PRICE,

15.99)

Table 1-1. Reference Qualifiers in Transformation Language

5HIHUHQFH�4XDOLILHU�

'HVFULSWLRQ

([SUHVVLRQ�6\QWD[�� �

Page 28: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

General RulesThese general rules apply when writing all expressions:

� You can pass a value from a port, literal string or number, variable, Lookup transformation, Stored Procedure transformation, External Procedure transformation, or the results of another expression.

� Separate each argument in a function with a comma.

� Except for literals, the transformation language is not case-sensitive.

� Except for literals, the Designer and Informatica Server ignore spaces.

� The colon (:), comma (,), and period (.) have special meaning and should be used only to specify syntax.

� The Informatica Server treats a dash (-) as a minus operator.

� If you pass a literal value to a function, enclose literal strings within single quotation marks. Do not use quotation marks for literal numbers. The Informatica Server treats any string value enclosed in single quotation marks as a character string.

� When you pass a mapping parameter or variable to a function within an expression, do not use quotation marks to designate mapping parameters or variables.

� Do not use quotation marks to designate ports.

� You can nest multiple functions within an expression (except aggregate functions, which allow only one nested aggregate function). The Informatica Server evaluates the expression starting with the innermost function.

For more information on entering expressions, see “Transformations” in the Designer Guide.

�� &KDSWHU����7KH�7UDQVIRUPDWLRQ�/DQJXDJH

Page 29: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Adding Comments to Expressions

The transformation language provides two comment specifiers to let you insert comments in expressions:

� Two dashes, as in:

-- These are comments

� Two slashes, as in:

// These are comments

The Informatica Server ignores all text on a line preceded by these two comment specifiers. For example, if you want to concatenate two strings, you can enter the following expression with comments in the middle of the expression:

-- This expression concatenates first and last names for customers:

FIRST_NAME -- First names from the CUST table

|| // Concat symbol

LAST_NAME // Last names from the CUST table

// Joe Smith Aug 18 1998

The Informatica Server ignores the comments and evaluates the expression as follows:

FIRST_NAME || LAST_NAME

You cannot continue a comment to a new line:

-- This expression concatenates first and last names for customers:

FIRST_NAME -- First names from the CUST table

|| // Concat symbol

LAST_NAME // Last names from the CUST table

Joe Smith Aug 18 1998

In this case, the Designer does not validate the expression, since the last line is not a valid expression.

$GGLQJ�&RPPHQWV�WR�([SUHVVLRQV�� �

Page 30: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Reserved Words

Some keywords in the transformation language, such as constants, operators, and system variables, are reserved for specific functions. These include:

� :EXT

� :LKP

� :SD

� :SEQ

� :SP

� :TD

� AND

� DD_DELETE

� DD_INSERT

� DD_REJECT

� DD_UPDATE

� FALSE

� NOT

� NULL

� OR

� PROC_RESULT

� SESSSTARTTIME

� SPOUTPUT

� SYSDATE

� TRUE

-�����You cannot use a reserved word to name a port or local variable. You can only use reserved words within transformation expressions. Reserved words have predefined meanings in expressions.

�� &KDSWHU����7KH�7UDQVIRUPDWLRQ�/DQJXDJH

Page 31: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� � � � � � � �

Constants

This chapter describes how to use the built-in constants of the transformation language:

� DD_DELETE, 10

� DD_INSERT, 11

� DD_REJECT, 12

� DD_UPDATE, 13

� FALSE, 14

� NULL, 15

� TRUE, 16

��

Page 32: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DD_DELETE

Flags records for deletion in an update strategy expression. DD_DELETE is equivalent to the integer literal 2.

-�����The DD_DELETE constant is designed for use in the Update Strategy transformation only. Informatica recommends using DD_DELETE instead of the integer literal 2. It is easier to troubleshoot complex numeric expressions if you use DD_DELETE.

When you run a session, select the data-driven update strategy to delete records from a target based on this flag.

ExampleThe following expression marks items with an ID number of 1001 for deletion, and all other items for insertion:

IIF( ITEM_ID = 1001, DD_DELETE, DD_INSERT )

This update strategy expression uses numeric literals to produce the same result:

IIF( ITEM_ID = 1001, 2, 0 )

-�����The expression using constants is easier to read than the expression using numeric literals.

��� &KDSWHU����&RQVWDQWV

Page 33: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DD_INSERT

Flags records for insertion in an update strategy expression. DD_INSERT is equivalent to the integer literal 0.

-�����The DD_INSERT constant is designed for use in the Update Strategy transformation only. Informatica recommends using DD_INSERT instead of the integer literal 0. It is easier to troubleshoot complex numeric expressions if you use DD_INSERT.

When you run a session, select the data-driven update strategy to write records to a target based on this flag.

ExamplesThe following examples modify a mapping that calculates monthly sales per salesperson, so you can examine the sales of just one salesperson.

This update strategy expression flags this employee’s sales for insertion (using DD_INSERT), and rejects everything else (using DD_REJECT):

IIF( EMPLOYEE.NAME = ’Alex’, DD_INSERT, DD_REJECT )

This update strategy expression uses numeric literals to produce the same result:

IIF( EMPLOYEE.NAME = ’Alex’, 0, 3 )

Notice that the expression using constants is easier to read than the expression using numeric literals.

The following update strategy expression uses SESSSTARTTIME to find only those orders that have shipped in the last two days and flag them for insertion. Using DATE_DIFF, the expression subtracts DATE_SHIPPED from the system date, returning the difference between the two dates. Because DATE_DIFF returns a Double value, the expression uses TRUNC to truncate the difference. It then compares the result to the integer literal 2. If the result is greater than 2, the expression flags the records for rejection. If the result is 2 or less, it flags them for insertion:

IIF( TRUNC( DATE_DIFF( SESSSTARTTIME, ORDERS.DATE_SHIPPED, ’DD’ ), 0 ) > 2,DD_REJECT, DD_INSERT )

''B,16(57�� ��

Page 34: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DD_REJECT

Flags records for rejection in an update strategy expression. DD_REJECT is equivalent to the integer literal 3.

-�����The DD_REJECT constant is designed for use in the Update Strategy transformation only. Informatica recommends using DD_REJECT instead of the integer literal 3. It is easier to troubleshoot complex numeric expressions if you use DD_REJECT.

When you run a session, select the data-driven update strategy to reject records from a target based on this flag.

DD_REJECT is generally used to filter or validate data. If you flag a record as reject, the Informatica Server skips the record and writes it to the session reject file. For more information, see “Reject Loading” in the Session and Server Guide.

ExamplesThe following examples modify a mapping that calculates the sales for the current month, so it includes only positive values.

This update strategy expression flags records less than zero for reject and all others for insert:

IIF( ORDERS.SALES > 0, DD_INSERT, DD_REJECT )

This expression uses numeric literals to produce the same result:

IIF( ORDERS.SALES > 0, 0, 3 )

Notice that the expression using constants is easier to read than the expression using numeric literals.

The following data-driven example uses DD_REJECT and IS_SPACES to avoid writing spaces to a character column in a target table. This expression flags records that consist entirely of spaces for reject and flags all others for insert:

IIF( IS_SPACES( CUST_NAMES ), DD_REJECT, DD_INSERT )

��� &KDSWHU����&RQVWDQWV

Page 35: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DD_UPDATE

Flags records for update in an update strategy expression. DD_UPDATE is equivalent to the integer literal 1.

-�����The DD_UPDATE constant is designed for use in the Update Strategy transformation only. Informatica recommends using DD_UPDATE instead of the integer literal 1. It is easier to troubleshoot complex numeric expressions if you use DD_UPDATE.

When you run a session, select the data-driven update strategy to write records to a target based on this flag.

ExamplesThe following examples modify a mapping that calculates sales for the current month, so it only loads the sales for one particular employee.

This expression flags records for Alex as updates and flags all others for rejection:

IIF( EMPLOYEE.NAME = ’Alex’, DD_UPDATE, DD_REJECT )

This expression uses numeric literals to produce the same result, flagging Alex’s sales for update (1) and flagging all other sales records for rejection (3):

IIF( EMPLOYEE.NAME = ’Alex’, 1, 3 )

Notice that the expression using constants is easier to read than the expression using numeric literals.

The following update strategy expression uses SYSDATE to find only those orders that have shipped in the last two days and flag them for insertion. Using DATE_DIFF, the expression subtracts DATE_SHIPPED from the system date, returning the difference between the two dates. Because DATE_DIFF returns a Double value, the expression uses TRUNC to truncate the difference. It then compares the result to the integer literal 2. If the result is greater than 2, the expression flags the records for rejection. If the result is 2 or less, it flags the records for update; otherwise, it flags them for rejection:

IIF( TRUNC( DATE_DIFF( SYSDATE, ORDERS.DATE_SHIPPED, ’DD’ ), 0 ) > 2, DD_REJECT, DD_UPDATE )

''B83'$7(�� ��

Page 36: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

FALSE

Clarifies a conditional expression. FALSE is equivalent to the integer 0.

ExampleThe following example uses FALSE in a DECODE expression to return values based on the results of a comparison. (This is useful if you want to perform multiple searches based on a single search value):

DECODE( FALSE,

Var1 = 22,’Variable 1 was 22!’,

Var2 = 49,’Variable 2 was 49!’,

Var1 < 23, ’Variable 1 was less than 23.’,

Var2 > 30, ’Variable 2 was more than 30.’,

’Variables were out of desired ranges.’)

��� &KDSWHU����&RQVWDQWV

Page 37: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

NULL

Indicates that a value is either unknown or undefined. NULL is not equivalent to a blank or empty string (for character columns) or zero (for numerical columns).

Although you can write expressions that return nulls, keep in mind that any column that has the NOT NULL or PRIMARY KEY constraint will not accept nulls. Therefore, if the Informatica Server tries to write a null value to a column with one of these constraints, the database will reject the row and the Informatica Server will write it to the reject file. Be sure to consider nulls when you create transformations.

The way functions handle nulls varies from function to function. If you pass a null value to a function, it might return zero or NULL, or it might ignore null values. For details on how each function handles null values, see “Functions” on page 47.

Null Values in Aggregate FunctionsBy default, the Informatica Server treats null values as nulls in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want it to handle null values in aggregate functions. You can have the Informatica Server treat null values as zero in aggregate functions or as NULLs. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica NT Server” or “Installing and Configuring the Informatica UNIX Server” in the Installation and Configuration Guide.

Null Values in Filter ConditionsIf a filter condition evaluates to NULL, the function does not select the record. If the filter condition evaluates to NULL for all records in the selected port, the aggregate function returns NULL (except COUNT, which returns zero). You use filter conditions with aggregate functions, as well as CUME, MOVINGAVG, and MOVINGSUM.

Nulls with OperatorsAny expression that uses operators (except the string operator ||) and contains a null value always evaluates to NULL. For example, the following expression evaluates to NULL:

8 * 10 - NULL

To test for nulls, use the ISNULL function.

18//�� ��

Page 38: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TRUE

Returns a value based on the result of a comparison. TRUE is equivalent to the integer 1.

ExampleThe following example uses TRUE in a DECODE expression to return values based on the results of a comparison. (This is useful if you want to perform multiple searches based on a single search value):

DECODE( TRUE,

Var1 = 22,’Variable 1 was 22!’,

Var2 = 49,’Variable 2 was 49!’,

Var1 < 23, ’Variable 1 was less than 23.’,

Var2 > 30, ’Variable 2 was more than 30.’,

’Variables were out of desired ranges.’)

��� &KDSWHU����&RQVWDQWV

Page 39: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� � � � � � � � �

Operators

This chapter describes how to use operators to perform arithmetic or comparisons within functions. It includes the following topics:

� Operator Precedence, 18

� Arithmetic Operators, 19

� String Operators, 21

� Comparison Operators, 22

� Logical Operators, 23

���

Page 40: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Operator Precedence

The transformation language supports the use of multiple operators and the use of operators within nested expressions.

If you write an expression that includes multiple operators, the Informatica Server evaluates the expression in the following order:

1. Arithmetic operators

2. String operators

3. Comparison operators

4. Logical operators

Table 3-1 lists the precedence for all transformation language operators. The Informatica Server evaluates operators in the order they appear in the following table. It evaluates operators in an expression with equal precedence to all operators from left to right.

The transformation language also supports the use of operators within nested expressions. When expressions contain parentheses, the Informatica Server evaluates operations inside parentheses before operations outside parentheses. Operations in the innermost parentheses are evaluated first.

For example, depending on how you nest the operations, the equation 8 + 5 - 2 * 8 returns different values:

Table 3-1. Operators in the Transformation Language

2SHUDWRU 0HDQLQJ

��� 3DUHQWKHVHV�

���� 8QDU\�SOXV�DQG�PLQXV�

������ 0XOWLSOLFDWLRQ��GLYLVLRQ��PRGXOXV�

���� $GGLWLRQ��VXEWUDFWLRQ�

__ &RQFDWHQDWH�

���� ��!��! /HVV�WKDQ��OHVV�WKDQ�RU�HTXDO�WR��JUHDWHU�WKDQ��JUHDWHU�WKDQ�RU�HTXDO�WR�

���!��� ��A (TXDO�WR��QRW�HTXDO�WR��QRW�HTXDO�WR��QRW�HTXDO�WR�

127 7KH�ORJLFDO�127�RSHUDWRU�

$1' 7KH�ORJLFDO�$1'�RSHUDWRU��XVHG�ZKHQ�VSHFLI\LQJ�FRQGLWLRQV�

25 7KH�ORJLFDO�25�RSHUDWRU��XVHG�ZKHQ�VSHFLI\LQJ�FRQGLWLRQV�

(TXDWLRQ 5HWXUQ�9DOXH

���������� �� ��

������������ �� ��

��� &KDSWHU����2SHUDWRUV

Page 41: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Arithmetic Operators

Use arithmetic operators to perform mathematical calculations on numeric data.

Table 3-2 lists the arithmetic operators in order of precedence in the transformation language:

If you perform arithmetic on a null value, the function returns NULL.

You can use these operators with numeric data or text data. However, the operator may produce different results when you use it to manipulate numeric data versus character data. For example, if you use an arithmetic operator with a string, the parser converts the string to a number.

-�����The transformation language provides built-in date functions that let you perform arithmetic on date/time values. For further information on built-in date functions, see “Understanding Date Arithmetic” on page 45.

Using Arithmetic Operators to Convert DataYou can convert data to numeric values within an expression. If the string consists of numbers, unary plus or minus, or a decimal point, the Informatica Server converts it and evaluates it without error.

Table 3-3 shows the results when you pass strings to an expression that adds numeric values:

Table 3-2. Arithmetic Operators in the Transformation Language

2SHUDWRU 0HDQLQJ

���� 8QDU\�SOXV�DQG�PLQXV��8QDU\�SOXV�LQGLFDWHV�D�SRVLWLYH�YDOXH��8QDU\�PLQXV�LQGLFDWHV�D�QHJDWLYH�YDOXH�

������ 0XOWLSOLFDWLRQ��GLYLVLRQ��PRGXOXV��$�PRGXOXV�LV�WKH�UHPDLQGHU�DIWHU�GLYLGLQJ�WZR�LQWHJHUV��)RU�H[DPSOH��������� ���EHFDXVH����GLYLGHG�E\���HTXDOV���ZLWK�D�UHPDLQGHU�RI���

���� $GGLWLRQ��VXEWUDFWLRQ�1RWH��7KH�DGGLWLRQ�RSHUDWRU�����GRHV�QRW�FRQFDWHQDWH�VWULQJV��,I�\RX�XVH�DULWKPHWLF�RSHUDWRUV�RQ�WH[W�RU�GDWH�YDOXHV��WKH�,QIRUPDWLFD�6HUYHU�FRQYHUWV�WKH�WH[W�WR�D�QXPEHU�EHIRUH�FDOFXODWLQJ�D�UHWXUQ�YDOXH��7R�FRQFDWHQDWH�VWULQJV��XVH�WKH�VWULQJ�RSHUDWRU�__��7R�SHUIRUP�DULWKPHWLF�RQ�GDWH�YDOXHV��XVH�WKH�GDWH�IXQFWLRQV�

Table 3-3. Converting Data with Arithmetic Operators

([SUHVVLRQ &RQYHUWV�7R 5HVXOWV

$EF������ ������� ���

�DEF������ ������� ���

�D�EF������ ������� ���

DE��F������ ������� ���

$ULWKPHWLF�2SHUDWRUV�� ��

Page 42: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

��H�������� ����������� ������

������18// 18// 18//

Table 3-3. Converting Data with Arithmetic Operators

([SUHVVLRQ &RQYHUWV�7R 5HVXOWV

��� &KDSWHU����2SHUDWRUV

Page 43: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

String Operators

Use the || string operator to concatenate two strings. The || operator converts operands of any datatype (except Binary) to String datatypes before concatenation:

The || operator includes leading and trailing spaces. You can use the LTRIM and RTRIM functions to trim leading and trailing spaces before concatenating two strings.

NullsThe || operator ignores null values. However, if both values are NULL, the || operator returns NULL.

ExampleThe following example shows an expression that concatenates employee first names and employee last names that are normally stored in two separate columns. This expression removes the spaces from the end of all first names and the beginning of all last names, concatenates a space to the end of each first name, then concatenates the last name:

LTRIM( RTRIM( EMP_FIRST ) || ’ ’ || LTRIM( EMP_LAST ))

-�����You can also use the CONCAT function to concatenate two string values. The operator, however, produces the same results in less time.

,QSXW�9DOXH 5HWXUQ�9DOXH�

DOSKD�__�EHWLFDO DOSKDEHWLFDO

DOSKD�__�� DOSKD�

DOSKD�__�18// DOSKD

EMP_FIRST EMP_LAST RETURN VALUE

‘ Alfred’ ‘ Rice ‘ Alfred Rice

‘ Bernice’ ‘ Kersins’ Bernice Kersins

NULL ‘ Proud’ Proud

‘ Curt’ NULL Curt

NULL NULL NULL

6WULQJ�2SHUDWRUV�� ��

Page 44: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Comparison Operators

Use comparison operators to compare character or numeric strings, manipulate data, and return a TRUE (1) or FALSE (0) value.

Table 3-4 lists the comparison operators in the transformation language:

You can use the greater than (>) and less than (<) operators to compare numeric values or return a range of rows based on the sort order for a primary key in a particular port.

If you compare a value to a null value, the result is NULL.

If a filter condition evaluates to NULL, the Informatica Server returns NULL.

For information on how to compare dates, see “Dates” on page 31.

Table 3-4. Comparison Operators in the Transformation Language

2SHUDWRU 0HDQLQJ

(TXDO�WR�

! *UHDWHU�WKDQ�

� /HVV�WKDQ�

! *UHDWHU�WKDQ�RU�HTXDO�WR�

� /HVV�WKDQ�RU�HTXDO�WR�

�! 1RW�HTXDO�WR�

� 1RW�HTXDO�WR�

A 1RW�HTXDO�WR�

��� &KDSWHU����2SHUDWRUV

Page 45: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Logical Operators

Use logical operators to manipulate numeric data. Expressions that return a numeric value evaluate to TRUE for non-zero values, FALSE for zero, and NULL for NULL.

Table 3-5 lists the logical operators in the transformation language:

NullsIf one of the conditions in a logical comparison is NULL, the result is NULL.

Table 3-5. Logical Operators in the Transformation Reference

2SHUDWRU 0HDQLQJ

127 1HJDWHV�UHVXOW�RI�DQ�H[SUHVVLRQ��)RU�H[DPSOH��LI�DQ�H[SUHVVLRQ�HYDOXDWHV�WR�758(��WKH�RSHUDWRU�127�UHWXUQV�)$/6(��,I�DQ�H[SUHVVLRQ�HYDOXDWHV�WR�)$/6(��127�UHWXUQV�758(�

$1' -RLQV�WZR�FRQGLWLRQV�DQG�UHWXUQV�758(�LI�ERWK�FRQGLWLRQV�HYDOXDWH�WR�758(��5HWXUQV�)$/6(�LI�RQH�FRQGLWLRQ�LV�QRW�WUXH�

25 &RQQHFWV�WZR�FRQGLWLRQV�DQG�UHWXUQV�758(�LI�DQ\�FRQGLWLRQ�HYDOXDWHV�WR�758(��5HWXUQV�)$/6(�LI�ERWK�FRQGLWLRQV�DUH�QRW�WUXH�

/RJLFDO�2SHUDWRUV�� ��

Page 46: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

��� &KDSWHU����2SHUDWRUV

Page 47: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� � � � � � � � �

Variables

This chapter describes how to use these variables:

� System Variables, 26

� Local Variables, 29

���

Page 48: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

System Variables

The transformation language provides the following system variables:

� PROC_RESULT

� $$$SessStartTime

� SYSDATE

� SESSSTARTTIME

PROC_RESULTWhen using an unconnected stored procedure in an expression, you need a method of returning the value of output parameters to a port. You have two options for capturing these values:

1. Assign the output value to a local variable.

2. Assign the output value to the system variable PROC_RESULT.

By using PROC_RESULT, you assign the value of the return parameter directly to an output port, which can be applied directly to a target. You can also combine these two options by assigning one output parameter as PROC_RESULT, and the other parameters as variables.

Use PROC_RESULT only within an expression. If you do not use PROC_RESULT or a variable, the port containing the expression captures a NULL. You cannot use PROC_RESULT in a connected lookup or within the Call Text for a stored procedure.

ExampleThe stored procedure spGET_NAME takes one input parameter, which is an employee ID. It returns two output parameters: a first and last name. When you import the stored procedure, the Stored Procedure transformation displays an input port called EMP_ID, and two output ports called FIRST_NAME and LAST_NAME.

Next, add an Expression transformation as part of your mapping, and create two new ports. The first port is an output port called outFIRST_NAME, and the second port is a local variable called outLAST_NAME. You also create an input port from an upstream transformation called ID. This passes an employee ID from a source earlier in the mapping, which you use as an input parameter to the stored procedure.

After opening the Expression Editor for outFIRST_NAME, you see spGET_NAME listed under the Stored Procedures in the Editor. Double click the name of the procedure to add it to the expression. You want to return the value of FIRST_NAME from the stored procedure to the current port, so use PROC_RESULT to pass the value of this output parameter. The value of LAST_NAME will be assigned to the variable outLAST_NAME. Your expression will appear as follows:

:SP.spGET_NAME( EMP_ID, PROC_RESULT, outLAST_NAME )

��� &KDSWHU����9DULDEOHV

Page 49: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

If you require nested stored procedures, where the output parameter of one stored procedure needs to be passed to another stored procedure, you use PROC_RESULT to pass this value. For additional information on configuring expressions, see “Stored Procedure Transformation” in the Designer Guide.

$$$SessStartTime $$$SessStartTime returns the initial system date value on the machine hosting the Informatica Server when the server initializes a session. $$$SessStartTime returns the session start time as a string value. The format of the string depends on the database you are using.

Table 4-1 lists the $$$SessStartTime date and time format according to different database types:

You can use $$$SessStartTime in a mapping or mapplet filter condition, user-defined join, or SQL override of a source qualifier. You can also use $$$SessStartTime in session-level overrides for mapping attributes. For details on using $$$SessStartTime in a mapping, see “Source Qualifier Transformation” in the Designer Guide.

-�����Changing any database environment variables such as NLS_LANG_FORMAT for Oracle or DBDATE for Informix will not affect the format string for datetime values the Informatica Server uses in the SQL override for $$$SessStartTime.

ExampleThe following expression uses $$$SessStartTime in the source filter condition of a source qualifier to perform an incremental extraction. The expression specifies a range of dates of all days in the week prior to when the Informatica Server initializes the session. The expression uses the function DATEDIFF to find the difference in the number of days between the value ORDER_DATE and $$$SessStartTime. If the difference between the two dates is less than or equal to seven days, the Informatica Server extracts that row from the source:

DATEDIFF(DAY, ORDER_DATE, ‘$$$SessStartTime’) <= 7

Table 4-1. Datatype Expansion for $$$SessStartTime

'DWDEDVH�7\SH 'DWH�WLPH�IRUPDW

2UDFOH 00�''�<<<<�++���0,�66

6\EDVH 00�''�<<<<++���0,�66

0LFURVRIW�64/�6HUYHU 00�''�<<<<�++���0,�66

,QIRUPL[ <<<<�00�''�++���0,�66

2'%& <<<<�00�''�++���0,�66

,%0�'%� <<<<�00�''�++���0,�66

6\VWHP�9DULDEOHV�� ��

Page 50: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SYSDATESYSDATE returns the current date and time on the machine hosting the Informatica Server for each row passing through the transformation. SYSDATE is stored as a transformation date/time datatype value.

To capture a static system date, use the SESSTARTTIME variable instead of SYSDATE.

-�����When you upgrade a repository to PowerMart/PowerCenter 5.1, the upgrade process replaces the system variable SYSDATE with the system variable SESSSTARTTIME under certain conditions for Aggregator, Expression, Filter, Rank, and Update Strategy transformations. For details on the conditions for SYSDATE replacement, see “Upgrading a Repository” in the Installation and Configuration Guide.

ExampleThe following expression uses SYSDATE to find only those orders that have shipped in the last two days and flag them for insertion. Using DATE_DIFF, the Informatica Server subtracts DATE_SHIPPED from the system date, returning the difference between the two dates. Because DATE_DIFF returns a double value, the expression truncates the difference. It then compares the result to the integer literal 2. If the result is greater than 2, the expression flags the rows for rejection. If the result is 2 or less, it flags them for insertion.

IIF( TRUNC( DATE_DIFF( SYSDATE, DATE_SHIPPED, ’DD’ ),0 ) > 2, DD_REJECT, DD_INSERT

SESSSTARTTIME SESSSTARTTIME returns the current date and time value on the machine hosting the Informatica Server when the server initializes the session. You can use SESSSTARTTIME with any function that accepts transformation date/time datatypes. SESSSTARTTIME is stored as a transformation date/time datatype value.

You can use SESSSTARTTIME in a mapping or a mapplet. You can reference SESSSTARTTIME only within the expression language.

ExampleThe following expression uses SESSSTARTTIME to display the number of days an order has been open up to the time the session ran. Using the SQL function DATE_DIFF, the server subtracts DATE_ENTERED from SESSTARTTIME and returns the result as a number of days:

DATE_DIFF(SESSSTARTTIME, DATE_ENTERED, ‘DD’)

��� &KDSWHU����9DULDEOHV

Page 51: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Local Variables

You can use local variables that you create within a mapping in any transformation expression. For example, if you use a complex tax calculation throughout a mapping, you might want to write the expression once and designate it as a variable. You thereby increase performance since the Informatica Server performs the calculation only once.

Local variables are especially useful when used with stored procedure expressions to capture multiple return values.

For details on local variables, see “Transformations” in the Designer Guide.

/RFDO�9DULDEOHV�� ��

Page 52: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

��� &KDSWHU����9DULDEOHV

Page 53: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� � � � � � � �

Dates

This chapter describes how to use dates in transformations. It includes the following topics:

� Overview, 32

� Date Format Strings, 37

� TO_CHAR Format Strings, 38

� TO_DATE and IS_DATE Format Strings, 41

� Understanding Date Arithmetic, 45

���

Page 54: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Overview

The transformation language provides a set of date functions and built-in date variables to help you perform transformations on dates.

With the date functions you can round, truncate, or compare dates, extract one part of a date, or perform arithmetic on a date. You can use date variables to capture the current date or session start time on the machine hosting the Informatica Server. For details on built-in variables, see “Variables” on page 25.

The transformation language provides the following other functions to manipulate dates:

� IS_DATE. Tests whether a string represents a date.

� TO_CHAR. Converts a date to a string.

� TO_DATE. Converts a string to a date.

The transformation language also provides the following sets of format strings:

� Date format strings. Use with date functions to specify the parts of a date.

� TO_CHAR format strings. Use to specify the format of the return string.

� TO_DATE and IS_DATE format strings. Use to specify the format of a string you want to convert to a date or test.

Date/Time DatatypePowerMart and PowerCenter provide a set of generic datatypes to help you transform data from different sources. These transformation datatypes include a Date/Time datatype. PowerMart and PowerCenter store dates internally in binary format.

Date functions accept date/time values only. To pass a string to a date function, first use TO_DATE to convert it to a date/time value. For example, the following expression converts a string port to date/time values and then adds one month to each date:

ADD_TO_DATE( TO_DATE( STRING_PORT, ‘MM/DD/RR’), ‘MM’, 1 )

-�����PowerMart and PowerCenter support dates between 1753 A.D. and 9999 A.D.

MillisecondsPowerMart and PowerCenter support date/time values up to the second. If you pass a value to a date function or Date/Time port, the Informatica Server truncates the millisecond portion of the date.

Julian Day, Modified Julian Day, and the Gregorian CalendarPowerMart and PowerCenter support dates in the Gregorian calendar system only. Dates expressed in a different calendar system are not supported.

��� &KDSWHU����'DWHV

Page 55: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

-�����Dates in the Julian calendar are called Julian dates, and are not supported in PowerMart or PowerCenter. This term should not be confused with Julian Day, nor with Modified Julian Day.

PowerMart and PowerCenter provide the ability to manipulate Modified Julian Day (MJD) formats using the J format string.

The MJD for a given date is the number of days to that date since Jan 1 4713 BC 00:00:00 (midnight). By definition, MJD includes a time component expressed as a decimal, which represents some fraction of 24 hours. The J format string does not convert this time component.

For example, the following TO_DATE expression converts strings in the SHIP_DATE_MJD_STRING port to date values in the default date format:

TO_DATE (SHIP_DATE_MJD_STR, ’J’)

Because the J format string does not include the time portion of a date, the return values have the time set to 00:00:00.

You can also use the J format string in TO_CHAR expressions. For example, you can use the J format string in a TO_CHAR expression to convert date values to MJD values expressed as strings. For example:

TO_CHAR(SHIP_DATE, ’J’)

-�����The Informatica Server ignores the time portion of the date in a TO_CHAR expression.

Dates in the Year 2000All transformation language date functions support the year 2000. PowerMart and PowerCenter support dates between 1753 A.D. and 9999 A.D.

RR Format StringThe transformation language provides the RR format string to convert strings with two-digit years to dates. Using TO_DATE and the RR format string, you can convert a string in the format MM/DD/RR to a date. The RR format string converts data differently depending on the current year.

� Current Year Between 0 and 49. If the current year is between 0 and 49 (such as 2003) and the source string year is between 0 and 49, the Informatica Server returns the current

SHIP_DATE_MJD_STR RETURN_VALUE

2451544 Dec 31 1999 00:00:00

2415021 Jan 1 1900 00:00:00

SHIP_DATE RETURN_VALUE

Dec 31 1999 23:59:59 2451544

Jan 1 1900 01:02:03 2415021

2YHUYLHZ�� ��

Page 56: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

century plus the two-digit year from the source string. If the source string year is between 50 and 99, the Informatica Server returns the previous century plus the two-digit year from the source string.

� Current Year Between 50 and 99. If the current year is between 50 and 99 (such as 1998) and the source string year is between 0 and 49, the Informatica Server returns the next century plus the two-digit year from the source string. If the source string year is between 50 and 99, the Informatica Server returns the current century plus the specified two-digit year.

Table 5-1 summarizes how the RR format string converts to dates:

ExampleThe following expression produces the same return values for any current year between 1950 and 2049:

TO_DATE( ORDER_DATE, ‘MM/DD/RR’ )

Difference Between the YY and RR Format StringsPowerMart and PowerCenter also provide a YY format string. Both the RR and YY format strings specify two-digit years. The YY and RR format strings produce identical results when used with all date functions except TO_DATE. In TO_DATE expressions, RR and YY produce different results.

Table 5-2 illustrates the different results each format string returns:

Table 5-1. RR Format String Conversions

&XUUHQW�\HDU 6RXUFH�\HDU 55�)RUPDW�6WULQJ�5HWXUQV

���� ���� &XUUHQW�FHQWXU\�

���� ����� 3UHYLRXV�FHQWXU\�

����� ���� 1H[W�FHQWXU\�

����� ����� &XUUHQW�FHQWXU\

ORDER_DATE RETURN_VALUE

‘04/12/98’ 04/12/1998 00:00:00

‘11/09/01’ 11/09/2001 00:00:00

Table 5-2. Differences Between RR and YY Format Strings

6WULQJ &XUUHQW�<HDU 72B'$7(�6WULQJ��¶00�''�55·� 72B'$7(�6WULQJ��¶00�''�<<·�

�������� ���� ������������������� �������������������

�������� ���� ������������������� �������������������

�������� ���� ������������������� �������������������

�������� ���� ������������������� �������������������

��� &KDSWHU����'DWHV

Page 57: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

For dates in the year 2000 and beyond, the YY format string produces less meaningful results than the RR format string. Informatica recommends using the RR format string for dates in the twenty-first century.

Dates in Relational DatabasesIn general, dates stored in relational databases contain a date and time value. The date includes the month, day, and year, while the time might include the hours, minutes, and seconds. You can pass date/time data to any of the date functions. Although date formats vary from database to database, and even between applications, the transformation language can read any date with a date datatype.

Dates in Flat FilesThe transformation language provides the TO_DATE function to convert strings to date/time values. You can also use IS_DATE to check if a string is a valid date before converting it with TO_DATE.

-�����The transformation language date functions accept date values only. If you want to pass a string to a date function, you must first use the TO_DATE function to convert it to a transformation Date/Time datatype.

Default Date FormatThe Informatica Server uses a default date format to store and manipulate strings that represent dates. Because PowerMart and PowerCenter store dates in binary format, the Informatica Server only uses the default date format when you:

� Convert a date to a string by connecting a date/time port to a string port. In this case, the Informatica Server converts the date to a string in the default date format, MM/DD/YYYY HH24:MI:SS.

� Convert a string to a date by connecting a string port to a date/time port. The Informatica Server expects the string values to be in the default date format, MM/DD/YYYY HH24:MI:SS. If an input value does not match this format, or represents an invalid date, the Informatica Server skips that row. If the string is in the default date format, the Informatica Server converts the string to a date value.

� Use TO_CHAR(date, [format_string]) to convert dates to strings. If you omit the format string, the Informatica Server returns the string in the default date format, MM/DD/YYYY HH24:MI:SS. If you specify a format string, the Informatica Server returns a string in the specified format.

� Use TO_DATE(date, [format_string]) to convert strings to dates. If you omit the format string, the Informatica Server expects the string in the default date format, MM/DD/YYYY HH24:MI:SS. If you specify a format string, the Informatica Server expects a string in the specified format.

2YHUYLHZ�� ��

Page 58: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The default date format of MM/DD/YYYY HH24:MI:SS contains the following parts of a date:

� Month (January = 01, September = 09)

� Day (of the month)

� Year (expressed in four digits, such as 1998)

� Hour (in 24-hour form. For example, 12:00:00AM = 0, 1:00:00AM = 1, 12:00:00PM = 12, 11:00:00PM = 23)

� Minutes

� Seconds

��� &KDSWHU����'DWHV

Page 59: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Date Format Strings

Input dates can be evaluated using a combination of format strings and date functions. Date format strings are not internationalized and must be entered in predefined formats as listed in the following table.

Table 5-3 summarizes the format strings you can use to specify a part of a date:

-�����The format string is not case-sensitive. It must always be enclosed within single quotation marks.

Table 5-4 uses date functions with date format strings to evaluate input dates:

Table 5-3. Date Format Strings in the Transformation Reference

)RUPDW�6WULQJ 'HVFULSWLRQ

'��''��'''��'$<��'<��- 'D\V����������<RX�FDQ�XVH�DQ\�RI�WKHVH�IRUPDW�VWULQJV�WR�VSHFLI\�WKH�HQWLUH�GD\�SRUWLRQ�RI�D�GDWH��)RU�H[DPSOH��LI�\RX�SDVV����$35������WR�D�GDWH�IXQFWLRQ��\RX�FDQ�XVH�DQ\�RI�WKHVH�IRUPDW�VWULQJV�VSHFLI\����

++��++����++�� +RXU�RI�GD\����WR������ZKHUH�]HUR�LV����$0��PLGQLJKW���<RX�FDQ�XVH�DQ\�RI�WKHVH�IRUPDWV�WR�VSHFLI\�WKH�HQWLUH�KRXU�SRUWLRQ�RI�D�GDWH��)RU�H[DPSOH��LI�\RX�SDVV�WKH�GDWH����$35��������������30��\RX�FDQ�XVH�++��++����RU�++���WR�VSHFLI\�WKH�KRXU�SRUWLRQ�RI�WKH�GDWH�

0, 0LQXWHV�

00��021��0217+ 0RQWK�SRUWLRQ�RI�GDWH����WR������<RX�FDQ�XVH�DQ\�RI�WKHVH�IRUPDW�VWULQJV�WR�VSHFLI\�WKH�HQWLUH�PRQWK�SRUWLRQ�RI�D�GDWH��)RU�H[DPSOH��LI�\RX�SDVV����$35������WR�D�GDWH�IXQFWLRQ��\RX�FDQ�XVH�00��021��RU�0217+�WR�VSHFLI\�$35�

66��6666 6HFRQG�SRUWLRQ�RI�GDWH����WR�����

<��<<��<<<��<<<<��55 <HDU�SRUWLRQ�RI�GDWH�������WR��������<RX�FDQ�XVH�DQ\�RI�WKHVH�IRUPDW�VWULQJV�WR�VSHFLI\�WKH�HQWLUH�\HDU�SRUWLRQ�RI�D�GDWH��)RU�H[DPSOH��LI�\RX�SDVV����$35������WR�D�GDWH�IXQFWLRQ��\RX�FDQ�XVH�<��<<��<<<��RU�<<<<�WR�VSHFLI\�������

Table 5-4. Date Functions that Use Date Format Strings

)XQFWLRQ 'HVFULSWLRQ

$''B72B'$7( 6SHFLI\�WKH�SDUW�RI�WKH�GDWH�\RX�ZDQW�WR�FKDQJH�

'$7(B',)) 6SHFLI\�WKH�SDUW�RI�WKH�GDWH�WR�XVH�WR�FDOFXODWH�WKH�GLIIHUHQFH�EHWZHHQ�WZR�GDWHV�

*(7B'$7(B3$57 6SHFLI\�WKH�SDUW�RI�WKH�GDWH�\RX�ZDQW�WR�UHWXUQ��7KLV�IXQFWLRQ�UHWXUQV�DQ�LQWHJHU�YDOXH�EDVHG�RQ�WKH�GHIDXOW�GDWH�IRUPDW�

5281' 6SHFLI\�WKH�SDUW�RI�WKH�GDWH�\RX�ZDQW�WR�URXQG�

6(7B'$7(B3$57 6SHFLI\�WKH�SDUW�RI�WKH�GDWH�\RX�ZDQW�WR�FKDQJH�

7581& 6SHFLI\�WKH�SDUW�RI�WKH�GDWH�\RX�ZDQW�WR�WUXQFDWH�

'DWH�)RUPDW�6WULQJV�� ��

Page 60: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_CHAR Format Strings

The TO_CHAR function converts a Date/Time datatype to a string with the format you specify. You can convert the entire date or a part of the date to a string. You might use TO_CHAR to convert dates to string, changing the format for reporting purposes.

TO_CHAR is generally used when the target is a flat file or a database that does not support a Date/Time datatype.

Table 5-5 summarizes the format strings for dates in the function TO_CHAR:

Table 5-5. TO_CHAR Format Strings

)RUPDW�6WULQJ 'HVFULSWLRQ

$0��$�0���30��3�0� 0HULGLDQ�LQGLFDWRU��<RX�FDQ�XVH�DQ\�RI�WKHVH�IRUPDW�VWULQJV�WR�VSHFLI\�$0�DQG�30�KRXUV��$0�DQG�30�UHWXUQ�WKH�VDPH�YDOXHV�DV�GR�$�0��DQG�3�0��

' 'D\�RI�ZHHN��������ZKHUH�6XQGD\�HTXDOV���

'' 'D\�RI�PRQWK����������

''' 'D\�RI�\HDU�����������LQFOXGLQJ�OHDS�\HDUV��

'$< 1DPH�RI�GD\��LQFOXGLQJ�XS�WR�QLQH�FKDUDFWHUV��IRU�H[DPSOH��:HGQHVGD\��

'< $EEUHYLDWHG�WKUHH�FKDUDFWHU�QDPH�IRU�D�GD\��IRU�H[DPSOH��:HG��

++��++�� +RXU�RI�GD\���������

++�� +RXU�RI�GD\����������ZKHUH����LV���$0��PLGQLJKW��

- 0RGLILHG�-XOLDQ�'D\��&RQYHUWV�WKH�FDOHQGDU�GDWH�WR�D�VWULQJ�HTXLYDOHQW�WR�LWV�0RGLILHG�-XOLDQ�'D\�YDOXH��FDOFXODWHG�IURP�-DQ������������������%&��,W�LJQRUHV�WKH�WLPH�FRPSRQHQW�RI�WKH�GDWH�)RU�H[DPSOH��WKH�H[SUHVVLRQ�72B&+$5��6+,3B'$7(��µ-¶���FRQYHUWV�'HF������������������WR�WKH�VWULQJ���������

0, 0LQXWHV���������

00 0RQWK���������

0217+ 1DPH�RI�PRQWK��LQFOXGLQJ�XS�WR�QLQH�FKDUDFWHUV��IRU�H[DPSOH��-DQXDU\��

021 $EEUHYLDWHG�WKUHH�FKDUDFWHU�QDPH�IRU�D�PRQWK��IRU�H[DPSOH��-DQ��

4 4XDUWHU�RI�\HDU��������ZKHUH�-DQXDU\�WR�0DUFK�HTXDOV���

55 /DVW�WZR�GLJLWV�RI�D�\HDU��7KH�IXQFWLRQ�UHPRYHV�WKH�OHDGLQJ�GLJLWV��)RU�H[DPSOH��LI�\RX�XVH�55�DQG�SDVV�WKH�\HDU�������72B&+$5�UHWXUQV����:KHQ�XVHG�ZLWK�72B&+$5��µ55¶�SURGXFHV�WKH�VDPH�UHVXOWV�DV��DQG�LV�LQWHUFKDQJHDEOH�ZLWK��µ<<�¶�+RZHYHU��ZKHQ�XVHG�ZLWK�72B'$7(��µ55¶�FDOFXODWHV�WKH�FORVHVW�DSSURSULDWH�FHQWXU\�DQG�VXSSOLHV�WKH�ILUVW�WZR�GLJLWV�RI�WKH�\HDU�

66 6HFRQGV���������

��� &KDSWHU����'DWHV

Page 61: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

-�����The format string is not case-sensitive. It must always be enclosed within single quotation marks.

ExamplesThe following examples illustrate the J, SSSSS, RR, and YY format strings. See the individual functions for more examples.

-�����The Informatica Server ignores the time portion of the date in a TO_CHAR expression.

66666 6HFRQGV�VLQFH�PLGQLJKW������������������:KHQ�\RX�XVH�66666�LQ�D�72B&+$5�H[SUHVVLRQ��WKH�,QIRUPDWLFD�6HUYHU�RQO\�HYDOXDWHV�WKH�WLPH�SRUWLRQ�RI�D�GDWH�)RU�H[DPSOH��WKH�H[SUHVVLRQ�72B&+$5��6+,3B'$7(��µ00�''�<<<<�66666¶��FRQYHUWV���������������������WR������������������

< /DVW�GLJLW�RI�D�\HDU��7KH�IXQFWLRQ�UHPRYHV�WKH�OHDGLQJ�GLJLWV��)RU�H[DPSOH��LI�\RX�XVH�µ<¶�DQG�SDVV�WKH�\HDU�������72B&+$5�UHWXUQV���

<< /DVW�WZR�GLJLWV�RI�D�\HDU��7KH�IXQFWLRQ�UHPRYHV�WKH�OHDGLQJ�GLJLWV��)RU�H[DPSOH��LI�\RX�XVH�<<�DQG�SDVV�WKH�\HDU�������72B&+$5�UHWXUQV����

<<< /DVW�WKUHH�GLJLWV�RI�D�\HDU��7KH�IXQFWLRQ�UHPRYHV�WKH�OHDGLQJ�GLJLWV��)RU�H[DPSOH��LI�\RX�XVH�<<<�DQG�SDVV�WKH�\HDU�������72B&+$5�UHWXUQV�����

<<<< (QWLUH�\HDU�SRUWLRQ�RI�GDWH��)RU�H[DPSOH��LI�\RX�XVH�<<<<�DQG�SDVV�WKH�\HDU�������72B&+$5�UHWXUQV������

: :HHN�RI�PRQWK��������ZKHUH�ZHHN���VWDUWV�RQ�WKH�ILUVW�GD\�RI�WKH�PRQWK�DQG�HQGV�RQ�WKH�VHYHQWK��ZHHN���VWDUWV�RQ�WKH�HLJKWK�GD\�DQG�HQGV�RQ�WKH�IRXUWHHQWK�GD\��)RU�H[DPSOH��)HE���GHVLJQDWHV�WKH�ILUVW�ZHHN�RI�)HEUXDU\�

:: :HHN�RI�\HDU����������ZKHUH�ZHHN����VWDUWV�RQ�-DQ���DQG�HQGV�RQ�-DQ����ZHHN���VWDUWV�RQ�-DQ���DQG�HQGV�RQ�-DQ�����DQG�VR�RQ�

��������� 3XQFWXDWLRQ�WKDW�GLVSOD\V�LQ�WKH�RXWSXW��<RX�PLJKW�XVH�WKHVH�V\PEROV�WR�VHSDUDWH�GDWH�SDUWV��)RU�H[DPSOH��\RX�PLJKW�FUHDWH�WKH�IROORZLQJ�H[SUHVVLRQ�WR�VHSDUDWH�GDWH�SDUWV�ZLWK�D�SHULRG��72B&+$5��'$7(6��00�''�<<<<���

�WH[W� 7H[W�WKDW�GLVSOD\V�LQ�WKH�RXWSXW��)RU�H[DPSOH��LI�\RX�FUHDWH�DQ�RXWSXW�SRUW�ZLWK�WKH�H[SUHVVLRQ��72B&+$5��'$7(6��00�''�<<<<��6DOHV�:HUH�8S����DQG�SDVV�WKH�GDWH�$SU���������WKH�IXQFWLRQ�UHWXUQV�WKH�VWULQJ������������6DOHV�:HUH�8S��<RX�FDQ�HQWHU�PXOWLE\WH�FKDUDFWHUV�WKDW�DUH�YDOLG�LQ�WKH�UHSRVLWRU\�FRGH�SDJH�

³³ 8VH�GRXEOH�TXRWDWLRQ�PDUNV�WR�VHSDUDWH�DPELJXRXV�IRUPDW�VWULQJV��IRU�H[DPSOH�'´´'''��7KH�HPSW\�TXRWDWLRQ�PDUNV�GR�QRW�DSSHDU�LQ�WKH�RXWSXW�

Table 5-5. TO_CHAR Format Strings

)RUPDW�6WULQJ 'HVFULSWLRQ

72B&+$5�)RUPDW�6WULQJV�� ��

Page 62: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

J Format StringYou can use the J format string in a TO_CHAR expression to convert date values to MJD values expressed as strings. For example:

TO_CHAR(SHIP_DATE, ’J’)

SSSSS Format StringYou can also use the format string SSSSS in a TO_CHAR expression. For example, the following expression converts the dates in the SHIP_DATE port to strings representing the total seconds since midnight:

TO_CHAR( SHIP_DATE, ’SSSSS’)

RR Format StringThe following expression converts dates to strings in the format MM/DD/YY:

TO_CHAR( SHIP_DATE, ‘MM/DD/RR’)

YY Format StringIn TO_CHAR expressions, the YY format string produces the same results as the RR format string. The following expression converts dates to strings in the format MM/DD/YY:

TO_CHAR( SHIP_DATE, ‘MM/DD/YY’)

SHIP_DATE RETURN_VALUE

Dec 31 1999 23:59:59 2451544

Jan 1 1900 01:02:03 2415021

SHIP_DATE RETURN_VALUE

12/31/1999 01:02:03 3783

09/15/1996 23:59:59 86399

SHIP_DATE RETURN_VALUE

12/31/1999 01:02:03 12/31/99

09/15/1996 23:59:59 09/15/96

05/17/2003 12:13:14 05/17/03

SHIP_DATE RETURN_VALUE

12/31/1999 01:02:03 12/31/99

09/15/1996 23:59:59 09/15/96

05/17/2003 12:13:14 05/17/03

��� &KDSWHU����'DWHV

Page 63: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_DATE and IS_DATE Format Strings

The TO_DATE function converts a string with the format you specify to a date/time value. TO_DATE is generally used to convert strings from flat files to date/time values. TO_DATE format strings are not internationalized and must be entered in predefined formats as listed in the TO_DATE and IS_DATE Format Strings table.

-�����TO_DATE and IS_DATE use the same set of format strings.

When you create a TO_DATE expression, use a format string for each part of the date in the source string. The source string format and the format string must match exactly; if any parts do not match, the Informatica Server does not convert the string and skips the row. If you omit the format string, the source string must be in the default date format MM/DD/YYYY HH24:MI:SS.

IS_DATE tells you if a value is a valid date. A valid date is any string representing a valid date in the default date format of MM/DD/YYYY HH24:MI:SS. If the strings you want to test are not in the default date format, use the format strings listed in the TO_DATE and IS_DATE Format Strings table to specify the date format. If a string does not match the specified format string or is not a valid date, the function returns FALSE (0). If the string matches the format string and is a valid date, the function returns TRUE (1). IS_DATE format strings are not internationalized and must be entered in predefined formats as listed in the following table.

Table 5-6 summarizes the format strings for the functions TO_DATE and IS_DATE:

Table 5-6. TO_DATE and IS_DATE Format Strings

)RUPDW�6WULQJ 'HVFULSWLRQ

$0��D�P���30��S�P� 0HULGLDQ�LQGLFDWRU��<RX�FDQ�XVH�DQ\�RI�WKHVH�IRUPDW�VWULQJV�WR�VSHFLI\�$0�DQG�30�KRXUV��$0�DQG�30�UHWXUQ�WKH�VDPH�YDOXHV�DV�GR�D�P��DQG�S�P��

'' 'D\�RI�PRQWK��������

''' 'D\�RI�\HDU�����������LQFOXGLQJ�OHDS�\HDUV��

'$< 1DPH�RI�GD\��LQFOXGLQJ�XS�WR�QLQH�FKDUDFWHUV��IRU�H[DPSOH��:HGQHVGD\���7KH�'$<�IRUPDW�VWULQJ�LV�QRW�FDVH�VHQVLWLYH�

'< $EEUHYLDWHG�WKUHH�FKDUDFWHU�QDPH�IRU�D�GD\��IRU�H[DPSOH��:HG���7KH�'<�IRUPDW�VWULQJ�LV�QRW�FDVH�VHQVLWLYH�

++��++�� +RXU�RI�GD\��������

++�� +RXU�RI�GD\���������ZKHUH�]HUR�LV���$0��PLGQLJKW��

0, 0LQXWHV��������

72B'$7(�DQG�,6B'$7(�)RUPDW�6WULQJV�� ��

Page 64: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

RequirementsThe Informatica Server expects the format of the TO_DATE string to meet the following conditions:

� The format of the TO_DATE string must exactly match the format string. If it does not, the Informatica Server might return inaccurate values or skip the row. For example, if you pass the string ‘20200512’, representing May 12, 2020, to TO_DATE, you must include the format string YYYYMMDD. If you do not include a format string, the Informatica

55 )RXU�GLJLW�\HDU��IRU�H[DPSOH���������������8VH�ZKHQ�VRXUFH�VWULQJV�LQFOXGH�WZR�GLJLW�\HDUV��8VH�ZLWK�72B'$7(�WR�FRQYHUW�WZR�GLJLW�\HDUV�WR�IRXU�GLJLW�\HDUV����&XUUHQW�<HDU�%HWZHHQ����DQG�����,I�WKH�FXUUHQW�\HDU�LV�EHWZHHQ����DQG�����VXFK�DV�������DQG�WKH�\HDU�YDOXH�RI�WKH�VRXUFH�VWULQJ�LV�EHWZHHQ���DQG�����WKH�,QIRUPDWLFD�6HUYHU�UHWXUQV�WKH�QH[W�FHQWXU\�SOXV�WKH�WZR�GLJLW�\HDU�IURP�WKH�VRXUFH�VWULQJ��,I�WKH�\HDU�YDOXH�RI�WKH�VRXUFH�VWULQJ�LV�EHWZHHQ����DQG�����WKH�,QIRUPDWLFD�6HUYHU�UHWXUQV�WKH�FXUUHQW�FHQWXU\�SOXV�WKH�VSHFLILHG�WZR�GLJLW�\HDU��

��&XUUHQW�<HDU�%HWZHHQ���DQG�����,I�WKH�FXUUHQW�\HDU�LV�EHWZHHQ���DQG�����VXFK�DV�������DQG�WKH�VRXUFH�VWULQJ�\HDU�LV�EHWZHHQ���DQG�����WKH�,QIRUPDWLFD�6HUYHU�UHWXUQV�WKH�FXUUHQW�FHQWXU\�SOXV�WKH�WZR�GLJLW�\HDU�IURP�WKH�VRXUFH�VWULQJ��,I�WKH�VRXUFH�VWULQJ�\HDU�LV�EHWZHHQ����DQG�����WKH�,QIRUPDWLFD�6HUYHU�UHWXUQV�WKH�SUHYLRXV�FHQWXU\�SOXV�WKH�WZR�GLJLW�\HDU�IURP�WKH�VRXUFH�VWULQJ��

66 6HFRQGV��������

66666 6HFRQGV�VLQFH�PLGQLJKW��:KHQ�\RX�XVH�66666�LQ�D�72B'$7(�H[SUHVVLRQ��WKH�,QIRUPDWLFD�6HUYHU�RQO\�HYDOXDWHV�WKH�WLPH�SRUWLRQ�RI�D�GDWH�)RU�H[DPSOH��WKH�H[SUHVVLRQ�72B'$7(��'$7(B675��µ00�''�<<<<�66666¶��FRQYHUWV�����������������WR���������������������

- 0RGLILHG�-XOLDQ�'D\��&RQYHUW�VWULQJV�LQ�0-'�IRUPDW�WR�GDWH�YDOXHV��,W�LJQRUHV�WKH�WLPH�FRPSRQHQW�RI�WKH�VRXUFH�VWULQJ��DVVLJQLQJ�DOO�GDWHV�WKH�WLPH�RI����������)RU�H[DPSOH��WKH�H[SUHVVLRQ�72B'$7(�µ�������¶��µ-¶���FRQYHUWV���������WR�'HF������������������

00 0RQWK��������

0217+ 1DPH�RI�PRQWK��LQFOXGLQJ�XS�WR�QLQH�FKDUDFWHUV��IRU�H[DPSOH��$XJXVW���&DVH�GRHV�QRW�PDWWHU�

021 $EEUHYLDWHG�WKUHH�FKDUDFWHU�QDPH�IRU�D�PRQWK��IRU�H[DPSOH��$XJ���&DVH�GRHV�QRW�PDWWHU�

< 7KH�FXUUHQW�\HDU�RQ�WKH�PDFKLQH�UXQQLQJ�WKH�,QIRUPDWLFD�6HUYHU�ZLWK�WKH�ODVW�GLJLW�RI�WKH�\HDU�UHSODFHG�ZLWK�WKH�VWULQJ�YDOXH�

<< 7KH�FXUUHQW�\HDU�RQ�WKH�PDFKLQH�UXQQLQJ�WKH�,QIRUPDWLFD�6HUYHU�ZLWK�WKH�ODVW�WZR�GLJLWV�RI�WKH�\HDU�UHSODFHG�ZLWK�WKH�VWULQJ�YDOXH�

<<< 7KH�FXUUHQW�\HDU�RQ�WKH�PDFKLQH�UXQQLQJ�WKH�,QIRUPDWLFD�6HUYHU�ZLWK�WKH�ODVW�WKUHH�GLJLWV�RI�WKH�\HDU�UHSODFHG�ZLWK�WKH�VWULQJ�YDOXH�

<<<< )RXU�GLJLWV�RI�D�\HDU��'R�QRW�XVH�WKLV�IRUPDW�VWULQJ�LI�\RX�DUH�SDVVLQJ�WZR�GLJLW�\HDUV��8VH�WKH�55�RU�<<�IRUPDW�VWULQJ�LQVWHDG�

Table 5-6. TO_DATE and IS_DATE Format Strings

)RUPDW�6WULQJ 'HVFULSWLRQ

��� &KDSWHU����'DWHV

Page 65: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Server expects the string in the default date format MM/DD/YYYY HH24:MI:SS. Likewise, if you pass a string that does not match the format string, the Informatica Server returns an error and skips the row. For example, if you pass the string 2020120 to TO_DATE and include the format string YYYYMMDD, the Informatica Server returns an error and skips the row because the string does not match the format string.

� The format string must always be enclosed within single quotation marks.

TipsThe following tips can improve your session performance:

� By default, the Informatica Server uses the format string MM/DD/YYYY HH24:MI:SS.

� The format string is not case-sensitive.

ExampleThe following examples illustrate the J, RR, and SSSSS format strings. See the individual functions for more examples.

J Format StringThe following expression converts strings in the SHIP_DATE_MJD_STRING port to date values in the default date format:

TO_DATE (SHIP_DATE_MJD_STR, ’J’)

Because the J format string does not include the time portion of a date, the return values have the time set to 00:00:00.

SHIP_DATE_MJD_STR RETURN_VALUE

2451544 Dec 31 1999 00:00:00

2415021 Jan 1 1900 00:00:00

72B'$7(�DQG�,6B'$7(�)RUPDW�6WULQJV�� ��

Page 66: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

RR Format StringThe following expression converts a string into a four-digit year format. The current year is 1998:

TO_DATE( DATE_STR, ‘MM/DD/RR’)

YY Format StringThe following expression converts a string into a four-digit year format. The current year is 1998:

TO_DATE( DATE_STR, ‘MM/DD/YY’)

-�����For the second row, RR returns the year 2005, while YY returns the year 1905.

SSSSS Format StringThe following expression converts strings that include the seconds since midnight to date values:

TO_DATE( DATE_STR, 'MM/DD/YYYY SSSSS')

DATE_STR RETURN VALUE

04/01/98 04/01/1998 00:00:00

08/17/05 08/17/2005 00:00:00

DATE_STR RETURN VALUE

04/01/98 04/01/1998 00:00:00

08/17/05 08/17/1905 00:00:00

DATE_STR RETURN_VALUE

12/31/1999 3783 12/31/1999 01:02:03

09/15/1996 86399 09/15/1996 23:59:59

��� &KDSWHU����'DWHV

Page 67: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Understanding Date Arithmetic

The transformation language provides built-in date functions so you can perform arithmetic on date/time values as follows:

� ADD_TO_DATE. Add or subtract a specific portion of a date.

� DATE_DIFF. Subtract two dates.

� SESSSTARTTIME. Return the difference between a date and the session start time.

� SET_DATE_PART. Change one part of a date.

You cannot use numeric arithmetic operators (such as + or -) to add or subtract dates.

The transformation language recognizes leap years and accepts dates between Jan. 1, 1753 00:00:00 AD and Dec. 31, 9999 23:59:59 AD.

-�����The transformation language uses the transformation Date/Time datatype to specify date values. You can only use the date functions on Date/Time values.

8QGHUVWDQGLQJ�'DWH�$ULWKPHWLF�� ��

Page 68: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

��� &KDSWHU����'DWHV

Page 69: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� � � � � � � � �

Functions

This chapter describes all the functions in the transformation languages, in alphabetical order. Each function description includes:

� Syntax

� Return value

� Example

For a quick reference to these functions, see “Function Quick Reference” on page 193.

���

Page 70: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Function Categories

The transformation language provides the following types of functions:

� Aggregate

� Character

� Conversion

� Date

� Numerical

� Scientific

� Special

� Test

� Variable

Aggregate FunctionsAggregate functions return summary values for non-null values in selected ports. With aggregate functions you can:

� Calculate a single value for all rows in a group.

� Return a single value for each group in an Aggregator transformation.

� Apply filters to calculate values for specific rows in the selected ports.

� Use operators to perform arithmetic within the function.

� Calculate two or more aggregate values derived from the same source columns in a single pass.

The transformation language includes the following aggregate functions:

� AVG

� COUNT

� FIRST

� LAST

� MAX (Date)

� MAX (Number)

� MEDIAN

� MIN (Date)

� MIN (Number)

� PERCENTILE

� STDDEV

� SUM

��� &KDSWHU����)XQFWLRQV

Page 71: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� VARIANCE

If you configure the Informatica Server to run in Unicode mode, MIN and MAX return values according to the sort order of the code page you specify in the session properties.

You can use aggregate functions in Aggregator transformations only. You can nest only one aggregate function within another aggregate function. The Informatica Server will evaluate the innermost aggregate function expression, and use the result to evaluate the outer aggregate function expression. You can set up an Aggregator transformation that groups by ID and nests two aggregate functions as follows:

SUM( AVG( earnings ) )

where your dataset contains the following values:

The return value is 1085. The Informatica Server groups by ID, evaluates the AVG expression, and returns four values. Then it SUMS the four averages to get the result.

ID EARNINGS

1 32

1 45

1 100

1 650

1 800

2 65

2 74

2 76

2 763

2 916

3 20

3 45

3 99

3 100

3 347

4 25

4 112

4 250

4 347

4 560

)XQFWLRQ�&DWHJRULHV�� ��

Page 72: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Aggregate Functions and NullsWhen you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can have the Informatica Server treat null values in aggregate functions as NULL or zero.

By default, the Informatica Server treats null values as NULL in aggregate functions. If you pass an entire port of null values, the function returns NULL. You can optionally configure the Informatica Server so that if you pass an entire port of null values to an aggregate function, the function returns zero. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

Filter ConditionsA filter limits the rows returned in a search. You can apply a filter condition to all aggregate functions, as well as to CUME, MOVINGAVG, and MOVINGSUM. The filter condition must evaluate to TRUE, FALSE, or NULL. If the filter condition evaluates to NULL or FALSE, the Informatica Server does not select the row.

You can enter any valid transformation expression. For example, the following expression calculates the median salary for all employees who make more than $50,000:

MEDIAN( SALARY, SALARY > 50000 )

You can also use other numeric values as the filter condition. For example, you can enter the following as the complete syntax for the MEDIAN function, including a numeric port:

MEDIAN( PRICE, QUANTITY > 0 )

In all cases, the Informatica Server rounds a decimal value to an integer (for example, 1.5 to 2, 1.2 to 1, 0.35 to 0) for the filter condition. If the value rounds to zero, the filter condition returns FALSE. If you do not want to round up a value, you can use the TRUNC function to truncate the value to an integer:

MEDIAN( PRICE, TRUNC( QUANTITY ) > 0 )

If you omit the filter condition, the function selects all rows in the port.

Character FunctionsThe transformation language includes the following character functions:

� ASCII

� CHR

� CHRCODE

� CONCAT

� INITCAP

� INSTR

� LENGTH

��� &KDSWHU����)XQFWLRQV

Page 73: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� LOWER

� LPAD

� LTRIM

� RPAD

� RTRIM

� SUBSTR

� UPPER

The character functions MAX, MIN, LOWER, UPPER, and INITCAP use the code page of the Informatica Server to evaluate character data.

Conversion FunctionsThe transformation language includes the following conversion functions:

� TO_CHAR(Date)

� TO_CHAR(Number)

� TO_DATE

� TO_DECIMAL

� TO_FLOAT

� TO_INTEGER

� TO_NUMBER

Date Functions The transformation language includes a group of date functions to help you round, truncate, or compare dates, extract one part of a date, or perform arithmetic on a date.

You can pass any value with a date datatype to any of the date functions. However, if you want to pass a string to a date function, you must first use the TO_DATE function to convert it to a transformation Date/Time datatype.

The transformation language includes the following date functions:

� ADD_TO_DATE

� DATE_COMPARE

� DATE_DIFF

� GET_DATE_PART

� LAST_DAY

� MAX

� MIN

� ROUND

)XQFWLRQ�&DWHJRULHV�� ��

Page 74: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� SET_DATE_PART

� TRUNC

Several of the date functions include a format argument. You must specify one of the transformation language format strings for this argument. Date format strings are not internationalized. For a complete list of date format strings, see “Dates” on page 31.

The Date/Time transformation datatype does not support milliseconds. Therefore, if you pass a date with milliseconds, the Informatica Server truncates the millisecond portion of the date.

Numerical Functions The transformation language includes the following numerical functions:

� ABS

� CEIL

� CUME

� EXP

� FLOOR

� LN

� LOG

� MOD

� MOVINGAVG

� MOVINGSUM

� POWER

� ROUND

� SIGN

� SQRT

� TRUNC

Scientific FunctionsThe transformation language includes the following scientific functions:

� COS

� COSH

� SIN

� SINH

� TAN

� TANH

��� &KDSWHU����)XQFWLRQV

Page 75: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Special Functions The transformation language includes the following special functions:

� ABORT

� DECODE

� ERROR

� IIF

� LOOKUP

Generally, you use special functions in Expression, Filter, and Update Strategy transformations. You can nest other functions within special functions. You can also nest a special function in an aggregate function.

Test Functions The transformation language includes the following test functions:

� ISNULL

� IS_DATE

� IS_NUMBER

� IS_SPACES

Variable FunctionsThe transformation language includes a group of variable functions to help you update the current value of a mapping variable throughout the session run. When you run a session, the Informatica Server evaluates the start and current value of a variable at the beginning of the session based on the final value of the variable from the last session run. You can use the following variable functions:

� SetCountVariable

� SetMaxVariable

� SetMinVariable

� SetVariable

You can use different variable functions with a variable based on the aggregation type of the variable.

When using mapping variables in partitioned sessions, use variable functions to determine the final value of the variable for each partition. At the end of the session, the Informatica Server performs the aggregate function across all partitions to determine one final value to save to the repository. Unless overridden, it uses the saved value as the start value of the variable for the next session run.

For example, you use SetMinVariable to set a variable to the minimum evaluated value. The Informatica Server calculates the minimum current value for the variable for each partition.

)XQFWLRQ�&DWHJRULHV�� ��

Page 76: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Then at the end of the session, it finds the minimum current value across all partitions and saves that value into the repository.

For more information on mapping variables, see “Mapping Parameters and Variables” in the Designer Guide. For more information on mapping variables in partitioned sessions, see “Partitioning Data” in the Session and Server Guide.

��� &KDSWHU����)XQFWLRQV

Page 77: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ABORT

Stops the session, and issues a specified error message to the session log file. When the Informatica Server encounters an ABORT function, it stops transforming data at that row. It processes any rows read before the session aborts and loads them based on the source- or target-based commit interval and the buffer block size defined for the session. The Informatica Server writes to the target up to the aborted row and then rolls back all uncommitted data to the last commit point. You can perform recovery on the session after rollback. For details on recovery, see “Commit Points and Recovery” in the Session and Server Guide.

You can use ABORT to validate data. Generally, you use ABORT within an IIF or DECODE function to set rules for aborting a session.

You can use the ABORT function for both input and output port default values. You might use ABORT for input ports to keep null values from passing into a transformation. You can also use ABORT to handle any kind of transformation error, including ERROR function calls within an expression. The default value overrides the ERROR function in an expression. If you want to ensure the session stops when an error occurs, assign ABORT as the default value.

If you use ABORT in an expression for an unconnected port, the Informatica Server does not execute the ABORT function.

-�����The Informatica Server handles the ABORT function and the Abort command you issue from the Server Manager differently. For more information on the Abort command, see “Working with Sessions” or “Commit Points and Recovery” in the Session and Server Guide.

SyntaxABORT( string )

Return ValueNULL.

Recovering from Aborted SessionsIf you want to recover data from an aborted session, use the Perform Recovery option in the session property sheet. When the Informatica Server recovers a session, it reads sources from the first row of uncommitted data.

$UJXPHQW 0HDQLQJ

VWULQJ 5HTXLUHG��6WULQJ��7KH�PHVVDJH�\RX�ZDQW�WR�GLVSOD\�LQ�WKH�VHVVLRQ�ORJ�ILOH�ZKHQ�WKH�VHVVLRQ�VWRSV��7KH�VWULQJ�FDQ�EH�DQ\�OHQJWK��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

$%257�� ��

Page 78: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

If you do not enable Perform Recovery for the session, when you rerun the session, the Informatica Server runs the entire session again, starting with the first row. Therefore, you might need to manually edit your target tables before running the session again.

-�����You cannot perform recovery if you did not enable Recovery in the Informatica Server configuration when you ran the initial session. For more information about recovery restrictions, see “Commit Points and Recovery” in the Session and Server Guide.

ExampleThe following expression aborts the session if a negative value exists in the Salary port:

IIF( SALARY < 0, ABORT(’Negative salary found. Session aborted.’, SALARY )

SALARY RETURN VALUE

10000 10000

150000 150000

-15000 NULL (Session aborts. Informatica Server does not write the row.)

NULL (Informatica Server does not write the row.)

1005 (Informatica Server does not write the row.)

��� &KDSWHU����)XQFWLRQV

Page 79: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ABS

Returns the absolute value of a numeric value.

SyntaxABS( numeric_value )

Return ValuePositive numeric value. ABS returns the same datatype of the numeric value passed as an argument. If you pass a Double, it returns a Double. Likewise, if you pass an Integer, it returns an Integer.

NULL if you pass a null value to the function.

-�����If the return value is Decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

ExampleThe following expression returns the difference between two numbers as a positive value, regardless of which number is larger:

ABS( PRICE - COST )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�UHWXUQ�WKH�DEVROXWH�YDOXHV��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

PRICE COST RETURN VALUE

250 150 100

52 48 4

169.95 69.95 100

59.95 NULL NULL

70 30 40

430 330 100

100 200 100

$%6�� ��

Page 80: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ADD_TO_DATE

Adds a specified amount to one part of a date/time value, and returns a date in the same format as the date you pass to the function. ADD_TO_DATE accepts positive and negative integer values. You can use ADD_TO_DATE to change the following parts of a date:

� Year. Enter a positive or negative integer in the amount argument. You can use any of the year format strings: Y, YY, YYY, or YYYY. For example, the expression ADD_TO_DATE ( SHIP_DATE, ’YY’, 10 ) adds 10 years to all dates in the SHIP_DATE port.

� Month. Enter a positive or negative integer in the amount argument. You can use any of the month format strings: MM, MON, MONTH. For example, the expression ADD_TO_DATE( SHIP_DATE, ’MONTH’, -10 ) subtracts 10 months from each date in the SHIP_DATE port.

� Day. Enter a positive or negative integer in the amount argument. You can use any of the day format strings: D, DD, DDD, DY, and DAY. For example, the expression ADD_TO_DATE( SHIP_DATE, ’DD’, 10 ) adds 10 days to each date in the SHIP_DATE port.

� Hour. Enter a positive or negative integer in the amount argument. You can use any of the hour format strings: HH, HH12, HH24. For example, the expression ADD_TO_DATE( SHIP_DATE, ’HH’, 14 ) adds 14 hours to each date in the SHIP_DATE port.

� Minute. Enter a positive or negative integer in the amount argument. You use the MI format string to set the minute. For example, the expression ADD_TO_DATE( SHIP_DATE, ’MI’, 25 ) adds 25 minutes to each date in the SHIP_DATE port.

� Seconds. Enter a positive or negative integer in the amount argument. You use the SS format string to set the second. For example, the expression ADD_TO_DATE( SHIP_DATE, ’SS’, 59 ) adds 59 seconds to each date in the SHIP_DATE port.

SyntaxADD_TO_DATE( date, format, amount )

$UJXPHQW 0HDQLQJ

GDWH� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�FKDQJH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��

IRUPDW� 5HTXLUHG��$�IRUPDW�VWULQJ�VSHFLI\LQJ�WKH�SRUWLRQ�RI�WKH�GDWH�YDOXH�\RX�ZDQW�WR�FKDQJH��(QFORVH�WKH�IRUPDW�VWULQJ�ZLWKLQ�VLQJOH�TXRWDWLRQ�PDUNV��IRU�H[DPSOH��PP��1RWH�WKDW�WKH�IRUPDW�VWULQJ�LV�QRW�FDVH�VHQVLWLYH��

DPRXQW� 5HTXLUHG��$Q�LQWHJHU�YDOXH�VSHFLI\LQJ�WKH�DPRXQW�RI�\HDUV��PRQWKV��GD\V��KRXUV��DQG�VR�RQ�E\�ZKLFK�\RX�ZDQW�WR�FKDQJH�WKH�GDWH�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�DQ�LQWHJHU��

��� &KDSWHU����)XQFWLRQV

Page 81: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Return ValueDate in the same format as the date you pass to this function.

NULL if a null value is passed as an argument to the function.

ExampleThe following expressions all add one month to each date in the DATE_SHIPPED port. If you pass a value that creates a day that does not exist in a particular month, the Informatica Server returns the last day of the month. For example, if you add one month to Jan 31 1998, the Informatica Server returns Feb 28 1998.

Also note, ADD_TO_DATE recognizes leap years and adds one month to Jan 29 2000:

ADD_TO_DATE( DATE_SHIPPED, ’MM’, 1 )

ADD_TO_DATE( DATE_SHIPPED, ’MON’, 1 )

ADD_TO_DATE( DATE_SHIPPED, ’MONTH’, 1 )

The following expressions subtract 10 days from each date in the DATE_SHIPPED port:

ADD_TO_DATE( DATE_SHIPPED, ’D’, -10 )

ADD_TO_DATE( DATE_SHIPPED, ’DD’, -10 )

ADD_TO_DATE( DATE_SHIPPED, ’DDD’, -10 )

ADD_TO_DATE( DATE_SHIPPED, ’DY’, -10 )

ADD_TO_DATE( DATE_SHIPPED, ’DAY’, -10 )

The following expressions subtract 15 hours from each date in the DATE_SHIPPED port:

ADD_TO_DATE( DATE_SHIPPED, ’HH’, -15 )

ADD_TO_DATE( DATE_SHIPPED, ’HH12’, -15 )

DATE_SHIPPED RETURN VALUE

Jan 12 1998 12:00:30AM Feb 12 1998 12:00:30AM

Jan 31 1998 6:24:45PM Feb 28 1998 6:24:45PM

Jan 29 2000 5:32:12AM Feb 29 2000 5:32:12AM (Leap Year)

Oct 9 1998 2:30:12PM Nov 9 1998 2:30:12PM

NULL NULL

DATE_SHIPPED RETURN VALUE

Jan 1 1997 12:00:30AM Dec 22 1996 12:00AM

Jan 31 1997 6:24:45PM Jan 21 1997 6:24:45PM

Mar 9 1996 5:32:12AM Feb 29 1996 5:32:12AM (Leap Year)

Oct 9 1997 2:30:12PM Sep 30 1997 2:30:12PM

Mar 3 1996 5:12:20AM Feb 22 1996 5:12:20AM

NULL NULL

$''B72B'$7(�� ��

Page 82: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ADD_TO_DATE( DATE_SHIPPED, ’HH24’, -15 )

Working with DatesUse the following tips when working with ADD_TO_DATE:

� You can add or subtract any part of the date by specifying a format string and making the amount argument a positive or negative integer.

� If you pass a value that creates a day that does not exist in a particular month, the Informatica Server returns the last day of the month. For example, if you add one month to Jan 31 1998, the Informatica Server returns Feb 28 1998.

� You can nest TRUNC and ROUND to help you manipulate dates.

� You can nest TO_DATE to convert strings to dates.

� ADD_TO_DATE changes only one portion of the date, which you specify. If you modify a date so that it changes from standard to daylight savings time, you need to change the hour portion of the date.

DATE_SHIPPED RETURN VALUE

Jan 1 1997 12:00:30AM Dec 31 1996 9:00:30AM

Jan 31 1997 6:24:45PM Jan 31 1997 3:24:45AM

Oct 9 1997 2:30:12PM Oct 8 1997 11:30:12PM

Mar 3 1996 5:12:20AM Mar 2 1996 2:12:20PM

Mar 1 1996 5:32:12AM Feb 29 1996 2:32:12PM (Leap Year)

NULL NULL

��� &KDSWHU����)XQFWLRQV

Page 83: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ASCII

When you configure the Informatica Server to run in ASCII mode, the ASCII function returns the numeric ASCII value of the first character of the string passed to the function.

When you configure the Informatica Server to run in Unicode mode, the ASCII function returns the numeric Unicode value of the first character of the string passed to the function. Unicode values fall in the range 0 to 65,535.

You can pass a string of any size to ASCII, but it evaluates only the first character in the string. Normally, before you pass any string value to ASCII, you parse out the specific character you want to convert to an ASCII or Unicode value. For example, you might use RTRIM or another string-manipulation function to do this. If you pass a numeric value, ASCII converts it to a character string and returns the ASCII or Unicode value of the first character in the string.

This function is identical in behavior to the CHRCODE function. If you use ASCII in your existing expressions, they will still work correctly, however, Informatica recommends using the CHRCODE function instead of the ASCII function to create new expressions.

SyntaxASCII ( string )

Return ValueInteger. The ASCII or Unicode value of the first character in the string.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the ASCII or Unicode value for the first character of each value in the ITEMS port:

ASCII( ITEMS )

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��&KDUDFWHU�VWULQJ��3DVVHV�WKH�YDOXH�\RX�ZDQW�WR�UHWXUQ�DV�DQ�$6&,,�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ITEMS RETURN VALUE

Flashlight 70

Compass 67

Safety Knife 83

Depth/Pressure Gauge 68

Regulator System 82

$6&,,�� ��

Page 84: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

AVG

Returns the average of all values in a group of rows. Optionally, you can apply a filter to limit the rows you read to calculate the average.

AVG is one of several aggregate functions. You can nest only one other aggregate function within AVG, and the nested function must return a Numeric datatype. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

SyntaxAVG( numeric_value [, filter_condition ] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����If the return value is decimal with precision greater than 15, you might want to select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsIf a value is NULL, AVG ignores the row. However, if all values passed from the port are NULL, AVG returns NULL.

-�����By default, the Informatica Server treats null values as NULLs in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�DQ�DYHUDJH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

��� &KDSWHU����)XQFWLRQV

Page 85: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Group ByAVG groups values based on group by ports you define in the transformation, returning one result for each group.

If there is not a group by port, AVG treats all rows as one group, returning one value.

ExampleThe following expression returns the average wholesale cost of flashlights:

AVG( WHOLESALE_COST, ITEM_NAME=’Flashlight’ )

TipYou can perform arithmetic on the values passed to AVG before the function calculates the average. For example:

AVG( QTY * PRICE - DISCOUNT )

ITEM_NAME WHOLESALE_COST

Flashlight 35.00

Navigation Compass 8.05

Regulator System 150.00

Flashlight 29.00

Depth/Pressure Gauge

88.00

Flashlight 31.00

RETURN VALUE: 31.66

$9*�� ��

Page 86: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

CEIL

Returns the smallest integer greater than or equal to the numeric value passed to this function. For example, if you pass 3.14 to CEIL, the function returns 4. If you pass 3.98 to CEIL, the function returns 4. Likewise, if you pass -3.17 to CEIL, the function returns -3.

SyntaxCEIL( numeric_value )

Return ValueInteger if you pass a numeric value with declared precision between 0 and 28.

Double value if you pass a numeric value with declared precision greater than 28.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the price rounded to the next integer:

CEIL( PRICE )

TipYou can perform arithmetic on the values passed to CEIL before CEIL returns the next integer value. For example, if you wanted to multiply a numeric value by 10 before you calculated the smallest integer less than the modified value, you might write the function as follows:

CEIL( PRICE * 10 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��

PRICE RETURN VALUE

39.79 40

125.12 126

74.24 75

NULL NULL

-100.99 -100

��� &KDSWHU����)XQFWLRQV

Page 87: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

CHR

When you configure the Informatica Server to move data in ASCII mode, CHR returns the ASCII character corresponding to the numeric value you pass to this function. ASCII values fall in the range 0 to 255. You can pass any integer to CHR, but only ASCII codes 32 to 126 are printable characters.

When you configure the Informatica Server to move data in Unicode mode, CHR returns the Unicode character corresponding to the numeric value you pass to this function. Unicode values fall in the range 0 to 65,535.

SyntaxCHR( numeric_value )

Return ValueASCII or Unicode character. A string containing one character.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the ASCII or Unicode character for each numeric value in the ITEM_ID port:

CHR( ITEM_ID )

Use the CHR function to concatenate a single quote onto a string. The single quote is the only character that cannot be used inside a string literal. For example:

’Joan’ || CHR(39) || ’s car’

returns

Joan’s car

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��7KH�YDOXH�\RX�ZDQW�WR�UHWXUQ�DV�DQ�$6&,,�RU�8QLFRGH�FKDUDFWHU��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ITEM_ID RETURN VALUE

65 A

122 z

NULL NULL

88 X

100 d

71 G

&+5�� ��

Page 88: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

CHRCODE

When you configure the Informatica Server to run in ASCII mode, CHRCODE returns the numeric ASCII value of the first character of the string passed to the function. ASCII values fall in the range 0 to 255.

When you configure the Informatica Server to run in Unicode mode, CHRCODE returns the numeric Unicode value of the first character of the string passed to the function. Unicode values fall in the range 0 to 65,535.

Normally, before you pass any string value to CHRCODE, you parse out the specific character you want to convert to an ASCII or Unicode value. For example, you might use RTRIM or another string-manipulation function to do this. If you pass a numeric value, CHRCODE converts it to a character string and returns the ASCII or Unicode value of the first character in the string.

This function is identical in behavior to the ASCII function. If you currently use ASCII in your existing expressions, it will still work correctly. However, Informatica recommends using the CHRCODE function instead of the ASCII function to create new expressions.

SyntaxCHRCODE ( string )

Return ValueASCII or Unicode character. A string containing one character.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the ASCII or Unicode value for the first character of each value in the ITEMS port:

CHRCODE( ITEMS )

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��&KDUDFWHU�VWULQJ��3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�UHWXUQ�DV�$6&,,�RU�8QLFRGH�YDOXHV��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ITEMS RETURN VALUE

Flashlight 70

Compass 67

Safety Knife 83

Depth/Pressure Gauge 68

Regulator System 82

��� &KDSWHU����)XQFWLRQV

Page 89: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

CONCAT

Concatenates two strings. CONCAT converts all data to text before concatenating the strings. Alternatively, you can use the || string operator to concatenate strings. Using the || string operator instead of CONCAT improves Informatica Server performance when you run sessions.

SyntaxCONCAT( first_string, second_string )

Return ValueString.

NULL if both string values are NULL.

NullsIf one of the strings is NULL, CONCAT ignores it and returns the other string.

If both strings are NULL, CONCAT returns NULL.

ExampleThe following expression concatenates the names in the FIRST_NAME and LAST_NAME ports:

CONCAT( FIRST_NAME, LAST_NAME )

$UJXPHQW 0HDQLQJ

ILUVWBVWULQJ� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���7KH�ILUVW�SDUW�RI�WKH�VWULQJ�\RX�ZDQW�WR�FRQFDWHQDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

VHFRQGBVWULQJ� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���7KH�VHFRQG�SDUW�RI�WKH�VWULQJ�\RX�ZDQW�WR�FRQFDWHQDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

FIRST_NAME LAST_NAME RETURN VALUE

John Baer JohnBaer

NULL Campbell Campbell (includes leading space)

Bobbi Apperley BobbiApperley

Jason Wood JasonWood

Dan Covington DanCovington

Greg NULL Greg (includes trailing space)

NULL NULL NULL

100 200 100200

&21&$7�� ��

Page 90: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Note that CONCAT does not add spaces to separate strings. If you want to add a space between two strings, you can write an expression with two nested CONCAT functions. For example, the following expression first concatenates a space on the end of the first name and then concatenates the last name:

CONCAT( CONCAT( FIRST_NAME, ’ ’ ), LAST_NAME )

Use the CHR and CONCAT functions to concatenate a single quote onto a string. The single quote is the only character that cannot be used inside a string literal. For example:

CONCAT( ’Joan’, CONCAT( CHR(39), ’s car’ ))

returns

Joan’s car

FIRST_NAME LAST_NAME RETURN VALUE

John Baer John Baer

NULL Campbell Campbell

Bobbi Apperley Bobbi Apperley

Jason Wood Jason Wood

Dan Covington Dan Covington

Greg NULL Greg

NULL NULL NULL

��� &KDSWHU����)XQFWLRQV

Page 91: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

COS

Returns the cosine of a numeric value (expressed in radians).

SyntaxCOS( numeric_value )

Return ValueDouble value.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the cosine for all values in the Degrees port:

COS( DEGREES * 3.14159265359 / 180 )

TipYou can perform arithmetic on the values passed to COS before the function calculates the cosine. For example, you can convert the values in the port to radians before calculating the cosine, as follows:

COS( ARCS * 3.14159265359 / 180 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��1XPHULF�GDWD�H[SUHVVHG�LQ�UDGLDQV��GHJUHHV�PXOWLSOLHG�E\�SL�GLYLGHG�E\�������3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�D�FRVLQH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

DEGREES RETURN VALUE

0 1.0

90 0.0

70 0.342020143325593

50 0.642787609686495

30 0.866025403784421

5 0.996194698091745

18 0.951056516295147

89 0.0174524064371813

NULL NULL

&26�� ��

Page 92: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

COSH

Returns the hyperbolic cosine of a numeric value (expressed in radians).

SyntaxCOSH( numeric_value )

Return ValueDouble value.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the hyperbolic cosine for the values in the Angles port:

COSH( ANGLES )

TipYou can perform arithmetic on the values passed to COSH before the function calculates the hyperbolic cosine. For example:

COSH( MEASURES.ARCS / 360 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��1XPHULF�GDWD�H[SUHVVHG�LQ�UDGLDQV��GHJUHHV�PXOWLSOLHG�E\�SL�GLYLGHG�E\�������3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�WKH�K\SHUEROLF�FRVLQH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ANGLES RETURN VALUE

1.0 1.54308063481524

2.897 9.0874465864177

3.66 19.4435376920294

5.45 116.381231106176

0 1.0

0.345 1.06010513656773

NULL NULL

��� &KDSWHU����)XQFWLRQV

Page 93: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

COUNT

Returns the number of rows that have non-null values in a group. Optionally, you can include the asterisk (*) argument to count all input values in a transformation.

COUNT is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. You can nest only one other aggregate function within COUNT. You can apply a condition to filter rows before counting them. For more information, see “Aggregate Functions” on page 48.

SyntaxCOUNT( value [, filter_condition] )

or

COUNT( * [, filter_condition] )

Return ValueInteger.

Zero if all values passed to this function are NULL (unless you include the asterisk argument).

NullsIf all values are NULL, the function returns 0.

If you apply the asterisk argument, this function counts all rows, including null values.

If you apply the value argument, this function ignores rows with null values.

-�����By default, the Informatica Server treats null values as NULLs in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�FRXQW��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

� $OWHUQDWLYH��8VH�WR�FRXQW�DOO�URZV�LQ�D�WUDQVIRUPDWLRQ��LQFOXGLQJ�QXOO�YDOXHV��

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

&2817�� ��

Page 94: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Group ByCOUNT groups values based on group by ports you define in the transformation, returning one result for each group. If there is no group by port COUNT treats all rows as one group, returning one value.

ExampleThe following expression counts the items with less than 5 quantity in stock, excluding null values:

COUNT( ITEM_NAME, IN_STOCK < 5 )

In this example, the function counted the Halogen flashlight but not the NULL item. The function counts all rows in a transformation, including null values, as illustrated in the following example:

COUNT( *, QTY < 5 )

In this example, the function counts the NULL item and the Halogen Flashlight. If you include the asterisk argument, but do not use a filter, the function counts all rows that pass into the transformation. For example:

COUNT( * )

ITEM_NAME IN_STOCK

Flashlight 10

NULL 2

Compass NULL

Regulator System 5

Safety Knife 8

Halogen Flashlight 1

RETURN VALUE: 1

ITEM_NAME QTY

Flashlight 10

NULL 2

Compass NULL

Regulator System 5

Safety Knife 8

Halogen Flashlight 1

RETURN VALUE: 2

ITEM_NAME QTY

Flashlight 10

NULL 2

��� &KDSWHU����)XQFWLRQV

Page 95: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Compass NULL

Regulator System 5

Safety Knife 8

Halogen Flashlight 1

RETURN VALUE: 6

ITEM_NAME QTY

&2817�� ��

Page 96: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

CUME

Returns a running total. A running total means CUME returns a total each time it adds a value. You can add a condition to filter rows out of the row set before calculating the running total.

Use CUME and similar functions (such as MOVINGAVG and MOVINGSUM) to simplify reporting by calculating running values.

SyntaxCUME( numeric_value [, filter_condition] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����If the return value is decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsIf a value is NULL, CUME returns the running total for the previous row. However, if all values in the selected port are NULL, CUME returns NULL.

ExampleThe following sample rowset might result from using the CUME function:

CUME( PERSONAL_SALES )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�D�UXQQLQJ�WRWDO��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��<RX�FDQ�FUHDWH�D�QHVWHG�H[SUHVVLRQ�WR�FDOFXODWH�D�UXQQLQJ�WRWDO�EDVHG�RQ�WKH�UHVXOWV�RI�WKH�IXQFWLRQ�DV�ORQJ�DV�WKH�UHVXOW�LV�D�QXPHULF�YDOXH�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

PERSONAL_SALES RETURN VALUE

40000 40000

80000 120000

40000 160000

��� &KDSWHU����)XQFWLRQV

Page 97: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Likewise, you can add values before calculating a running total:

CUME( CA_SALES + OR_SALES )

60000 220000

NULL 220000

50000 270000

CA_SALES OR_SALES RETURN VALUE

40000 10000 50000

80000 50000 180000

40000 2000 222000

60000 NULL 222000

NULL NULL 222000

50000 3000 275000

PERSONAL_SALES RETURN VALUE

&80(�� ��

Page 98: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DATE_COMPARE

Returns an integer indicating which of two dates is earlier. Note that DATE_COMPARE returns an integer value rather than a date value.

SyntaxDATE_COMPARE( date1, date2 )

Return Value-1 if the first date is earlier.

0 if the two dates are equal.

1 if the second date is earlier.

NULL if one of the date values is NULL.

ExampleThe following expression compares each date in the DATE_PROMISED and DATE_SHIPPED ports, and returns an integer indicating which date is earlier:

DATE_COMPARE( DATE_PROMISED, DATE_SHIPPED )

$UJXPHQW 0HDQLQJ

GDWH�� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��7KH�ILUVW�GDWH�\RX�ZDQW�WR�FRPSDUH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�DV�ORQJ�DV�LW�HYDOXDWHV�WR�D�GDWH�

GDWH�� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��7KH�VHFRQG�GDWH�\RX�ZDQW�WR�FRPSDUH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�DV�ORQJ�DV�LW�HYDOXDWHV�WR�D�GDWH�

DATE_PROMISED DATE_SHIPPED RETURN VALUE

Jan 1 1997 Jan 13 1997 -1

Feb 1 1997 Feb 1 1997 0

Dec 22 1997 Dec 15 1997 1

Feb 29 1996 Apr 12 1996 -1 (Leap year)

NULL Jan 6 1997 NULL

Jan 13 1997 NULL NULL

��� &KDSWHU����)XQFWLRQV

Page 99: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DATE_DIFF

Returns the length of time, measured in the increment you specify (years, months, days, hours, minutes, or seconds), between two dates. The Informatica Server subtracts the second date from the first date and returns the difference.

SyntaxDATE_DIFF( date1, date2, format )

Return ValueDouble value. If date1 is later than date2, the return value is a positive number. If date1 is earlier than date2, the return value is a negative number.

Zero if the dates are the same.

NULL if one (or both) of the date values is NULL.

ExampleThe following expressions return the number of hours between the DATE_PROMISED and DATE_SHIPPED ports:

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’HH’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’HH12’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’HH24’ )

$UJXPHQW 0HDQLQJ

GDWH�� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��3DVVHV�WKH�YDOXHV�IRU�WKH�ILUVW�GDWH�\RX�ZDQW�WR�FRPSDUH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

GDWH�� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��3DVVHV�WKH�YDOXHV�IRU�WKH�VHFRQG�GDWH�\RX�ZDQW�WR�FRPSDUH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

IRUPDW� 5HTXLUHG��)RUPDW�VWULQJ�VSHFLI\LQJ�WKH�GDWH�RU�WLPH�PHDVXUHPHQW��\HDU��VHFRQG��DQG�VR�RQ��XVHG�WR�FRPSDUH�WKH�WZR�GDWHV��<RX�FDQ�VSHFLI\�RQO\�RQH�SDUW�RI�WKH�GDWH��IRU�H[DPSOH��PP��%H�VXUH�WR�HQFORVH�WKH�IRUPDW�VWULQJV�ZLWKLQ�VLQJOH�TXRWDWLRQ�PDUNV��7KH�IRUPDW�VWULQJ�LV�QRW�FDVH�VHQVLWLYH���)RU�H[DPSOH��WKH�IRUPDW�VWULQJ�PP�LV�WKH�VDPH�DV�00��0P�RU�P0��

DATE_PROMISED DATE_SHIPPED RETURN VALUE

Jan 1 1997 12:00:00AM Mar 29 1997 12:00:00PM -2100.0

Mar 29 1997 12:00:00PM Jan 1 1997 12:00:00AM 2100.0

Mar 10 1996 6:10:45PM Feb 29 1996 2:15:14AM 255.925277777016 (Leap year)

NULL Dec 10 1997 5:55:10PM NULL

Dec 10 1997 5:55:10PM NULL NULL

'$7(B',))�� ��

Page 100: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The following expressions return the number of days between the DATE_PROMISED and the DATE_SHIPPED ports:

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’D’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’DD’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’DDD’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’DY’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’DAY’ )

The following expressions return the number of months between the DATE_PROMISED and DATE_SHIPPED ports:

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’MM’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’MON’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’MONTH’ )

The following expressions return the number of years between the DATE_PROMISED and DATE_SHIPPED ports:

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’Y’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’YY’ )

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’YYY’ )

Jun 3 1997 1:13:46PM Aug 23 1996 4:20:16PM 6812.89166666567

DATE_PROMISED DATE_SHIPPED RETURN VALUE

Jan 1 1997 12:00:00AM Mar 29 1997 12:00:00PM -87.5

Mar 29 1997 12:00:00PM Jan 1 1997 12:00:00AM 87.5

Mar 10 1996 6:10:45PM Feb 29 1996 2:15:14AM 10.663553240709 (Leap year)

NULL Dec 10 1997 5:55:10PM NULL

Dec 10 1997 5:55:10PM NULL NULL

Jun 3 1997 1:13:46PM Aug 23 1996 4:20:16PM 283.870486111147

DATE_PROMISED DATE_SHIPPED RETURN VALUE

Jan 1 1997 12:00:00AM Mar 29 1997 12:00:00PM -2.91935483870839

Mar 29 1997 12:00:00PM Jan 1 1997 12:00:00AM 2.91935483870839

Mar 10 1996 6:10:45PM Feb 29 1996 2:15:14AM 0.346001356960187

NULL Dec 10 1997 5:55:10PM NULL

Dec 10 1997 5:55:10PM NULL NULL

Jun 3 1997 1:13:46PM Aug 23 1996 4:20:16PM 9.35340409697164

DATE_PROMISED DATE_SHIPPED RETURN VALUE

��� &KDSWHU����)XQFWLRQV

Page 101: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, ’YYYY’ )

DATE_PROMISED DATE_SHIPPED RETURN VALUE

Jan 1 1997 12:00:00AM Mar 29 1997 12:00:00PM -0.243279569892366

Mar 29 1997 12:00:00PM Jan 1 1997 12:00:00AM 0.243279569892366

Mar 10 1996 6:10:45PM Feb 29 1996 2:15:14AM 0.0288334464133489 (Leap year)

NULL Dec 10 1997 5:55:10PM NULL

Dec 10 1997 5:55:10PM NULL NULL

Jun 3 1997 1:13:46PM Aug 23 1996 4:20:16PM 0.779450341414304

'$7(B',))�� ��

Page 102: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DECODE

Searches a port for a value you specify. If the function finds the value, it returns a result value, which you define. You can build an unlimited number of searches within a DECODE function.

If you write a DECODE expression with multiple searches, DECODE converts the value argument and each search value to the datatype of the first search argument.

If you use DECODE to search for a value in a string port, you can either trim trailing blanks with the RTRIM function or include the blanks in your search string.

SyntaxDECODE( value, first_search, first_result [, second_search, second_result]…[,default] )

Return ValueFirst_result if the search finds a matching value. The return value datatype always matches the first_result.

Default value if the search does not find a matching value.

NULL if you omit the default argument and the search does not find a matching value.

Even if multiple conditions are met, the Informatica Server returns the first matching result.

If your data contains multibyte characters and your DECODE expression compares string data, the return value depends on the code page and data movement mode of the Informatica Server.

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�VHDUFK��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

VHDUFK� 5HTXLUHG��$Q\�YDOXH�ZLWK�WKH�VDPH�GDWDW\SH�DV�WKH�YDOXH�DUJXPHQW��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�VHDUFK��7KH�VHDUFK�YDOXH�PXVW�PDWFK�WKH�YDOXH�DUJXPHQW�H[DFWO\��\RX�PD\�QRW�VHDUFK�IRU�D�SRUWLRQ�RI�D�YDOXH��$OVR�QRWH�WKDW�WKH�VHDUFK�YDOXH�LV�FDVH�VHQVLWLYH��)RU�H[DPSOH��LI�\RX�ZDQW�WR�VHDUFK�IRU�WKH�VWULQJ�+DORJHQ�)ODVKOLJKW�LQ�D�SDUWLFXODU�SRUW��\RX�PXVW�HQWHU�+DORJHQ�)ODVKOLJKW��QRW�MXVW�+DORJHQ��,I�\RX�HQWHU�+DORJHQ��WKH�VHDUFK�GRHV�QRW�ILQG�D�PDWFKLQJ�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

UHVXOW� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���7KH�YDOXH�\RX�ZDQW�WR�UHWXUQ�LI�WKH�VHDUFK�ILQGV�D�PDWFKLQJ�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��

GHIDXOW� 2SWLRQDO��$Q\�GDWDW\SH��H[FHSW�%LQDU\���7KH�YDOXH�\RX�ZDQW�WR�UHWXUQ�LI�WKH�VHDUFK�GRHV�QRW�ILQG�D�PDWFKLQJ�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��

��� &KDSWHU����)XQFWLRQV

Page 103: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleYou might use DECODE in an expression that searches for a particular ITEM_ID and returns the ITEM_NAME:

DECODE( ITEM_ID, 10, ’Flashlight’,

14, ’Regulator’,

20, ’Knife’,

40, ’Tank’,

’NONE’ )

Note that DECODE returns the default value of NONE for items 17 and 25 because the search values did not match the ITEM_ID. Also, DECODE returns NONE for the NULL ITEM_ID.

The following expression tests multiple columns and conditions, evaluated in a top to bottom order for TRUE or FALSE:

DECODE( TRUE,

Var1 = 22,’Variable 1 was 22!’,

Var2 = 49,’Variable 2 was 49!’,

Var1 < 23, ’Variable 1 was less than 23.’,

Var2 > 30, ’Variable 2 was more than 30.’,

’Variables were out of desired ranges.’)

ITEM_ID RETURN VALUE

10 Flashlight

14 Regulator

17 NONE

20 Knife

25 NONE

NULL NONE

40 Tank

Var1 Var2 RETURN VALUE

21 47 Variable 1 was less than 23.

22 49 Variable 1 was 22!

23 49 Variable 2 was 49!

24 27 Variables were out of desired ranges.

25 50 Variable 2 was more than 30.

'(&2'(�� ��

Page 104: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ERROR

Causes the Informatica Server to skip a row and issue an error message, which you define. The error message displays in the session log file. The Informatica Server does not write these skipped rows to the session reject file.

You can use ERROR in Expression transformations to validate data. Generally, you use ERROR within an IIF or DECODE function to set rules for skipping rows.

You can use the ERROR function for both input and output port default values. You might use ERROR for input ports to keep null values from passing into a transformation. You can also use ERROR to handle any kind of transformation error, including ERROR function calls within an expression. The default value overrides the ERROR function in an expression. If you want to ensure the Informatica Server skips rows that produce an error, assign ERROR as the default value.

SyntaxERROR( string )

Return ValueString value.

ExampleThe following example shows how you can reference a mapping that calculates the average salary for employees in all departments of your company, but skip negative values. The following expression nests the ERROR function in an IIF expression so that if the Informatica Server finds a negative salary in the Salary port, it skips the row and displays an error:

IIF( SALARY < 0, ERROR (’Error. Negative salary found. Row skipped.’, EMP_SALARY )

$UJXPHQW 0HDQLQJ

VWULQJ�� 5HTXLUHG��6WULQJ�YDOXH��7KH�PHVVDJH�\RX�ZDQW�WR�GLVSOD\�ZKHQ�WKH�,QIRUPDWLFD�6HUYHU�VNLSV�D�URZ�EDVHG�RQ�WKH�H[SUHVVLRQ�FRQWDLQLQJ�WKH�(5525�IXQFWLRQ��7KH�VWULQJ�FDQ�EH�DQ\�OHQJWK�

SALARY RETURN VALUE

10000 10000

-15000 ’Error. Negative salary found. Row skipped.’

NULL NULL

150000 150000

1005 1005

��� &KDSWHU����)XQFWLRQV

Page 105: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

EXP

Returns e raised to the specified power (exponent), where e=2.71828183. For example, EXP(2) returns 7.38905609893065. Most often, you use this function to analyze scientific and technical data, rather than business data. EXP is the reciprocal of the LN function, which returns the natural logarithm of a numeric value.

SyntaxEXP( exponent )

Return ValueDouble value.

NULL if a value passed as an argument to the function is NULL.

ExampleThe following expression uses the values stored in the Numbers port as the exponent value:

EXP( NUMBERS )

$UJXPHQW 0HDQLQJ

H[SRQHQW� 5HTXLUHG��1XPHULF�GDWDW\SH��7KH�YDOXH�WR�ZKLFK�\RX�ZDQW�WR�UDLVH�H���7KH�H[SRQHQW�LQ�WKH�HTXDWLRQ�HAYDOXH���<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

NUMBERS RETURN VALUE

10 22026.4657948067

-2 0.135335283236613

8.55 5166.754427176

NULL NULL

(;3�� ��

Page 106: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

FIRST

Returns the first row in a group. Optionally, you can apply a filter to limit the rows the Informatica Server reads. You can nest only one other aggregate function within FIRST.

FIRST is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

SyntaxFIRST( value [, filter_condition ] )

Return ValueFirst row in a group.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

NullsIf a value is NULL, FIRST ignores the row. However, if all values passed from the port are NULL, FIRST returns NULL.

-�����By default, the Informatica Server treats null values as NULLs in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

Group ByFIRST groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, FIRST treats all rows as one group, returning one value.

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�UHWXUQ�WKH�ILUVW�URZ��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

��� &KDSWHU����)XQFWLRQV

Page 107: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression returns the first row in the ITEMS_NAME port with a price greater than $10.00:

FIRST( ITEM_NAME, ITEM_PRICE > 10 )

ITEM_NAME ITEM_PRICE

Flashlight 35.00

Navigation Compass 8.05

Regulator System 150.00

Flashlight 29.00

Depth/Pressure Gauge 88.00

Flashlight 31.00

RETURN VALUE: Flashlight

),567�� ��

Page 108: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

FLOOR

Returns the largest integer less than or equal to the numeric value you pass to this function. For example, if you pass 3.14 to FLOOR, the function returns 3; if you pass 3.98 to FLOOR, the function returns 3. Likewise, if you pass -3.17 to FLOOR, the function returns -4.

SyntaxFLOOR( numeric_value )

Return ValueInteger if you pass a numeric value with declared precision between 0 and 28.

Double if you pass a numeric value with declared precision greater than 28.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the largest integer less than or equal to the values in the PRICE port:

FLOOR( PRICE )

TipYou can perform arithmetic on the values you pass to FLOOR. For example, if you wanted to multiply a numeric value by 10 before you calculate the largest integer less than the modified value, you might write the function as follows:

FLOOR( UNIT_PRICE * 10 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�DV�ORQJ�DV�LW�HYDOXDWHV�WR�QXPHULF�GDWD��

PRICE RETURN VALUE

39.79 39

125.12 125

74.24 74

NULL NULL

-100.99 -101

��� &KDSWHU����)XQFWLRQV

Page 109: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

GET_DATE_PART

Returns the specified part of a date as an integer value. Therefore, if you create an expression that returns the month portion of the date, and pass a date such as Apr 1 1997 00:00:00, GET_DATE_PART returns 4.

SyntaxGET_DATE_PART( date, format )

Return ValueInteger representing the specified part of the date.

NULL if a value passed to the function is NULL.

ExampleThe following expressions return the hour for each date in the DATE_SHIPPED port. Note that 12:00:00AM returns 0 because the default date format is based on the 24 hour interval:

GET_DATE_PART( DATE_SHIPPED, ’HH’ )

GET_DATE_PART( DATE_SHIPPED, ’HH12’ )

GET_DATE_PART( DATE_SHIPPED, ’HH24’ )

The following expressions return the day for each date in the DATE_SHIPPED port:

GET_DATE_PART( DATE_SHIPPED, ’D’ )

GET_DATE_PART( DATE_SHIPPED, ’DD’ )

$UJXPHQW 0HDQLQJ

GDWH� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

IRUPDW� 5HTXLUHG��$�IRUPDW�VWULQJ�VSHFLI\LQJ�WKH�SRUWLRQ�RI�WKH�GDWH�YDOXH�\RX�ZDQW�WR�FKDQJH��(QFORVH�IRUPDW�VWULQJV�ZLWKLQ�VLQJOH�TXRWDWLRQ�PDUNV��IRU�H[DPSOH��PP��7KH�IRUPDW�VWULQJ�LV�QRW�FDVH�VHQVLWLYH��(DFK�IRUPDW�VWULQJ�UHWXUQV�WKH�HQWLUH�SDUW�RI�WKH�GDWH�EDVHG�RQ�WKH�GHIDXOW�IRUPDW�RI�00�''�<<<<�++���0,�66��)RU�H[DPSOH��LI�\RX�SDVV�WKH�GDWH�$SU��������WR�*(7B'$7(B3$57��WKH�IRUPDW�VWULQJV�<��<<��<<<��RU�<<<<�DOO�UHWXUQ�������

DATE_SHIPPED RETURN VALUE

Mar 13 1997 12:00:00AM 0

Sep 2 1997 2:00:01AM 2

Aug 22 1997 12:00:00PM 12

June 3 1997 11:30:44PM 23

NULL NULL

*(7B'$7(B3$57�� ��

Page 110: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

GET_DATE_PART( DATE_SHIPPED, ’DDD’ )

GET_DATE_PART( DATE_SHIPPED, ’DY’ )

GET_DATE_PART( DATE_SHIPPED, ’DAY’ )

The following expressions return the month for each date in the DATE_SHIPPED port:

GET_DATE_PART( DATE_SHIPPED, ’MM’ )

GET_DATE_PART( DATE_SHIPPED, ’MON’ )

GET_DATE_PART( DATE_SHIPPED, ’MONTH’ )

The following expression return the year for each date in the DATE_SHIPPED port:

GET_DATE_PART( DATE_SHIPPED, ’Y’ )

GET_DATE_PART( DATE_SHIPPED, ’YY’ )

GET_DATE_PART( DATE_SHIPPED, ’YYY’ )

GET_DATE_PART( DATE_SHIPPED, ’YYYY’ )

DATE_SHIPPED RETURN VALUE

Mar 13 1997 12:00:00AM 13

June 3 1997 11:30:44PM 3

Aug 22 1997 12:00:00PM 22

NULL NULL

DATE_SHIPPED RETURN VALUE

Mar 13 1997 12:00:00AM 3

June 3 1997 11:30:44PM 6

NULL NULL

DATE_SHIPPED RETURN VALUE

Mar 13 1997 12:00:00AM 1997

June 3 1997 11:30:44PM 1997

NULL NULL

��� &KDSWHU����)XQFWLRQV

Page 111: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

IIF

Returns one of two values you specify, based on the results of a condition.

SyntaxIIF( condition, value1 [,value2] )

Unlike conditional functions in many other systems, the FALSE (value2) condition in the IIF function is not required. If you omit value2, the function returns the following when the condition is FALSE:

� 0 if value1 is a Numeric datatype.

� Empty string if value1 is a String datatype.

� NULL if value1 is a Date/Time datatype.

For example, the following expression does not include a FALSE condition and value1 is a string datatype so the Informatica Server returns an empty string for each row that evaluates to FALSE:

IIF( SALES > 100, EMP_NAME )

Return Valuevalue1 if the condition is TRUE.

value2 with the datatype of value1 if the condition is FALSE.

$UJXPHQW 0HDQLQJ

FRQGLWLRQ� 5HTXLUHG��7KH�FRQGLWLRQ�\RX�ZDQW�WR�HYDOXDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�758(�RU�)$/6(�

YDOXH�� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���7KH�YDOXH�\RX�ZDQW�WR�UHWXUQ�LI�WKH�FRQGLWLRQ�LV�758(��7KH�UHWXUQ�YDOXH�LV�DOZD\V�WKH�GDWDW\SH�VSHFLILHG�E\�WKLV�DUJXPHQW��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��LQFOXGLQJ�DQRWKHU�,,)�H[SUHVVLRQ�

YDOXH�� 2SWLRQDO��$Q\�GDWDW\SH��H[FHSW�%LQDU\���7KH�YDOXH�\RX�ZDQW�WR�UHWXUQ�LI�WKH�FRQGLWLRQ�LV�)$/6(��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��LQFOXGLQJ�DQRWKHU�,,)�H[SUHVVLRQ�

SALES EMP_NAME RETURN VALUE

150 John Smith John Smith

50 Pierre Bleu ’’ (empty string)

120 Sally Green Sally Green

NULL Greg Jones ’’ (empty string)

,,)�� ��

Page 112: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

For example, the following expression includes the FALSE condition NULL so the Informatica Server returns NULL for each row that evaluates to FALSE:

IIF( SALES > 100, EMP_NAME, NULL )

If your data contains multibyte characters and your condition argument compares string data, the return value depends on the code page and data movement mode of the Informatica Server.

IIF and DatatypesIIF handles datatypes differently based on the datatypes of each condition.

If you write an expression with both a TRUE (value1) and FALSE (value2) condition, IIF returns a value with the same datatype as value1.

If the datatype of value1 is an integer (for example, 0), then the return value is an integer.

IIF( SALES < 100, 0, SALARY )

-�����When the input is NULL the Informatica Server evaluates the condition as FALSE and returns a FALSE condition.

Check your expressions carefully when you use different datatypes for value1 and value2. The following example could yield undesired results:

IIF( SALES < 100, 0, .3333 )

The return value is an integer, so value2 gets rounded to 0.

-�����Since IIF returns value1’s datatype, you should check that the field you are populating has a datatype that is compatible with value1’s datatype.

SALES EMP_NAME RETURN VALUE

150 John Smith John Smith

50 Pierre Bleu NULL

120 Sally Green Sally Green

NULL Greg Jones NULL

SALES SALARY RETURN VALUE

150 50,000.00 50,000

120 70,000.41 70,000

50 20,000.00 0

NULL 50,000.41 50,000

SALES RETURN VALUE

150 0

50 0

��� &KDSWHU����)XQFWLRQV

Page 113: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

If, however, value1 does not have a datatype (for example, you include the ERROR or ABORT function), IIF returns a value with the same datatype as value2. For example:

IIF( SALES < 0, ERROR( ’Negative value found’ ), EMP_SALARY )

If the precision and scale of value1 differs from that of value2, the Informatica Server evaluates the expression and returns a value in the precision and scale of value1. For example:

REAL_SALES=IIF( ISNULL( SALES ), 0.0, SALES )

Since value1, 0.0, has one decimal place, the Informatica Server rounds each input value to one decimal place. The value 7.75 rounds to 7.8. To return more accurate values, specify 0.00 for value1.

Special Uses of IIFYou can use nested IIF statements to test multiple conditions. The following example tests for various conditions and returns 0 if sales is zero or negative:

IIF( SALES > 0, IIF( SALES < 50, SALARY1, IIF( SALES < 100, SALARY2, IIF( SALES < 200, SALARY3, BONUS))), 0 )

You can make this logic more readable by adding comments:

IIF( SALES > 0,

--then test to see if sales is between 1 and 49:

IIF( SALES < 50,

--then return SALARY1

SALARY1,

--else test to see if sales is between 50 and 99:

IIF( SALES < 100,

--then return

SALARY2,

SALES EMP_SALARY RETURN VALUE

100 10000.56 10000.56

-500 50000.82 Informatica Server skips row

400.55 2000.66 2000.66

800.10 30000.4 30000.43

SALES REAL_SALES

8 8.0

7.75 7.8

-6 -6.0

-7.45 -7.5

NULL 0.0

,,)�� ��

Page 114: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

--else test to see if sales is between 100 and 199:

IIF( SALES < 200,

--then return

SALARY3,

--else for sales over 199, return

BONUS)

)

),

--else for sales less than or equal to zero, return

0)

You can use IIF in update strategies. For example:

IIF( ISNULL( ITEM_NAME ), DD_REJECT, DD_INSERT)

Alternative to IIFYou can use DECODE instead of IIF in many cases. DECODE may improve readability. The following shows how you can use DECODE instead of IIF using the first example from the previous section:

DECODE( TRUE,

SALES > 0 and SALES < 50, SALARY1,

SALES > 49 AND SALES < 100, SALARY2,

SALES > 99 AND SALES < 200, SALARY3,

SALES > 199, BONUS)

You can often use a Filter transformation instead of IIF to maximize session performance. See “Filter Transformation” in the Designer Guide for more information.

��� &KDSWHU����)XQFWLRQV

Page 115: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

INITCAP

Capitalizes the first letter in each word of a string and converts all other letters to lowercase. Words are delimited by white space (a blank space, formfeed, newline, carriage return, tab, or vertical tab) and characters that are not alphanumeric. For example, if you pass the string ‘…THOMAS’, the function returns Thomas.

SyntaxINITCAP( string )

Return ValueString. If your data contains multibyte characters, the return value depends on the code page and data movement mode of the Informatica Server.

NULL if a value passed to the function is NULL.

ExampleThe following expression capitalizes all names in the FIRST_NAME port.

INITCAP( FIRST_NAME )

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

FIRST_NAME RETURN VALUE

ramona Ramona

18-albert 18-Albert

NULL NULL

?!SAM ?!Sam

THOMAS Thomas

PierRe Pierre

,1,7&$3�� ��

Page 116: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

INSTR

Returns the position of a character set in a string, counting from left to right.

SyntaxINSTR( string, search_value [,start [,occurrence]] )

Return ValueInteger if the search is successful. Integer represents the position of the first character in the search_value, counting from left to right.

Zero if the search is unsuccessful.

NULL if a value passed to the function is NULL.

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��7KH�VWULQJ�PXVW�EH�D�FKDUDFWHU�VWULQJ��3DVVHV�WKH�YDOXH�\RX�ZDQW�WR�HYDOXDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��7KH�UHVXOWV�RI�WKH�H[SUHVVLRQ�PXVW�EH�D�FKDUDFWHU�VWULQJ��LI�QRW��,1675�FRQYHUWV�WKH�YDOXH�WR�D�VWULQJ�EHIRUH�HYDOXDWLQJ�LW�

VHDUFKBYDOXH� 5HTXLUHG��$Q\�YDOXH��7KH�VHDUFK�YDOXH�LV�FDVH�VHQVLWLYH��7KH�VHW�RI�FKDUDFWHUV�\RX�ZDQW�WR�VHDUFK�IRU��7KH�VHDUFKBYDOXH�PXVW�PDWFK�D�SDUW�RI�WKH�VWULQJ�H[DFWO\��)RU�H[DPSOH��LI�\RX�ZULWH�INSTR(’Alfred Pope’, ’Alfred Smith’)�WKH�IXQFWLRQ�UHWXUQV�]HUR��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��,I�\RX�ZDQW�WR�VHDUFK�IRU�D�FKDUDFWHU�VWULQJ��HQFORVH�WKH�FKDUDFWHUV�\RX�ZDQW�WR�VHDUFK�IRU�LQ�VLQJOH�TXRWDWLRQ�PDUNV��IRU�H[DPSOH�DEF��

VWDUW� 2SWLRQDO��0XVW�EH�DQ�LQWHJHU�YDOXH��7KH�SRVLWLRQ�LQ�WKH�VWULQJ�ZKHUH�\RX�ZDQW�WR�VWDUW�WKH�VHDUFK��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�7KH�GHIDXOW�YDOXH�LV����PHDQLQJ�WKDW�,1675�VWDUWV�WKH�VHDUFK�DW�WKH�ILUVW�FKDUDFWHU�LQ�WKH�VWULQJ��,I�WKH�VWDUW�SRVLWLRQ�LV�D�SRVLWLYH�QXPEHU��,1675�ORFDWHV�WKH�VWDUW�SRVLWLRQ�E\�FRXQWLQJ�IURP�WKH�EHJLQQLQJ�RI�WKH�VWULQJ��,I�WKH�VWDUW�SRVLWLRQ�LV�D�QHJDWLYH�QXPEHU��,1675�ORFDWHV�WKH�VWDUW�SRVLWLRQ�E\�FRXQWLQJ�IURP�WKH�HQG�RI�WKH�VWULQJ��,I�WKH�VWDUW�SRVLWLRQ�LV�]HUR��,1675�VHDUFKHV�IURP�WKH�ILUVW�FKDUDFWHU�LQ�WKH�VWULQJ��,I�\RX�RPLW�WKLV�DUJXPHQW��WKH�IXQFWLRQ�XVHV�WKH�GHIDXOW�YDOXH�RI���

RFFXUUHQFH� 2SWLRQDO��$�SRVLWLYH�LQWHJHU�JUHDWHU�WKDQ�]HUR��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��,I�WKH�VHDUFK�YDOXH�DSSHDUV�PRUH�WKDQ�RQFH�LQ�WKH�VWULQJ��\RX�FDQ�VSHFLI\�ZKLFK�RFFXUUHQFH�\RX�ZDQW�WR�VHDUFK�IRU��)RU�H[DPSOH��\RX�ZRXOG�HQWHU���WR�VHDUFK�IRU�WKH�VHFRQG�RFFXUUHQFH�IURP�WKH�VWDUW�SRVLWLRQ�,I�\RX�RPLW�WKLV�DUJXPHQW��WKH�IXQFWLRQ�XVHV�WKH�GHIDXOW�YDOXH�RI����PHDQLQJ�WKDW�,1675�VHDUFKHV�IRU�WKH�ILUVW�RFFXUUHQFH�RI�WKH�VHDUFK�YDOXH��,I�\RX�SDVV�D�GHFLPDO��WKH�,QIRUPDWLFD�6HUYHU�URXQGV�LW�WR�WKH�QHDUHVW�LQWHJHU�YDOXH��,I�\RX�SDVV�D�QHJDWLYH�LQWHJHU�RU�]HUR��WKH�PDSSLQJ�IDLOV�ZKHQ�\RX�UXQ�D�VHVVLRQ�RU�EDWFK�

��� &KDSWHU����)XQFWLRQV

Page 117: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression returns the position of the first occurrence of the letter ‘a’, starting at the beginning of each company name. Because the search_value argument is case-sensitive, it skips the ‘A’ in ‘Blue Fin Aqua Center’, and returns the position for the ‘a’ in ‘Aqua’:

INSTR( COMPANY, ’a’ )

The following expression returns the position of the second occurrence of the letter ‘a’, starting at the beginning of each company name. Because the search_value argument is case-sensitive, it skips the ‘A’ in ‘Blue Fin Aqua Center’, and returns 0:

INSTR( COMPANY, ’a’, 1, 2 )

The following expression returns the position of the second occurrence of the letter ‘a’ in each company name, starting from the last character in the company name. Because the search_value argument is case-sensitive, it skips the ‘A’ in 'Blue Fin Aqua Center’, and returns 0:

INSTR( COMPANY, ’a’, -1, 2 )

COMPANY RETURN VALUE

Blue Fin Aqua Center 13

Maco Shark Shop 2

Scuba Gear 5

The Dive Shop 0

VIP Diving Club 0

COMPANY RETURN VALUE

Blue Fin Aqua Center 0

Maco Shark Shop 8

Scuba Gear 9

The Dive Shop 0

VIP Diving Club 0

COMPANY RETURN VALUE

Blue Fin Aqua Center 0

Maco Shark Shop 2

Scuba Gear 5

The Dive Shop 0

VIP Diving Club 0

,1675�� ��

Page 118: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The following expression returns the position of the first character in the string ‘Blue Fin Aqua Center’ (starting from the last character in the company name):

INSTR( COMPANY, ’Blue Fin Aqua Center’, -1, 1 )

Using Nested INSTRYou can nest the INSTR function within other functions to accomplish more complex tasks.

The following expression evaluates a string, starting from the end of the string. The expression finds the last (rightmost) space in the string and then returns all characters to the left of it:

SUBSTR( CUST_NAME,1,INSTR( CUST_NAME,’ ’ ,-1,1 ))

The following expression strips out the character ‘#’ from a string:

SUBSTR( 1, INSTR( CUST_ID,’#’ )-1 ) || SUBSTR( INSTR( CUST_ID,’#’ )+1 )

COMPANY RETURN VALUE

Blue Fin Aqua Center 1

Maco Shark Shop 0

Scuba Gear 0

The Dive Shop 0

VIP Diving Club 0

CUST_NAME RETURN VALUE

PATRICIA JONES PATRICIA

MARY ELLEN SHAH MARY ELLEN

CUST_ID RETURN VALUE

ID#33 ID33

#A3577 A3577

SS #712403399 SS 712403399

��� &KDSWHU����)XQFWLRQV

Page 119: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ISNULL

Returns whether a value is NULL. ISNULL evaluates an empty string as FALSE.

-�����To test for empty strings, use LENGTH. See “LENGTH” on page 108 for more information.

SyntaxISNULL( value )

Return ValueTRUE (1) if the value is NULL.

FALSE (0) if the value is not NULL.

ExampleThe following example checks for null values in the items table:

ISNULL( ITEM_NAME )

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���3DVVHV�WKH�URZV�\RX�ZDQW�WR�HYDOXDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ITEM_NAME RETURN VALUE

Flashlight 0 (FALSE)

NULL 1 (TRUE)

Regulator system 0 (FALSE)

‘’ 0 (FALSE) Empty string is not NULL

,618//�� ��

Page 120: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

IS_DATE

Returns whether a value is a valid date. A valid date is any string in the default date format of MM/DD/YYYY HH24:MI:SS. If the strings you want to test are not in the default date format, use the TO_DATE format strings to specify the date format. If the strings passed to IS_DATE do not match the format string specified, the function returns FALSE (0). If the strings match the format string, the function returns TRUE (1).

IS_DATE evaluates strings and returns an integer value. IS_DATE converts all non-string values to strings before evaluating the value.

The output port for an IS_DATE expression must be String or Numeric datatype.

You might use IS_DATE to test or filter data in a flat file before writing it to a target.

Informatica recommends using the RR format string with IS_DATE, not the YY format string. In most cases, the two format strings return the same values, but there are some unique cases where YY returns incorrect results. For example, the expression IS_DATE(‘02/29/00’, ‘YY’) is internally computed as IS_DATE(02/29/1900 00:00:00), which returns false. However, the Informatica Server computes the expression IS_DATE(‘02/29/00’, ‘RR’) as IS_DATE(02/29/2000 00:00:00), which returns TRUE. In the first case, year 1900 is not a leap year, so there is no February 29th.

-�����IS_DATE uses the same format strings as TO_DATE.

SyntaxIS_DATE( value [,format] )

Return ValueTRUE (1) if the row is a valid date.

FALSE (0) if the row is not a valid date.

NULL if a value in the expression is NULL or if the format string is NULL.

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��6WULQJV��3DVVHV�WKH�URZV�\RX�ZDQW�WR�HYDOXDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

IRUPDW� 2SWLRQDO��(QWHU�D�YDOLG�72B'$7(�IRUPDW�VWULQJ��7KH�IRUPDW�VWULQJ�PXVW�PDWFK�WKH�SDUWV�RI�WKH�VWULQJ�DUJXPHQW�H[DFWO\��)RU�H[DPSOH��LI�\RX�SDVV�WKH�VWULQJ�0DU�����������������$0��\RX�PXVW�XVH�WKH�IRUPDW�VWULQJ�021�''�<<<<�++���0,�66$0��,I�\RX�RPLW�WKH�IRUPDW�VWULQJ��WKH�VWULQJ�YDOXH�PXVW�EH�LQ�WKH�GHIDXOW�GDWH�RI�00�''�<<<<�++���0,�66��

��� &KDSWHU����)XQFWLRQV

Page 121: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression checks the INVOICE_DATE port for valid dates:

IS_DATE( INVOICE_DATE )

This expression returns data similar to the following:

The following IS_DATE expression specifies a format string of ‘YYYY/MM/DD’:

IS_DATE( INVOICE_DATE, ‘YYYY/MM/DD’ )

If the string value does not match this format, IS_DATE returns FALSE:

The following example shows how IS_DATE can be used to test data before using TO_DATE to convert the strings to dates. This expression checks the values in the INVOICE_DATE port, and converts each valid date to a date value. If the value is not a valid date, the Informatica Server returns ERROR and skips the row.

Note that this example returns a Date/Time value; therefore, the output port for the expression needs to be Date/Time:

IIF( IS_DATE ( INVOICE_DATE, ‘YYYY/MM/DD’ ), TO_DATE( INVOICE_DATE ), ERROR(‘Not a valid date’ ) )

INVOICE_DATE RETURN VALUE

NULL NULL

180 0 (FALSE)

‘180’ 0 (FALSE)

‘04/01/98’ 0 (FALSE)

‘04/01/1998 00:12:15’ 1 (TRUE)

‘02/31/1998 12:13:55’ 0 (FALSE) (February does not have 31 days)

‘John Smith’ 0 (FALSE)

INVOICE_DATE RETURN VALUE

NULL NULL

180 0 (FALSE)

‘180’ 0 (FALSE)

‘04/01/98’ 0 (FALSE)

‘1998/01/12’ 1 (TRUE)

‘1998/11/21 00:00:13’ 0 (FALSE)

‘1998/02/31’ 0 (FALSE) (February does not have 31 days)

‘John Smith’ 0 (FALSE)

INVOICE_DATE RETURN VALUE

NULL NULL

180 ‘Not a valid date’

,6B'$7(�� ��

Page 122: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

‘180’ ‘Not a valid date’

‘04/01/98’ ‘Not a valid date’

‘1998/01/12’ 1998/01/12

‘1998/11/21 00:00:13’ ‘Not a valid date’

‘1998/02/31’ ‘Not a valid date’

‘John Smith’ ‘Not a valid date’

INVOICE_DATE RETURN VALUE

���� &KDSWHU����)XQFWLRQV

Page 123: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

IS_NUMBER

Returns whether a string is a valid number. If you pass a value that is not a string, IS_NUMBER converts it to a string before evaluating it.

A valid number consists of the following parts:

� Optional space before the number

� Optional sign (+/-)

� One or more digits with an optional decimal point

� Optional scientific notation, i.e. the letter ‘e’ or ‘E’ (and the letter ‘d’ or ‘D’ on NT) followed by an optional sign (+/-), followed by one or more digits

� Optional white space following the number

The following numbers are all valid:

‘ 100 ’

‘ +100’

-100

-3.45e+32

+3.45E-32

+3.45d+32 (NT only)

+3.45D-32 (NT only)

.6804

The output port for an IS_NUMBER expression must be a String or Numeric datatype.

You might use IS_NUMBER to test or filter data in a flat file before writing it to a target.

SyntaxIS_NUMBER( value )

Return ValueTRUE (1) if the row is a valid number.

FALSE (0) if the row is not a valid number.

NULL if a value in the expression is NULL.

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�YDOLG�GDWDW\SH��H[FHSW�%LQDU\���3DVVHV�WKH�URZV�\RX�ZDQW�WR�HYDOXDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

,6B180%(5�� ���

Page 124: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression checks the ITEM_PRICE port for valid numbers:

IS_NUMBER( ITEM_PRICE )

You can use IS_NUMBER to test data before using one of the numeric conversion functions, such as TO_FLOAT. For example, the following expression checks the values in the ITEM_PRICE port, and converts each valid number to a double-precision floating point value. If the value is not a valid number, the Informatica Server returns 0.00:

IIF( IS_NUMBER ( ITEM_PRICE ), TO_FLOAT( ITEM_PRICE ), 0.00 )

ITEM_PRICE RETURN VALUE

123.00 1 (True)

-3.45e+3 1 (True)

-3.45D-3 1 (True - NT only)

-3.45d-3 0 (False - non-NT)

3.45E-’ 0 (False) Incomplete number

‘ ’ 0 (False) Consists entirely of whitespace

‘’ 0 (False) Empty string

+123abc 0 (False)

123 1 (True) Leading whitespace

123 1 (True) Trailing whitespace

ABC 0 (False)

-ABC 0 (False)

NULL NULL

ITEM_PRICE RETURN VALUE

‘123.00’ 123

‘-3.45e+3’ -3450

‘3.45E-3’ 0.00345

‘ ’ 0.00 Consists entirely of whitespace

‘’ 0.00 Empty string

‘+123abc’ 0.00

‘ 123ABC’ 0.00

‘ABC’ 0.00

‘-ABC’ 0.00

NULL NULL

���� &KDSWHU����)XQFWLRQV

Page 125: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

IS_SPACES

Returns whether a value consist entirely of spaces. A space is a blank space, a formfeed, a newline, a carriage return, a tab, or a vertical tab.

IS_SPACES evaluates an empty string as FALSE because there are no spaces. To test for an empty string, use LENGTH. For more information on LENGTH, see “LENGTH” on page 108.

SyntaxIS_SPACES( value )

Return ValueTRUE (1) if the row consists entirely of spaces.

FALSE (0) if the row contains data.

NULL if a value in the expression is NULL.

ExampleThe following expression checks the ITEM_NAME port for rows that consist entirely of spaces:

IS_SPACES( ITEM_NAME )

TipYou can use IS_SPACES to avoid writing spaces to a character column in a target table. For example, if you have a transformation that writes customer names to a fixed length CHAR(5) column in a target table, you might want to write ‘00000’ instead of spaces. To do this, you would create an expression similar to the following:

IIF( IS_SPACES( CUST_NAMES ), ’00000’, CUST_NAMES )

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�YDOLG�GDWDW\SH��H[FHSW�%LQDU\���3DVVHV�WKH�URZV�\RX�ZDQW�WR�HYDOXDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ITEM_NAME RETURN VALUE

Flashlight 0 (False)

1 (True)

Regulator system 0 (False)

NULL NULL

‘’ 0 (FALSE) (Empty string does not contain spaces.)

,6B63$&(6�� ���

Page 126: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

LAST

Returns the last row in the selected port. Optionally, you can apply a filter to limit the rows the Informatica Server reads. You can nest only one other aggregate function within LAST.

LAST is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

-�����This function was called PIVOT in PowerMart 3.5.

SyntaxLAST( value [, filter_condition ] )

Return ValueLast row in a port.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����By default, the Informatica Server treats null values as NULLs in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

ExampleThe following expression returns the last row in the ITEMS_NAME port with a price greater than $10.00:

LAST( ITEM_NAME, ITEM_PRICE > 10 )

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�UHWXUQ�WKH�ODVW�URZ��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ITEM_NAME ITEM_PRICE

Flashlight 35.00

Navigation Compass 8.05

Regulator System 150.00

Flashlight 29.00

���� &KDSWHU����)XQFWLRQV

Page 127: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Depth/Pressure Gauge 88.00

Vest 31.00

RETURN VALUE: Vest

ITEM_NAME ITEM_PRICE

/$67�� ���

Page 128: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

LAST_DAY

Returns the date of the last day of the month for each date in a port.

SyntaxLAST_DAY( date )

Return ValueDate. The last day of the month for that date value you pass to this function.

NULL if a value in the selected port is NULL.

NullIf a value is NULL, LAST ignores the row. However, if all values passed from the port are NULL, LAST returns NULL.

Group ByLAST groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, LAST treats all rows as one group, returning one value.

Using LAST_DAY with Flat FilesIf you want to calculate the last day of the month, but your source dates are stored in flat files, you can nest TO_DATE to convert the string to a date. TO_DATE always includes time information. If you pass a string that does not have a time value, the date returned will include the time 00:00:00.

The following example returns the last day of the month for each order date in the same format as the string:

LAST_DAY( TO_DATE( ORDER_DATE, ’DD-MON-YY’ ))

$UJXPHQW 0HDQLQJ

GDWH� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��3DVVHV�WKH�GDWHV�IRU�ZKLFK�\RX�ZDQW�WR�UHWXUQ�WKH�ODVW�GD\�RI�WKH�PRQWK��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�GDWH�

ORDER_DATE RETURN VALUE

’18-NOV-98’ Nov 30 1998 00:00:00

’28-APR-98’ Apr 30 1998 00:00:00

NULL NULL

���� &KDSWHU����)XQFWLRQV

Page 129: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression returns the last day of the month for each date in the ORDER_DATE port:

LAST_DAY( ORDER_DATE )

’18-FEB-96’ Feb 29 1996 00:00:00 (Leap year)

ORDER_DATE RETURN VALUE

Apr 1 1998 12:00:00AM Apr 30 1998 12:00:00AM

Jan 6 1998 12:00:00AM Jan 31 1998 12:00:00AM

Feb 2 1996 12:00:00AM Feb 29 1996 12:00:00AM (Leap year)

NULL NULL

Jul 31 1998 12:00:00AM Jul 31 1998 12:00:00AM

ORDER_DATE RETURN VALUE

/$67B'$<�� ���

Page 130: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

LENGTH

Returns the number of characters in a string, including trailing blanks.

SyntaxLENGTH( string )

Return ValueInteger representing the length of the string.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the length of each customer name:

LENGTH( CUSTOMER_NAME )

TipsYou can use LENGTH to test for empty string conditions. If you want to find fields in which customer name is empty, use an expression such as:

IIF( LENGTH( CUSTOMER_NAME ) = 0, ‘EMPTY STRING’ )

To test for a null field, use ISNULL. For details, see “ISNULL” on page 97. To test for spaces, use IS_SPACES. For details, see “IS_SPACES” on page 103.

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��6WULQJ�GDWDW\SH��7KH�VWULQJV�\RX�ZDQW�WR�HYDOXDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

CUSTOMER_NAME RETURN VALUE

Bernice Davis 13

NULL NULL

John Baer 9

Greg Brown 10

���� &KDSWHU����)XQFWLRQV

Page 131: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

LN

Returns the natural logarithm of a numeric value. For example, LN(3)returns 1.098612. You usually use this function to analyze scientific data rather than business data.

This function is the reciprocal of the function EXP.

SyntaxLN( numeric_value )

Return ValueDouble value.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the natural logarithm for all values in the NUMBERS port:

LN( NUMBERS )

-�����The Informatica Server displays an error and does not write the row when you pass a negative number or zero. The numeric_value must be a positive number greater than zero.

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��,W�PXVW�EH�D�SRVLWLYH�QXPEHU��JUHDWHU�WKDQ�]HUR��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�WKH�QDWXUDO�ORJDULWKP��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

NUMBERS RETURN VALUE

10 2.302585092994

125 4.828313737302

0.96 -0.04082199452026

NULL NULL

-90 Error. (The Informatica Server does not write row.)

0 Error. (The Informatica Server does not write row.)

/1�� ���

Page 132: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

LOG

Returns the logarithm of a numeric value. Most often, you use this function to analyze scientific data rather than business data.

SyntaxLOG( base, exponent )

Return ValueDouble value.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the logarithm for all values in the NUMBERS port:

LOG( BASE, EXPONENT )

Note that the Informatica Server displays an error and does not write the row if you pass a negative number, zero, or 1 as a base value, or if you pass a negative value for the exponent.

$UJXPHQW 0HDQLQJ

EDVH� 5HTXLUHG��7KH�EDVH�RI�WKH�ORJDULWKP��0XVW�EH�D�SRVLWLYH�QXPHULF�YDOXH�RWKHU�WKDQ���RU����$Q\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�SRVLWLYH�QXPEHU�RWKHU�WKDQ���RU����

H[SRQHQW� 5HTXLUHG��7KH�H[SRQHQW�RI�WKH�ORJDULWKP��0XVW�EH�D�SRVLWLYH�QXPHULF�YDOXH�JUHDWHU�WKDQ����$Q\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�SRVLWLYH�QXPEHU�JUHDWHU�WKDQ���

BASE EXPONENT RETURN VALUE

15 1 1.176091259056

.09 10 -0.956244644696599

NULL 18 NULL

35.78 NULL NULL

-9 18 Error. (Informatica Server does not write the row.)

0 5 Error. (Informatica Server does not write the row.)

10 -2 Error. (Informatica Server does not write the row.)

���� &KDSWHU����)XQFWLRQV

Page 133: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

LOOKUP

Searches for a value in a lookup source column.

The LOOKUP function compares data in a lookup source to a value you specify. When the Informatica Server finds the search value in the lookup table, it returns the value from a specified column in the same row in the lookup table.

-�����This function is not supported in mapplets.

Using the Lookup Transformation or the LOOKUP FunctionInformatica recommends using the Lookup transformation rather than the LOOKUP function to lookup values in PowerMart and PowerCenter mappings. If you have PowerMart 3.5 mappings that use the LOOKUP function, the upgrade program creates lookup tables as they exist in PowerMart 3.5. Informatica recommends converting these lookup tables and LOOKUP expressions to Lookup transformations.

If you use the LOOKUP function in a mapping, you need to enable the lookup caching option for 3.5 compatibility in the session property sheet. This option exists expressly for PowerMart 3.5 users who want to continue using the LOOKUP function, rather than creating Lookup transformations. For more information, see “Lookup Transformation” in the Designer Guide.

You can define multiple searches for one lookup table within a LOOKUP function. However, each search must find a matching value to return the lookup value.

SyntaxLOOKUP( result, search1, value1 [, search2, value2]… )

Return ValueResult if all searches find matching values. If the Informatica Server finds matching values, it returns the result from the same row as the search1 argument.

NULL if the search does not find any matching values.

$UJXPHQW 0HDQLQJ

UHVXOW� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���0XVW�EH�DQ�RXWSXW�SRUW�LQ�WKH�VDPH�ORRNXS�WDEOH�DV�VHDUFK��6SHFLILHV�WKH�UHWXUQ�YDOXH�LI�WKH�VHDUFK�PDWFKHV�WKH�YDOXH��$OZD\V�SUHIDFH�WKLV�DUJXPHQW�ZLWK�WKH�UHIHUHQFH�TXDOLILHU��7'�

VHDUFK�� 5HTXLUHG��'DWDW\SH�WKDW�PDWFKHV�WKH�YDOXH���0XVW�EH�DQ�RXWSXW�SRUW�LQ�WKH�VDPH�ORRNXS�WDEOH�DV�UHVXOW��6SHFLILHV�WKH�YDOXHV�\RX�ZDQW�WR�PDWFK�WR�YDOXH��$OZD\V�SUHIDFH�WKLV�DUJXPHQW�ZLWK�WKH�UHIHUHQFH�TXDOLILHU��7'�

YDOXH�� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���PXVW�PDWFK�VHDUFK��GDWDW\SH��7KH�YDOXHV�\RX�ZDQW�WR�VHDUFK�IRU�LQ�WKH�ORRNXS�VRXUFH�FROXPQ�VSHFLILHG�LQ�VHDUFK���<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

/22.83�� ���

Page 134: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Error if the search finds more than one matching value.

ExampleThe following expression searches the lookup source :TD.SALES for a specific item ID and price, and returns the item name if both searches find a match:

LOOKUP( :TD.SALES.ITEM_NAME, :TD.SALES.ITEM_ID, 10, :TD.SALES.PRICE, 15.99 )

TipsWhen you compare char and varchar values, the LOOKUP function returns a result only if the two rows match exactly. This means that both the value and the length for each row must match. If your lookup source is a padded char value of a specified length and your lookup search is a varchar value, you need to use the RTRIM function to trim the trailing spaces from the lookup source so that the values match the lookup search:

LOOKUP(:TD.ORDERS.PRICE, :TD.ORDERS.ITEM, RTRIM( ORDERS.ITEM, ’ ’))

Use the :TD reference qualifier in the result and search arguments of a LOOKUP function:

LOOKUP(:TD.ORDERS.ITEM, :TD.ORDERS.PRICE, ORDERS.PRICE, :TD.ORDERS.QTY, ORDERS.QTY)

ITEM_NAME ITEM_ID PRICE

Regulator 5 100.00

Flashlight 10 15.99

Halogen Flashlight 15 15.99

NULL 20 15.99

RETURN VALUE: Flashlight

���� &KDSWHU����)XQFWLRQV

Page 135: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

LOWER

Converts uppercase string characters to lowercase.

SyntaxLOWER( string )

Return ValueLowercase character string. If your data contains multibyte characters, the return value depends on the code page and data movement mode of the Informatica Server.

NULL if a value in the selected port is NULL.

ExampleThe following expression returns all first names in the Customers table to lowercase:

LOWER( FIRST_NAME )

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��$Q\�VWULQJ�YDOXH��7KH�DUJXPHQW�SDVVHV�WKH�VWULQJ�YDOXHV�WKDW�\RX�ZDQW�WR�UHWXUQ�DV�ORZHUFDVH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�VWULQJ�

FIRST_NAME RETURN VALUE

antonia antonia

NULL NULL

THOMAS thomas

PierRe pierre

BERNICE bernice

/2:(5�� ���

Page 136: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

LPAD

Adds a set of blanks or characters to the beginning of a string to set the string to a specified length.

SyntaxLPAD( first_string, length [,second_string] )

Return ValueString of the specified length.

NULL if a value passed to the function is NULL.

ExampleThe following expression standardizes numbers to six digits by padding them with leading zeros.

LPAD( PART_NUM, 6, ’0’)

LPAD counts the length from left to right. So, if the first string is longer than the length, LPAD truncates the string from right to left. For example, LPAD(‘alphabetical’, 5, ‘x’) would return the string ‘alpha’.

$UJXPHQW 0HDQLQJ

ILUVWBVWULQJ� 5HTXLUHG��&DQ�EH�D�FKDUDFWHU�VWULQJ��7KH�VWULQJV�\RX�ZDQW�WR�FKDQJH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

OHQJWK� 5HTXLUHG��0XVW�EH�D�SRVLWLYH�LQWHJHU�OLWHUDO��7KLV�DUJXPHQW�VSHFLILHV�WKH�OHQJWK�\RX�ZDQW�HDFK�VWULQJ�WR�EH��

VHFRQGBVWULQJ� 2SWLRQDO��&DQ�EH�DQ\�VWULQJ�YDOXH��7KH�FKDUDFWHUV�\RX�ZDQW�WR�DSSHQG�WR�WKH�OHIW�VLGH�RI�WKH�ILUVWBVWULQJ�YDOXHV��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��<RX�FDQ�HQWHU�D�VSHFLILF�VWULQJ�OLWHUDO��KRZHYHU��EH�VXUH�WR�HQFORVH�WKH�FKDUDFWHUV�\RX�ZDQW�WR�DGG�WR�WKH�EHJLQQLQJ�RI�WKH�VWULQJ�ZLWKLQ�VLQJOH�TXRWDWLRQ�PDUNV��IRU�H[DPSOH�DEF��7KLV�DUJXPHQW�LV�FDVH�VHQVLWLYH��,I�\RX�RPLW�WKH�VHFRQGBVWULQJ��WKH�IXQFWLRQ�SDGV�WKH�EHJLQQLQJ�RI�WKH�ILUVW�VWULQJ�ZLWK�EODQNV�

PART_NUM RETURN VALUE

702 000702

1 000001

0553 000553

484834 484834

���� &KDSWHU����)XQFWLRQV

Page 137: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

If the second string is longer than the total characters needed to return the specified length, LPAD only uses a portion of the second string:

LPAD( ITEM_NAME, 16, ’*..*’ )

ITEM_NAME RETURN VALUE

Flashlight *..**.Flashlight

Compass *..**..**Compass

Regulator System Regulator System

Safety Knife *..*Safety Knife

/3$'�� ���

Page 138: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

LTRIM

Removes blanks or characters from the beginning of a string. Most often, you use LTRIM with IIF or DECODE in an Expression or Update Strategy transformation to avoid spaces in a target table.

If you do not specify a trim_set parameter in your expression:

� In UNICODE mode, LTRIM removes both single- and double-byte spaces from the beginning of a string.

� In ASCII mode, LTRIM removes only single-byte spaces.

If you use LTRIM to remove characters from a string, LTRIM compares the trim_set to each character in the string argument, character-by-character, starting with the left side of the string. If the character in the string matches any character in the trim_set, LTRIM removes it. LTRIM continues comparing and removing characters until it fails to find a matching character in the trim_set. Then it returns the string, with any matching characters removed.

SyntaxLTRIM( string [, trim_set] )

Return ValueString. The string values with the specified characters in the trim_set argument removed.

NULL if a value passed to the function is NULL. If the trim_set is NULL, the function returns NULL.

$UJXPHQWV 0HDQLQJ

VWULQJ� 5HTXLUHG��$Q\�VWULQJ�YDOXH��3DVVHV�WKH�VWULQJV�\RX�ZDQW�WR�PRGLI\��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��<RX�FDQ�XVH�RSHUDWRUV�WR�SHUIRUP�FRPSDULVRQV�RU�FRQFDWHQDWH�VWULQJV�EHIRUH�UHPRYLQJ�FKDUDFWHUV�IURP�WKH�EHJLQQLQJ�RI�D�VWULQJ�

WULPBVHW� 2SWLRQDO��$Q\�VWULQJ�YDOXH��3DVVHV�WKH�FKDUDFWHUV�\RX�ZDQW�WR�UHPRYH�IURP�WKH�EHJLQQLQJ�RI�WKH�ILUVW�VWULQJ��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��<RX�FDQ�DOVR�HQWHU�D�FKDUDFWHU�VWULQJ��KRZHYHU��\RX�PXVW�HQFORVH�WKH�FKDUDFWHUV�\RX�ZDQW�WR�UHPRYH�IURP�WKH�EHJLQQLQJ�RI�WKH�VWULQJ�ZLWKLQ�VLQJOH�TXRWDWLRQ�PDUNV��IRU�H[DPSOH��DEF��,I�\RX�RPLW�WKH�VHFRQG�VWULQJ��WKH�IXQFWLRQ�UHPRYHV�DQ\�EODQNV�IURP�WKH�EHJLQQLQJ�RI�WKH�VWULQJ��$OVR�QRWH�WKDW�/75,0�LV�FDVH�VHQVLWLYH��)RU�H[DPSOH��LI�\RX�ZDQW�WR�UHPRYH�WKH�$�FKDUDFWHU�IURP�WKH�VWULQJ�$OIUHGR��\RX�ZRXOG�HQWHU�$��QRW�D��

���� &KDSWHU����)XQFWLRQV

Page 139: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression removes the characters ‘S’ and ‘.’ from the strings in the LAST_NAME port:

LTRIM( LAST_NAME, ’S.’)

LTRIM removes ‘S.’ from S. MacDonald and the ‘S’ from both Sawyer and Steadman, but not the period from H. Bender. This is because LTRIM searches, character-by-character, for the set of characters you specify in the trim_set argument. If the first character in the string matches the first character in the trim_set, LTRIM removes it. Then it looks at the second character in the string, if it matches the second character in the trim_set, LTRIM removes it, and so on. When the first character in the string does not match the corresponding character in the trim_set, LTRIM returns the string and evaluates the next row.

In the example of H. Bender, H does not match either character in the trim_set argument, so LTRIM returns the string in the LAST_NAME port and moves to the next row.

TipsYou can use RTRIM and LTRIM with || or CONCAT to remove leading and trailing blanks after you concatenate two strings.

You can also remove multiple sets of characters by nesting LTRIM. For example, if you want to remove leading blanks and the character 'T' from a column of names, you might create an expression similar to the following:

LTRIM( LTRIM( NAMES ), ’T’ )

LAST_NAME RETURN VALUE

Nelson Nelson

Osborne Osborne

NULL NULL

S. MacDonald MacDonald

Sawyer awyer

H. Bender H. Bender

Steadman teadman

/75,0�� ���

Page 140: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

MAX (Dates)

Returns the latest date found within a port or group. You can apply a filter to limit the rows in the search. You can nest only one other aggregate function within MAX.

MAX is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

You can also use MAX to return the largest numeric value in a port or group.

SyntaxMAX( date [, filter_condition] )

Return ValueDate.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

ExampleYou can return the maximum date for a port or group. The following expression returns the maximum order date for flashlights:

MAX( ORDERDATE, ITEM_NAME=’Flashlight’ )

$UJXPHQW 0HDQLQJ

GDWH� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��3DVVHV�WKH�GDWH�IRU�ZKLFK�\RX�ZDQW�WR�UHWXUQ�D�PD[LPXP�GDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ITEM_NAME ORDER_DATE

Flashlight Apr 20 1998

Regulator System May 15 1998

Flashlight Sep 21 1998

Diving Hood Aug 18 1998

Halogen Flashlight Feb 1 1998

Flashlight Oct 10 1998

Flashlight NULL

���� &KDSWHU����)XQFWLRQV

Page 141: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

MAX (Numbers)

Returns the maximum numeric value found within a port or group. You can apply a filter to limit the rows in the search. You can nest only one other aggregate function within MAX.

MAX is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

You can also use MAX to return the latest date in a port or group.

SyntaxMAX( numeric_value [, filter_condition] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

If the return value is decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsIf a value is NULL, MAX ignores it. However, if all values passed from the port are NULL, MAX returns NULL.

-�����By default, the Informatica Server treats null values as NULLs in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��3DVVHV�WKH�QXPHULF�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�UHWXUQ�D�PD[LPXP�QXPHULF�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

0$;��1XPEHUV��� ���

Page 142: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Group ByMAX groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, MAX treats all rows as one group, returning one value.

ExampleThe first expression returns the maximum price for flashlights:

MAX( PRICE, ITEM_NAME=’Flashlight’ )

ITEM_NAME PRICE

Flashlight 10.00

Regulator System 360.00

Flashlight 55.00

Diving Hood 79.00

Halogen Flashlight 162.00

Flashlight 85.00

Flashlight NULL

RETURN VALUE: 85.00

���� &KDSWHU����)XQFWLRQV

Page 143: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

MEDIAN

Returns the median of all values in a selected port. If there is an even number of values in the port, the median is the average of the middle two values when all values are placed ordinally on a number line. If there is an odd number of values in the port, the median is the middle number.

Optionally, you can apply a filter to limit the rows you read to calculate the median. You can nest only one other aggregate function within MEDIAN, and the nested function must return a Numeric datatype.

MEDIAN is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

SyntaxMEDIAN( numeric_value [, filter_condition ] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����If the return value is decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsIf a value is NULL, MEDIAN ignores the row. However, if all values passed from the port are NULL, MEDIAN returns NULL.

-�����By default, the Informatica Server treats null values as NULLs in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�D�PHGLDQ��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

0(',$1�� ���

Page 144: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Group ByMEDIAN groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, MEDIAN treats all rows as one group, returning one value.

ExampleTo calculate the median salary for all departments, you would create an Aggregator transformation grouped by departments with a port specifying the following expression:

MEDIAN( SALARY )

The following expression returns the median value for orders of Stabilizing Vests:

MEDIAN( SALES, ITEM = ‘Stabilizing Vest’ )

ITEM SALES

Flashlight 85

Stabilizing Vest 504

Stabilizing Vest 36

Safety Knife 5

Medium Titanium Knife 150

Tank NULL

Stabilizing Vest 441

Chisel Point Knife 60

Stabilizing Vest NULL

Stabilizing Vest 1044

Wrist Band Thermometer 110

RETURN VALUE: 472.5

���� &KDSWHU����)XQFWLRQV

Page 145: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

MIN (Dates)

Returns the oldest date found in a port or group. You can apply a filter to limit the rows in the search. You can nest only one other aggregate function within MIN, and the nested function must return a date datatype.

MIN is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

You can also use MIN to return the minimum numeric value in a port or group.

SyntaxMIN( date [, filter_condition] )

Return ValueDate if the value argument is a date.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

NullsIf a single value is NULL, MIN ignores it. However, if all values passed from the port are NULL, MIN returns NULL.

Group ByMIN groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, MIN treats all rows as one group, returning one value.

$UJXPHQW 0HDQLQJ

GDWH� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�UHWXUQ�PLQLPXP�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

0,1��'DWHV��� ���

Page 146: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression returns the oldest order date for flashlights:

MIN( ORDER_DATE, ITEM_NAME=’Flashlight’ )

ITEM_NAME ORDER_DATE

Flashlight Apr 20 1998

Regulator System May 15 1998

Flashlight Sep 21 1998

Diving Hood Aug 18 1998

Halogen Flashlight Feb 1 1998

Flashlight Oct 10 1998

Flashlight NULL

RETURN VALUE: Feb 1 1998

���� &KDSWHU����)XQFWLRQV

Page 147: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

MIN (Numbers)

Returns the minimum numeric value found in a port or group. You can apply a filter to limit the rows in the search. You can nest only one other aggregate function within MIN, and the nested function must return a Numeric datatype.

MIN is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

You can also use MIN to return the oldest date in a port or group.

SyntaxMIN( numeric_value [, filter_condition] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����If the return value is a decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsIf a single value is NULL, MIN ignores it. However, if all values passed from the port are NULL, MIN returns NULL.

-�����By default, the Informatica Server treats null values as NULLS in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SHV��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�UHWXUQ�PLQLPXP�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

0,1��1XPEHUV��� ���

Page 148: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Group ByMIN groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, MIN treats all rows as one group, returning one value.

ExampleThe following expression returns the minimum price for flashlights:

MIN ( PRICE, ITEM_NAME=’Flashlight’ )

ITEM_NAME PRICE

Flashlight 10.00

Regulator System 360.00

Flashlight 55.00

Diving Hood 79.00

Halogen Flashlight 162.00

Flashlight 85.00

Flashlight NULL

RETURN VALUE: 10.00

���� &KDSWHU����)XQFWLRQV

Page 149: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

MOD

Returns the remainder of a division calculation. For example, MOD(8,5) returns 3.

SyntaxMOD( numeric_value, divisor )

Return ValueNumeric value of the datatype you pass to the function. The remainder of the numeric value divided by the divisor.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the modulus of the values in the PRICE port divided by the values in the QTY port:

MOD( PRICE, QTY )

The last row (25, 0) produced an error because you cannot divide by zero. To avoid dividing by zero, you can create an expression similar to the following, which returns the modulus of Price divided by Quantity only if the quantity is not zero. If the quantity is zero, the function returns NULL:

MOD( PRICE, IIF( QTY = 0, NULL, QTY ))

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��7KH�YDOXHV�\RX�ZDQW�WR�GLYLGH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

GLYLVRU� 5HTXLUHG��7KH�QXPHULF�YDOXH�\RX�ZDQW�WR�GLYLGH�E\��7KH�GLYLVRU�FDQQRW�EH�]HUR�

PRICE QTY RETURN VALUE

10.00 2 0

12.00 5 2

9.00 2 1

15.00 3 0

NULL 3 NULL

20.00 NULL NULL

25.00 0 Error. Informatica Server does not write row.

PRICE QTY RETURN VALUE

10.00 2 0

02'�� ���

Page 150: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The last row (25, 0) produced a NULL rather than an error because the IIF function replaces NULL with the zero in the QTY port.

12.00 5 2

9.00 2 1

15.00 3 0

NULL 3 NULL

20.00 NULL NULL

25.00 0 NULL

PRICE QTY RETURN VALUE

���� &KDSWHU����)XQFWLRQV

Page 151: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

MOVINGAVG

Returns the average (row-by-row) of a specified set of rows. Optionally, you can apply a condition to filter rows before calculating the moving average.

SyntaxMOVINGAVG( numeric_value, rowset [, filter_condition] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����If the return value is a decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsMOVINGAVG ignores null values when calculating the moving average. However, if all values are NULL, the function returns NULL.

ExampleThe following expression returns the average order for a Stabilizing Vest, based on the first five rows in the Sales port, and thereafter, returns the average for the last five rows read:

MOVINGAVG( SALES, 5 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��7KH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�D�PRYLQJ�DYHUDJH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

URZVHW� 5HTXLUHG��0XVW�EH�D�SRVLWLYH�LQWHJHU�OLWHUDO�JUHDWHU�WKDQ�]HUR��'HILQHV�WKH�URZ�VHW�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�WKH�PRYLQJ�DYHUDJH��)RU�H[DPSOH��LI�\RX�ZDQW�WR�FDOFXODWH�D�PRYLQJ�DYHUDJH�IRU�D�FROXPQ�RI�GDWD��ILYH�URZV�DW�D�WLPH��\RX�PLJKW�ZULWH�DQ�H[SUHVVLRQ�VXFK�DV� MOVINGAVG(SALES, 5)

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ROW_NO SALES RETURN VALUE

1 600 NULL

2 504 NULL

3 36 NULL

4 100 NULL

029,1*$9*�� ���

Page 152: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The function returns the average for a set of five rows: 358 based on rows 1 through 5, 245.8 based on rows 2 through 6, and 243 based on rows 3 through 7.

5 550 358

6 39 245.8

7 490 243

ROW_NO SALES RETURN VALUE

���� &KDSWHU����)XQFWLRQV

Page 153: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

MOVINGSUM

Returns the sum (row-by-row) of a specified set of rows.

Optionally, you can apply a condition to filter rows before calculating the moving sum.

SyntaxMOVINGSUM( numeric_value, rowset [, filter_condition] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if the function does not select any rows (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����If the return value is a Decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsMOVINGSUM ignores null values when calculating the moving sum. However, if all values are NULL, the function returns NULL.

ExampleThe following expression returns the sum of orders for a Stabilizing Vest, based on the first five rows in the Sales port, and thereafter, returns the average for the last five rows read:

MOVINGSUM( SALES, 5 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��7KH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�D�PRYLQJ�VXP��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

URZVHW� 5HTXLUHG��0XVW�EH�D�SRVLWLYH�LQWHJHU�OLWHUDO�JUHDWHU�WKDQ�]HUR��'HILQHV�WKH�URZVHW�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�WKH�PRYLQJ�VXP��)RU�H[DPSOH��LI�\RX�ZDQW�WR�FDOFXODWH�D�PRYLQJ�VXP�IRU�D�FROXPQ�RI�GDWD��ILYH�URZV�DW�D�WLPH��\RX�PLJKW�ZULWH�DQ�H[SUHVVLRQ�VXFK�DV� MOVINGSUM( SALES, 5 )

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ROW_NO SALES RETURN VALUE

1 600 NULL

2 504 NULL

3 36 NULL

029,1*680�� ���

Page 154: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The function returns the sum for a set of five rows: 1790 based on rows 1 through 5, 1229 based on rows 2 through 6, and 1215 based on rows 3 through 7.

4 100 NULL

5 550 1790

6 39 1229

7 490 1215

ROW_NO SALES RETURN VALUE

���� &KDSWHU����)XQFWLRQV

Page 155: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

PERCENTILE

Calculates the value that falls at a given percentile in a group of numbers. See the following equation for more details.

Optionally, you can apply a filter to limit the rows you read to calculate the percentile. You can nest only one other aggregate function within PERCENTILE, and the nested function must return a Numeric datatype.

PERCENTILE is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

SyntaxPERCENTILE( numeric_value, percentile [, filter_condition ] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����If the return value is decimal with precision greater than 15, you might want to select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsIf a value is NULL, PERCENTILE ignores the row. However, if all values in a group are NULL, PERCENTILE returns NULL.

-�����By default, the Informatica Server treats null values as NULLs in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�D�SHUFHQWLOH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

SHUFHQWLOH� 5HTXLUHG��,QWHJHU�EHWZHHQ���DQG������LQFOXVLYH��3DVVHV�WKH�SHUFHQWLOH�\RX�ZDQW�WR�FDOFXODWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��,I�\RX�SDVV�D�QXPEHU�RXWVLGH�WKH���WR�����UDQJH��WKH�,QIRUPDWLFD�6HUYHU�GLVSOD\V�DQ�HUURU�DQG�GRHV�QRW�ZULWH�WKH�URZ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

3(5&(17,/(�� ���

Page 156: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

Group ByPERCENTILE groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, PERCENTILE treats all rows as one group, returning one value.

ExampleThe Informatica Server calculates a percentile using the following logic:

where:

� x is the number of elements in the group of values for which you are calculating a percentile.

� If i < 1, PERCENTILE returns the value of the first element in the list.

� If i is an integer value, PERCENTILE returns the value of the ith element in the list.

� Otherwise PERCENTILE returns the value of n:

The following expression returns the salary that falls at the 75th percentile of salaries greater than $50,000:

PERCENTILE( SALARY, 75, SALARY > 50000 )

SALARY

125000.0

27900.0

100000.0

NULL

55000.0

9000.0

85000.0

86000.0

48000.0

99000.0

� � �+� � ������������

��������������������������������������������������=

� � ����� � �–� ��� � � ����� � �–� ��� �+=

���� &KDSWHU����)XQFWLRQV

Page 157: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

RETURN VALUE: 106250.0

SALARY

3(5&(17,/(�� ���

Page 158: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

POWER

Returns a value raised to the exponent you pass to the function.

SyntaxPOWER( base, exponent )

Return ValueDouble value.

NULL if you pass a null value to the function.

ExampleThe following expression returns the values in the Numbers port raised to the values in the Exponent port:

POWER( NUMBERS, EXPONENT )

Note that -3.0 raised to 6 returns the same results as -3.0 raised to 5.5. If the base is negative, the exponent must be an integer; otherwise the Informatica Server rounds the exponent to the nearest integer value.

$UJXPHQW 0HDQLQJ

EDVH� 5HTXLUHG��1XPHULF�YDOXH��7KLV�DUJXPHQW�LV�WKH�EDVH�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��,I�WKH�EDVH�YDOXH�LV�QHJDWLYH��WKH�H[SRQHQW�PXVW�EH�DQ�LQWHJHU�

H[SRQHQW� 5HTXLUHG��1XPHULF�YDOXH��7KLV�DUJXPHQW�LV�WKH�H[SRQHQW�YDOXH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��,I�WKH�EDVH�YDOXH�LV�QHJDWLYH��WKH�H[SRQHQW�PXVW�EH�DQ�LQWHJHU��,Q�WKLV�FDVH��WKH�IXQFWLRQ�URXQGV�DQ\�GHFLPDO�YDOXHV�WR�WKH�QHDUHVW�LQWHJHU�EHIRUH�UHWXUQLQJ�D�YDOXH��

NUMBERS EXPONENT RETURN VALUE

10.0 2.0 100

3.5 6.0 1838.265625

3.5 5.5 982.594307804838

NULL 2.0 NULL

10.0 NULL NULL

-3.0 -6.0 0.00137174211248285

3.0 -6.0 0.00137174211248285

-3.0 6.0 729.0

-3.0 5.5 729.0

���� &KDSWHU����)XQFWLRQV

Page 159: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ROUND (Dates)

Rounds one part of a date. You can also use ROUND to round numbers.

This functions can round the following parts of a date:

� Year. Rounds the year portion of a date based on the month. If the month is between January and June, the function returns January 1 of the input year, and sets the time to 00:00:00. If the month is between July and December, the function returns January 1 of the next year with the time set to 00:00:00. For example, the expression ROUND(06/30/1998 2:30:55, ’YY’) returns 01/01/1998 00:00:00, and ROUND(07/1/1998 3:10:15, ’YY’) returns 1/1/1998 00:00:00.

� Month. Rounds the month portion of a date based on the day of the month. If the day of the month is between 1 and 15, it rounds the date to the first day of the input month with the time set to 00:00:00. If the day of the month is between 16 and the last day of the month, it rounds to the first day of the next month with the time set to 00:00:00. For example, the expression ROUND(4/15/1998 12:15:00, ’MM’) returns 4/1/1998 00:00:00, and ROUND(4/16/1998 8:24:19, ’MM’) returns 5/1/1998 00:00:00.

� Day. Rounds the day portion of the date based on the time. If the time is between 00:00:00 (12AM) and 11:59:59AM, the function returns the current date with the time set to 00:00:00 (12AM). If the time is 12:00:00 (12PM) or later, the function rounds the date to the next day with the time set to 00:00:00 (12AM). For example, the expression ROUND(06/13/1998 2:30:45, ’DD’) returns 06/13/1998 00:00:00, and ROUND(06/13/1998 22:30:45, ’DD’) returns 06/14/1998 00:00:00.

� Hour. Rounds the hour portion of the date based on the minutes in the hour. If the minute portion of the time is between 0 and 29, the function returns the current hour with the minutes and seconds set to zero. If the minute portion is 30 or greater, the function rounds to the next hour and sets the minutes and seconds to zero. For example, the expression ROUND(04/01/1998 11:29:35, ’HH’) returns 04/01/1998 11:00:00, and ROUND(04/01/1998 13:39:00, ’HH’) returns 04/01/1998 14:00:00.

� Minute. Rounds the minute portion of the date based on the seconds. If time has 0 to 29 seconds, the function returns the current minutes and sets the seconds to zero. If the time has 30 to 59 seconds, the function rounds to the next minute and sets the seconds to zero. For example, the expression ROUND(05/22/1998 10:15:29, ’MI’) returns 05/22/1998 10:15:00, and ROUND(05/22/1998 10:15:30, ’MI’) returns 05/22/1998 10:16:00.

5281'��'DWHV��� ���

Page 160: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SyntaxROUND( date [,format] )

Return ValueDate with the specified part rounded. ROUND returns a date in the same format as the source date. You can link the results of this function to any port with a Date/Time datatype.

NULL if you pass a null value to the function.

ExampleThe following expressions round the year portion of dates in the DATE_SHIPPED port:

ROUND( DATE_SHIPPED, ’Y’ )

ROUND( DATE_SHIPPED, ’YY’ )

ROUND( DATE_SHIPPED, ’YYY’ )

ROUND( DATE_SHIPPED, ’YYYY’ )

The following expressions round the month portion of each date in the DATE_SHIPPED port:

ROUND( DATE_SHIPPED, ’MM’ )

ROUND( DATE_SHIPPED, ’MON’ )

ROUND( DATE_SHIPPED, ’MONTH’ )

$UJXPHQW 0HDQLQJ

GDWH� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��<RX�FDQ�QHVW�72B'$7(�WR�FRQYHUW�VWULQJV�WR�GDWHV�EHIRUH�URXQGLQJ��

IRUPDW� 2SWLRQDO��(QWHU�D�YDOLG�IRUPDW�VWULQJ��7KLV�LV�WKH�SRUWLRQ�RI�WKH�GDWH�WKDW�\RX�ZDQW�WR�URXQG��<RX�FDQ�URXQG�RQO\�RQH�SRUWLRQ�RI�WKH�GDWH��,I�\RX�RPLW�WKH�IRUPDW�VWULQJ��WKH�IXQFWLRQ�URXQGV�WKH�GDWH�WR�WKH�QHDUHVW�GD\��

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:30AM Jan 1 1998 12:00:00AM

Apr 19 1998 1:31:20PM Jan 1 1998 12:00:00AM

Dec 20 1998 3:29:55PM Jan 1 1999 12:00:00AM

NULL NULL

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:30AM Jan 1 1998 12:00:00AM

Apr 19 1998 1:31:20PM May 1 1998 12:00:00AM

Dec 20 1998 3:29:55PM Jan 1 1999 12:00:00AM

NULL NULL

���� &KDSWHU����)XQFWLRQV

Page 161: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The following expressions round the day portion of each date in the DATE_SHIPPED port:

ROUND( DATE_SHIPPED, ’D’ )

ROUND( DATE_SHIPPED, ’DD’ )

ROUND( DATE_SHIPPED, ’DDD’ )

ROUND( DATE_SHIPPED, ’DY’ )

ROUND( DATE_SHIPPED, ’DAY’ )

The following expressions round the hour portion of each date in the DATE_SHIPPED port:

ROUND( DATE_SHIPPED, ’HH’ )

ROUND( DATE_SHIPPED, ’HH12’ )

ROUND( DATE_SHIPPED, ’HH24’ )

The following expression rounds the minute portion of each date in the DATE_SHIPPED port:

ROUND( DATE_SHIPPED, ’MI’ )

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:30AM Jan 15 1998 12:00:00AM

Apr 19 1998 1:31:20PM Apr 20 1998 12:00:00AM

Dec 20 1998 3:29:55PM Dec 21 1998 12:00:00AM

Dec 31 1998 11:59:59PM Jan 1 1999 12:00:00AM

NULL NULL

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:31AM Jan 15 1998 2:00:00AM

Apr 19 1998 1:31:20PM Apr 19 1998 2:00:00PM

Dec 20 1998 3:29:55PM Dec 20 1998 3:00:00PM

Dec 31 1998 11:59:59PM Jan 1 1999 12:00:00AM

NULL NULL

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:30AM Jan 15 1998 2:11:00AM

Apr 19 1998 1:31:20PM Apr 19 1998 1:31:00PM

Dec 20 1998 3:29:55PM Dec 20 1998 3:30:00PM

Dec 31 1998 11:59:59PM Jan 1 1999 12:00:00AM

NULL NULL

5281'��'DWHV��� ���

Page 162: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ROUND (Numbers)

Rounds numbers to a specified number of digits or decimal places. You can also use ROUND to round dates.

SyntaxROUND( numeric_value [, precision] )

Return ValueNumeric value.

If one of the arguments is NULL, ROUND returns NULL.

-�����If the return value is a decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

ExampleThe following expression returns the values in the Price port rounded to three decimal places.

ROUND( PRICE, 3 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��<RX�FDQ�XVH�RSHUDWRUV�WR�SHUIRUP�DULWKPHWLF�EHIRUH�\RX�URXQG�WKH�YDOXHV�

SUHFLVLRQ� 2SWLRQDO��3RVLWLYH�RU�QHJDWLYH�LQWHJHU��,I�\RX�HQWHU�D�SRVLWLYH�SUHFLVLRQ��WKH�IXQFWLRQ�URXQGV�WR�WKLV�QXPEHU�RI�GHFLPDO�SODFHV��)RU�H[DPSOH��5281'�����������UHWXUQV������DQG�5281'�����������UHWXUQV������,I�\RX�HQWHU�D�QHJDWLYH�SUHFLVLRQ��WKH�IXQFWLRQ�URXQGV�WKLV�QXPEHU�RI�GLJLWV�WR�WKH�OHIW�RI�WKH�GHFLPDO�SRLQW��UHWXUQLQJ�DQ�LQWHJHU��)RU�H[DPSOH��5281'������������UHWXUQV����DQG�5281'������������UHWXUQV����,I�\RX�HQWHU�GHFLPDO�SUHFLVLRQ��WKH�IXQFWLRQ�URXQGV�WR�WKH�QHDUHVW�LQWHJHU�EHIRUH�HYDOXDWLQJ�WKH�H[SUHVVLRQ��)RU�H[DPSOH��5281'�������������UHWXUQV������EHFDXVH�WKH�IXQFWLRQ�URXQGV�����WR���DQG�WKHQ�HYDOXDWHV�WKH�H[SUHVVLRQ�,I�\RX�RPLW�WKH�SUHFLVLRQ�DUJXPHQW��WKH�IXQFWLRQ�URXQGV�WR�WKH�QHDUHVW�LQWHJHU��WUXQFDWLQJ�WKH�GHFLPDO�SRUWLRQ�RI�WKH�QXPEHU��)RU�H[DPSOH��5281'��������UHWXUQV����

PRICE RETURN VALUE

12.9936 12.994

15.9949 15.995

-18.8678 -18.868

56.9561 56.956

NULL NULL

���� &KDSWHU����)XQFWLRQV

Page 163: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

You can round digits to the left of the decimal point by passing a negative integer in the precision argument:

ROUND( PRICE, -2 )

If you pass a decimal value in the precision argument, the Informatica Server rounds it to the nearest integer before evaluating the expression:

ROUND( PRICE, 0.8 )

If you omit the precision argument, the function rounds to the nearest integer:

ROUND( PRICE )

PRICE RETURN VALUE

13242.99 13200.0

1435.99 1400.0

-108.95 -100.0

NULL NULL

PRICE RETURN VALUE

12.99 12.9

56.34 56.3

NULL NULL

PRICE RETURN VALUE

12.99 13.0

-15.99 -16.0

-18.99 -19.0

56.95 57.0

NULL NULL

5281'��1XPEHUV��� ���

Page 164: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

RPAD

Converts a string to a specified length by adding blanks or characters to the end of the string.

SyntaxRPAD( first_string, length [,second_string] )

Return ValueString of the specified length.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the item name with a length of 16 characters, appending the string ’.’ to the end of each item name:

RPAD( ITEM_NAME, 16, ’.’)

RPAD counts the length from left to right. So, if the first string is longer than the length, RPAD truncates the string from right to left. For example, RPAD(‘alphabetical’, 5, ‘x’) would return the string ‘alpha’. RPAD uses a partial part of the second_string when necessary.

$UJXPHQW 0HDQLQJ

ILUVWBVWULQJ� 5HTXLUHG��$Q\�VWULQJ�YDOXH��7KH�VWULQJV�\RX�ZDQW�WR�FKDQJH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

OHQJWK� 5HTXLUHG��0XVW�EH�D�SRVLWLYH�LQWHJHU�OLWHUDO��6SHFLILHV�WKH�OHQJWK�\RX�ZDQW�HDFK�VWULQJ�WR�EH��

VHFRQGBVWULQJ� 2SWLRQDO��$Q\�VWULQJ�YDOXH��3DVVHV�WKH�VWULQJ�\RX�ZDQW�WR�DSSHQG�WR�WKH�ULJKW�VLGH�RI�WKH�ILUVWBVWULQJ�YDOXHV��(QFORVH�WKH�FKDUDFWHUV�\RX�ZDQW�WR�DGG�WR�WKH�HQG�RI�WKH�VWULQJ�ZLWKLQ�VLQJOH�TXRWDWLRQ�PDUNV��IRU�H[DPSOH��DEF��7KLV�DUJXPHQW�LV�FDVH�VHQVLWLYH�,I�\RX�RPLW�WKH�VHFRQG�VWULQJ��WKH�IXQFWLRQ�SDGV�WKH�HQG�RI�WKH�ILUVW�VWULQJ�ZLWK�EODQNV�

ITEM_NAME RETURN VALUE

Flashlight Flashlight......

Compass Compass.........

Regulator System Regulator System

Safety Knife Safety Knife....

���� &KDSWHU����)XQFWLRQV

Page 165: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The following expression returns the item name with a length of 16 characters, appending the string ‘*..*’ to the end of each item name:

RPAD( ITEM_NAME, 16, ’*..*’ )

ITEM_NAME RETURN VALUE

Flashlight Flashlight*..**.

Compass Compass*..**..**

Regulator System Regulator System

Safety Knife Safety Knife*..*

53$'�� ���

Page 166: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

RTRIM

Removes blanks or characters from the end of a string.

If you do not specify a trim_set parameter in your expression:

� In UNICODE mode, RTRIM removes both single- and double-byte spaces from the end of a string.

� In ASCII mode, RTRIM removes only single-byte spaces.

If you use RTRIM to remove characters from a string, RTRIM compares the trim_set to each character in the string argument, character-by-character, starting with the right side of the string. If the character in the string matches any character in the trim_set, RTRIM removes it. RTRIM continues comparing and removing characters until it fails to find a matching character in the trim_set. It returns the string, with any matching characters removed.

SyntaxRTRIM( string [, trim_set] )

Return ValueString. The string values with the specified characters in the trim_set argument removed.

NULL if a value passed to the function is NULL.

ExampleThe following expression removes the characters ‘re’ from the strings in the LAST_NAME port:

RTRIM( LAST_NAME, ’re’)

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��$Q\�VWULQJ�YDOXH��3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�WULP��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��<RX�FDQ�XVH�RSHUDWRUV�WR�SHUIRUP�FRPSDULVRQV�RU�FRQFDWHQDWH�VWULQJV�EHIRUH�UHPRYLQJ�EODQNV�IURP�WKH�HQG�RI�D�VWULQJ�

WULPBVHW� 2SWLRQDO��$Q\�VWULQJ�YDOXH��3DVVHV�WKH�FKDUDFWHUV�\RX�ZDQW�WR�UHPRYH�IURP�WKH�HQG�RI�WKH�VWULQJ��<RX�FDQ�DOVR�HQWHU�D�WH[W�OLWHUDO��KRZHYHU��\RX�PXVW�HQFORVH�WKH�FKDUDFWHUV�\RX�ZDQW�WR�UHPRYH�IURP�WKH�HQG�RI�WKH�VWULQJ�ZLWKLQ�VLQJOH�TXRWDWLRQ�PDUNV��IRU�H[DPSOH��DEF��$OVR�QRWH�WKDW�575,0�LV�FDVH�VHQVLWLYH��,I�\RX�RPLW�WKH�VHFRQG�VWULQJ��WKH�IXQFWLRQ�UHPRYHV�EODQNV�IURP�WKH�HQG�RI�WKH�ILUVW�VWULQJ�

LAST_NAME RETURN VALUE

Nelson Nelson

Page Pag

Osborne Osborn

���� &KDSWHU����)XQFWLRQV

Page 167: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

RTRIM removes ‘e’ from Page even though ‘r’ is the first character in the trim_set. This is because RTRIM searches, character-by-character, for the set of characters you specify in the trim_set argument. If the last character in the string matches the first character in the trim_set, RTRIM removes it. If, however, the last character in the string does not match, RTRIM compares the second character in the trim_set. If the second from last character in the string matches the second character in the trim_set, RTRIM removes it, and so on. When the character in the string fails to match the trim_set, RTRIM returns the string and evaluates the next row.

In the last example, the last character in Nelson does not match any character in the trim_set argument, so RTRIM returns the string 'Nelson' and evaluates the next row.

TipsYou can use RTRIM and LTRIM with || or CONCAT to remove leading and trailing blanks after you concatenate two strings.

You can also remove multiple sets of characters by nesting RTRIM. For example, if you want to remove trailing blanks and the character ‘t’ from the end of each string in a column of names, you might create an expression similar to the following:

RTRIM( RTRIM( NAMES ), ’t’ )

NULL NULL

Sawyer Sawy

H. Bender H. Bend

Steadman Steadman

LAST_NAME RETURN VALUE

575,0�� ���

Page 168: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SETCOUNTVARIABLE

Counts the rows evaluated by the function and increments the current value of a mapping variable based on the count. Increases the current value by one for each row marked for insertion. Decreases the current value by one for each row marked for deletion. Keeps the current value the same for each row marked for update or reject. Returns the new current value.

At the end of a successful session, the Informatica Server saves the last current value to the repository. When used with a partitioned session, the Informatica Server generates different current values for each partition. At the end of the session, it determines the total count for all partitions and saves the total to the repository. Unless overridden, it uses the saved value as the initial value of the variable for the next session run.

Use SETCOUNTVARIABLE with mapping variables with a Count aggregation type. Use SETCOUNTVARIABLE in the following transformations:

� Expression

� Filter

� Router

� Update Strategy

The Informatica Server does not save the final value of a mapping variable to the repository when any of the following are true:

� The session fails to complete.

� The session is configured for a test load.

� The session is a debug session.

� The session runs in debug mode and is configured to discard session output.

For details on mapping variables, see “Mapping Parameters and Variables” in the Designer Guide.

SyntaxSETCOUNTVARIABLE( $$Variable )

Return ValueThe current value of the variable.

$UJXPHQW 0HDQLQJ

��9DULDEOH 5HTXLUHG��1DPH�RI�WKH�PDSSLQJ�YDULDEOH�\RX�ZDQW�WR�VHW��8VH�PDSSLQJ�YDULDEOHV�ZLWK�D�FRXQW�DJJUHJDWLRQ�W\SH�

���� &KDSWHU����)XQFWLRQV

Page 169: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleYou have a mapping that updates a slowly changing dimension table containing distributor information. The following expression counts the number of current distributors with the mapping variable $$CurrentDistributors and returns the current value to the CUR_DIST port. It increases the count by one for each inserted row, decreases the count for each deleted row, and keeps the count the same for all updated or rejected rows. The initial value of $$CurrentDistributors from the previous session run is 23.

SETCOUNTVARIABLE ($$CurrentDistributors)

At the end of the session, the Informatica Server saves ‘25’ to the repository as the current value for $$CurrentDistributors. The next time the session runs, the Informatica Server evaluates the initial value to $$CurrentDistributors to ‘25’.

Suppose the same session is partitioned into three sections. The Informatica Server then evaluates $$CurrentDistributors for each partition, then saves the full count to the repository. For example, the last evaluated value for $$CurrentDistributors in each partition is as follows:

(row marked for...) DIST_ID DISTRIBUTOR CUR_DIST

(update) 000015 MSD Inc. 23

(insert) 000024 Darkroom Co. 24

(insert) 000025 Howard’s Supply 25

(update) 000003 JNR Ltd. 25

(delete) 000024 Darkroom Co. 24

(insert) 000026 Supply.com 25

3DUWLWLRQ)LQDO�&XUUHQW�9DOXH�IRU���&XUUHQW'LVWULEXWRUV

9DOXH�,QFUHPHQWHG�IRU���&XUUHQW'LVWULEXWRU�SHU�3DUWLWLRQ

3DUWLWLRQ�� �� ��

3DUWLWLRQ�� �� ��

3DUWLWLRQ�� �� ��

,QLWLDO�YDOXH�IRU���&XUUHQW'LVWULEXWRUV�DW�WKH�EHJLQQLQJ�RI�WKH�VHVVLRQ����7RWDO���&XUUHQW'LVWULEXWRU�YDOXH�LQFUHPHQWHG�DFURVV�DOO�SDUWLWLRQV���9DOXH�IRU���&XUUHQW'LVWULEXWRUV�VDYHG�WR�WKH�UHSRVLWRU\����

6(7&28179$5,$%/(�� ���

Page 170: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SET_DATE_PART

Sets one part of a date/time value to a value you specify. With SET_DATE_PART you can change the following parts of a date:

� Year. Change the year by entering a positive integer in the value argument. You can use any of the year format strings: Y, YY, YYY, or YYYY to set the year. For example, the expression SET_DATE_PART( SHIP_DATE, ’YY’, 2001 ) changes the year to 2001 for all dates in the SHIP_DATE port.

� Month. Change the month by entering a positive integer between 1 and 12 (January=1 and December=12) in the value argument. You can use any of the month format strings: MM, MON, MONTH to set the month. For example, the expression SET_DATE_PART( SHIP_DATE, ’MONTH’, 10 ) changes the month to October for all dates in the SHIP_DATE port.

� Day. Change the day by entering a positive integer between 1 and 31 (except for the months that have less than 31 days: February, April, June, September, and November) in the value argument. You can use any of the month format strings (D, DD, DDD, DY, and DAY) to set the day. For example, the expression SET_DATE_PART( SHIP_DATE, ’DD’, 10 ) changes the day to 10 for all dates in the SHIP_DATE port.

� Hour. Change the hour by entering a positive integer between 0 and 24 (where 0=12AM, 12=12PM, and 24 =12AM) in the value argument. You can use any of the hour format strings (HH, HH12, HH24) to set the hour. For example, the expression SET_DATE_PART( SHIP_DATE, ’HH’, 14 ) changes the hour to 14:00:00 (or 2:00:00PM) for all dates in the SHIP_DATE port.

� Minute. Change the minutes by entering a positive integer between 0 and 59 in the value argument. You use the MI format string to set the minute. For example, the expression SET_DATE_PART( SHIP_DATE, ’MI’, 25 ) changes the minute to 25 for all dates in the SHIP_DATE port.

� Seconds. You can change the seconds by entering a positive integer between 0 and 59 in the value argument. You use the SS format string to set the second. For example, the expression SET_DATE_PART( SHIP_DATE, ’SS’, 59 ) changes the second to 59 for all dates in the SHIP_DATE port.

SyntaxSET_DATE_PART( date, format, value )

$UJXPHQW 0HDQLQJ

GDWH� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��7KH�GDWH�\RX�ZDQW�WR�PRGLI\��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��

���� &KDSWHU����)XQFWLRQV

Page 171: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Return ValueDate in the same format as the source date with the specified part changed.

NULL if a value passed to the function is NULL.

ExampleThe following expressions change the hour to 4PM for each date in the DATE_PROMISED port:

SET_DATE_PART( DATE_PROMISED, ’HH’, 16 )

SET_DATE_PART( DATE_PROMISED, ’HH12’, 16 )

SET_DATE_PART( DATE_PROMISED, ’HH24’, 16 )

The following expressions change the month to June for the dates in the DATE_PROMISED port. The Informatica Server displays an error when you try to create a date that does not exist, such as changing March 31 to June 31:

SET_DATE_PART( DATE_PROMISED, ’MM’, 6 )

SET_DATE_PART( DATE_PROMISED, ’MON’, 6 )

SET_DATE_PART( DATE_PROMISED, ’MONTH’, 6 )

IRUPDW� 5HTXLUHG��$�IRUPDW�VWULQJ�VSHFLI\LQJ�WKH�SRUWLRQ�RI�WKH�GDWH�WR�EH�FKDQJHG��7KH�IRUPDW�VWULQJ�LV�QRW�FDVH�VHQVLWLYH�

YDOXH� 5HTXLUHG��$�SRVLWLYH�LQWHJHU�YDOXH�DVVLJQHG�WR�WKH�VSHFLILHG�SRUWLRQ�RI�WKH�GDWH��7KH�LQWHJHU�PXVW�EH�D�YDOLG�YDOXH�IRU�WKH�SDUW�RI�WKH�GDWH�\RX�ZDQW�WR�FKDQJH��LI�\RX�HQWHU�DQ�LPSURSHU�YDOXH��IRU�H[DPSOH��)HEUXDU\������WKH�VHVVLRQ�IDLOV�

DATE_PROMISED RETURN VALUE

Jan 1 1997 12:15:56AM Jan 1 1997 4:15:56PM

Feb 13 1997 2:30:01AM Feb 13 1997 4:30:01PM

Mar 31 1997 5:10:15PM Mar 31 1997 4:10:15PM

Dec 12 1997 8:07:33AM Dec 12 1997 4:07:33PM

NULL NULL

DATE_PROMISED RETURN VALUE

Jan 1 1997 12:15:56AM Jun 1 1997 4:15:56PM

Feb 13 1997 2:30:01AM Jun 13 1997 4:30:01PM

Mar 31 1997 5:10:15PM Error. Informatica Server doesn’t write row.

Dec 12 1997 8:07:33AM Jun 12 1997 4:07:33PM

NULL NULL

$UJXPHQW 0HDQLQJ

6(7B'$7(B3$57�� ���

Page 172: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The following expressions change the year to 2000 for the dates in the DATE_PROMISED port:

SET_DATE_PART( DATE_PROMISED, ’Y’, 2000 )

SET_DATE_PART( DATE_PROMISED, ’YY’, 2000 )

SET_DATE_PART( DATE_PROMISED, ’YYY’, 2000 )

SET_DATE_PART( DATE_PROMISED, ’YYYY’, 2000 )

TipIf you want to change multiple parts of a date at one time, you can nest multiple SET_DATE_PART functions within the date argument. For example, you might write the following expression to change all of the dates in the DATE_ENTERED port to July 1 1998:

SET_DATE_PART( SET_DATE_PART( SET_DATE_PART( DATE_ENTERED, ’YYYY’, 1998),MM’, 7), ’DD’, 1)

DATE_PROMISED RETURN VALUE

Jan 1 1997 12:15:56AM Jan 1 2000 12:15:56AM

Feb 13 1997 2:30:01AM Feb 13 2000 2:30:01AM

Mar 31 1997 5:10:15PM Mar 31 2000 5:10:15PM

Dec 12 1997 8:07:33AM Dec 12 2000 4:07:33PM

NULL NULL

���� &KDSWHU����)XQFWLRQV

Page 173: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SETMAXVARIABLE

Sets the current value of a mapping variable to the higher of two values: the current value of the variable or the value you specify. Returns the new current value.The SETMAXVARIABLE function executes only if a row is marked as insert. SETMAXVARIABLE ignores all other row types and the current value remains unchanged.

At the end of a successful session, the Informatica Server saves the final current value to the repository. When used with a partitioned session, the Informatica Server generates different current values for each partition. At the end of the session, it saves the highest current value across all partitions to the repository. Unless overridden, it uses the saved value as the initial value of the variable for the next session run.

When used with a string mapping variable, SETMAXVARIABLE returns the higher string based on the sort order selected for the session.

Use SETMAXVARIABLE with mapping variables with a Max aggregation type. Use SETMAXVARIABLE in the following transformations:

� Expression

� Filter

� Router

� Update Strategy

The Informatica Server does not save the final value of a mapping variable to the repository when any of the following are true:

� The session fails to complete.

� The session is configured for a test load.

� The session is a debug session.

� The session runs in debug mode and is configured to discard session output.

For details on mapping variables, see “Mapping Parameters and Variables” in the Designer Guide.

SyntaxSETMAXVARIABLE( $$Variable, value )

$UJXPHQW 0HDQLQJ

��9DULDEOH 5HTXLUHG��1DPH�RI�WKH�PDSSLQJ�YDULDEOH�\RX�ZDQW�WR�VHW��8VH�PDSSLQJ�YDULDEOHV�ZLWK�0D[�DJJUHJDWLRQ�W\SH�

YDOXH 5HTXLUHG��7KH�YDOXH�\RX�ZDQW�WKH�,QIRUPDWLFD�6HUYHU�WR�FRPSDUH�DJDLQVW�WKH�FXUUHQW�YDOXH�RI�WKH�YDULDEOH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�GDWDW\SH�FRPSDWLEOH�ZLWK�WKH�GDWDW\SH�RI�WKH�YDULDEOH�

6(70$;9$5,$%/(�� ���

Page 174: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Return ValueThe higher of two values: the current value of the variable or the value you specified. The return value is the new current value of the variable.

When value is NULL the Informatica Server returns the current value of $$Variable.

ExampleThe following expression compares the number of items purchased in each transaction with a mapping variable $$MaxItems. It sets $$MaxItems to the higher of two values and returns the historically highest number of items purchased in a single transaction to the MAX_ITEMS port. The initial value of $$MaxItems from the previous session run is 22.

SETMAXVARIABLE ($$MAXITEMS, ITEMS)

At the end of the session, the Informatica Server saves ‘35’ to the repository as the maximum current value for $$MaxItems. The next time the session runs, the Informatica Server evaluates the initial value to $$MaxItems to ‘35’.

Suppose the same session is partitioned into three sections. The Informatica Server evaluates $$MaxItems for each partition. Then, it saves the largest value to the repository. For example, the last evaluated value for $$MaxItems in each partition is as follows:

TRANSACTION ITEMS MAX_ITEMS

0100002 12 22

0100003 5 22

0100004 18 22

0100005 35 35

0100006 5 35

0100007 14 35

3DUWLWLRQ )LQDO�&XUUHQW�9DOXH�IRU���0D[,WHPV

3DUWLWLRQ�� ��

3DUWLWLRQ�� ��

3DUWLWLRQ�� ��

9DOXH�IRU���0D[,WHPV�VDYHG�WR�WKH�UHSRVLWRU\����

���� &KDSWHU����)XQFWLRQV

Page 175: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SETMINVARIABLE

Sets the current value of a mapping variable to the lower of two values: the current value of the variable or the value you specify. Returns the new current value.The SETMINVARIABLE function executes only if a row is marked as insert. SETMINVARIABLE ignores all other row types and the current value remains unchanged.

At the end of a successful session, the Informatica Server saves the final current value to the repository. When used with a partitioned session, the Informatica Server generates different current values for each partition. At the end of the session, it saves the lowest current value across all partitions to the repository. Unless overridden, it uses the saved value as the initial value of the variable for the next session run.

When used with a string mapping variable, SETMINVARIABLE returns the lower string based on the sort order selected for the session.

Use SETMINVARIABLE with mapping variables with a Min aggregation type. Use SETMINVARIABLE in the following transformations:

� Expression

� Filter

� Router

� Update Strategy

The Informatica Server does not save the final value of a mapping variable to the repository when any of the following are true:

� The session fails to complete.

� The session is configured for a test load.

� The session is a debug session.

� The session runs in debug mode and is configured to discard session output.

For details on mapping variables, see “Mapping Parameters and Variables” in the Designer Guide.

SyntaxSETMINVARIABLE( $$Variable, value )

$UJXPHQW 0HDQLQJ

��9DULDEOH 5HTXLUHG��1DPH�RI�WKH�PDSSLQJ�YDULDEOH�\RX�ZDQW�WR�VHW��8VH�ZLWK�PDSSLQJ�YDULDEOHV�ZLWK�0LQ�DJJUHJDWLRQ�W\SH�

YDOXH 5HTXLUHG��7KH�YDOXH�\RX�ZDQW�WKH�,QIRUPDWLFD�6HUYHU�WR�FRPSDUH�DJDLQVW�WKH�FXUUHQW�YDOXH�RI�WKH�YDULDEOH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�GDWDW\SH�FRPSDWLEOH�ZLWK�WKH�GDWDW\SH�RI�WKH�YDULDEOH�

6(70,19$5,$%/(�� ���

Page 176: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Return ValueThe lower of two values: the current value of the variable or the value you specified. The return value is the new current value of the variable.

When value is NULL the Informatica Server returns the current value of $$Variable.

ExampleThe following expression compares the price of an item with a mapping variable $$MinPrice. It sets $$MinPrice to the lower of two values and returns the historically lowest item price to the MIN_PRICE port. The initial value of $$MinPrice from the previous session run is 22.50.

SETMINVARIABLE ($$MinPrice, PRICE)

At the end of the session, the Informatica Server saves ‘22.00’ to the repository as the minimum current value for $$MinPrice. The next time the session runs, the Informatica Server evaluates the initial value to $$MinPrice to ‘22.00’.

Suppose the same session is partitioned into three sections. The Informatica Server evaluates $$MinPrice for each partition. Then, it saves the smallest value to the repository. For example, the last evaluated value for $$MinPrice in each partition is as follows:

DATE PRICE MIN_PRICE

05/01/2000 09:00:00 23.50 22.50

05/01/2000 10:00:00 27.00 22.50

05/01/2000 11:00:00 26.75 22.50

05/01/2000 12:00:00 25.25 22.50

05/01/2000 13:00:00 22.00 22.00

05/01/2000 14:00:00 22.75 22.00

05/01/2000 15:00:00 23.00 22.00

05/01/2000 16:00:00 24.25 22.00

05/01/2000 17:00:00 24.00 22.00

3DUWLWLRQ )LQDO�&XUUHQW�9DOXH�IRU���0LQ3ULFH

3DUWLWLRQ�� �����

3DUWLWLRQ�� �����

3DUWLWLRQ�� �����

9DOXH�IRU���0LQ3ULFH�VDYHG�WR�WKH�UHSRVLWRU\�������

���� &KDSWHU����)XQFWLRQV

Page 177: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SETVARIABLE

Sets the current value of a mapping variable to a value you specify. Returns the specified value. The SETVARIABLE function executes only if a row is marked as insert. SETVARIABLE ignores all other row types and the current value remains unchanged.

At the end of a successful session, the Informatica Server compares the final current value of the variable to the start value of the variable. Based on the aggregate type of the variable, it saves a final current value to the repository. Unless overridden, it uses the saved value as the initial value of the variable for the next session run.

Use SETVARIABLE in the following transformations:

� Expression

� Filter

� Router

� Update Strategy

The Informatica Server does not save the final value of a mapping variable to the repository when any of the following are true:

� The session fails to complete.

� The session is configured for a test load.

� The session is a debug session.

� The session runs in debug mode and is configured to discard session output.

For details on mapping variables, see “Mapping Parameters and Variables” in the Designer Guide.

SyntaxSETVARIABLE( $$Variable, value )

Return ValueCurrent value of the variable.

When value is NULL the Informatica Server returns the current value of $$Variable.

$UJXPHQW 0HDQLQJ

��9DULDEOH 5HTXLUHG��1DPH�RI�WKH�PDSSLQJ�YDULDEOH�\RX�ZDQW�WR�VHW��8VH�ZLWK�PDSSLQJ�YDULDEOHV�ZLWK�0D[�0LQ�DJJUHJDWLRQ�W\SH�

YDOXH 5HTXLUHG��7KH�YDOXH�\RX�ZDQW�WR�VHW�WKH�FXUUHQW�YDOXH�RI�WKH�YDULDEOH�WR��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�GDWDW\SH�FRPSDWLEOH�ZLWK�WKH�GDWDW\SH�RI�WKH�YDULDEOH�

6(79$5,$%/(�� ���

Page 178: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression sets a mapping variable $$Time to the system date at the time the Informatica Server evaluates the row and returns the system date to the SET_$$TIME port:

SETVARIABLE ($$Time, SYSDATE)

At the end of the session, the Informatica Server saves “10/10/2000 01:34:37” to the repository as the last evaluated current value for $$Time. The next time the session runs, the Informatica Server evaluates all references to $$Time to “10/10/2000 01:34:37”.

The following expression sets the mapping variable $$Timestamp to the timestamp associated with the row and returns the timestamp to the SET_$$TIMESTAMP port:

SETVARIABLE ($$Time, TIMESTAMP)

At the end of the session, the Informatica Server saves “10/01/2000 12:40:31” to the repository as the last evaluated current value for $$Timestamp.

The next time the session runs, the Informatica Server evaluates the initial value of $$Timestamp to “10/01/2000 12:40:31”.

TRANSACTION TOTAL SET_$$TIME

0100002 534.23 10/10/2000 01:34:33

0100003 699.01 10/10/2000 01:34:34

0100004 97.50 10/10/2000 01:34:35

0100005 116.43 10/10/2000 01:34:36

0100006 323.95 10/10/2000 01:34:37

TRANSACTION TIMESTAMP TOTAL SET_$$TIMESTAMP

0100002 10/01/2000 12:01:01 534.23 10/01/2000 12:01:01

0100003 10/01/2000 12:10:22 699.01 10/01/2000 12:10:22

0100004 10/01/2000 12:16:45 97.50 10/01/2000 12:16:45

0100005 10/01/2000 12:23:10 116.43 10/01/2000 12:23:10

0100006 10/01/2000 12:40:31 323.95 10/01/2000 12:40:31

���� &KDSWHU����)XQFWLRQV

Page 179: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SIGN

Returns whether a numeric value is positive, negative, or 0.

SyntaxSIGN( numeric_value )

Return Value-1 for negative values.

0 for 0.

1 for positive values.

NULL if NULL.

ExampleThe following expression tells you if the SALES port includes any negative values:

SIGN( SALES )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�YDOXH��3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�HYDOXDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

SALES RETURN VALUE

100 1

-25.99 -1

0 0

NULL NULL

6,*1�� ���

Page 180: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SIN

Returns the sine of a numeric value (expressed in radians).

SyntaxSIN( numeric_value )

Return ValueDouble value.

NULL if a value passed to the function is NULL.

ExampleThe following expression converts the values in the Degrees port to radians and then calculates the sine for each radian:

SIN( DEGREES * 3.14159265359 / 180 )

You can perform arithmetic on the values passed to SIN before the function calculates the sine. For example:

SIN( ARCS * 3.14159265359 / 180 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��1XPHULF�GDWD�H[SUHVVHG�LQ�UDGLDQV��GHJUHHV�PXOWLSOLHG�E\�SL�GLYLGHG�E\�������3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�WKH�VLQH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��<RX�FDQ�DOVR�XVH�RSHUDWRUV�WR�FRQYHUW�D�QXPHULF�YDOXH�WR�UDGLDQV�RU�SHUIRUP�DULWKPHWLF�ZLWKLQ�WKH�6,1�FDOFXODWLRQ��

DEGREES RETURN VALUE

0 0

90 1

70 0.939692620785936

50 0.766044443119015

30 0.50000000000003

5 0.0871557427476639

18 0.309016994374967

89 0.999847695156393

NULL NULL

���� &KDSWHU����)XQFWLRQV

Page 181: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SINH

Returns the hyperbolic sine of the numeric value.

SyntaxSINH( numeric_value )

Return ValueDouble value.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the hyperbolic sine for the values in the Angles port:

SINH( ANGLES )

TipYou can perform arithmetic on the values passed to SINH before the function calculates the hyperbolic sine. For example:

SINH( MEASURES.ARCS / 180 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��1XPHULF�GDWD�H[SUHVVHG�LQ�UDGLDQV��GHJUHHV�PXOWLSOLHG�E\�SL�GLYLGHG�E\�������3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�WKH�K\SHUEROLF�VLQH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ANGLES RETURN VALUE

1.0 1.1752011936438

2.897 9.03225804884884

3.66 19.4178051793031

5.45 116.376934801486

0 0.0

0.345 0.35188478309993

NULL NULL

6,1+�� ���

Page 182: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SQRT

Returns the square root of a positive numeric value.

SyntaxSQRT( numeric_value )

Return ValueDouble value.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the square root for the values in the Numbers port:

SQRT( NUMBERS )

The value -100 results in an error during the session, since the function SQRT only evaluates positive numeric values. If you pass a negative value or character value, the Informatica Server displays a Transformation Evaluation Error and does not write the row.

You can perform arithmetic on the values passed to SQRT before the function calculates the square root.

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��3RVLWLYH�QXPHULF�YDOXH��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�D�VTXDUH�URRW��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��

NUMBERS RETURN VALUE

100 10

-100 Error. Informatica Server does not write row.

NULL NULL

60.54 7.78074546557076

���� &KDSWHU����)XQFWLRQV

Page 183: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

STDDEV

Returns the standard deviation of the numeric values you pass to this function. STDDEV is used to analyze statistical data. You can nest only one other aggregate function within STDDEV, and the nested function must return a Numeric datatype.

STDDEV is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

SyntaxSTDDEV( numeric_value [,filter_condition] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����If the return value is decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsIf a single value is NULL, STDDEV ignores it. However, if all values are NULL, STDDEV returns NULL.

-�����By default, the Informatica Server treats null values as NULLS in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SHV��7KLV�IXQFWLRQ�SDVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�D�VWDQGDUG�GHYLDWLRQ�RU�WKH�UHVXOWV�RI�D�IXQFWLRQ��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��<RX�FDQ�XVH�RSHUDWRUV�WR�DYHUDJH�YDOXHV�LQ�GLIIHUHQW�SRUWV��

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

67''(9�� ���

Page 184: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Group BySTDDEV groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, STDDEV treats all rows as one group, returning one value.

ExampleThe following expression calculates the standard deviation of all rows greater than 2000.00 dollars in the TOTAL_SALES port:

STDDEV( SALES, SALES > 2000.00 )

The function does not include the values 1010.90 and 153.88 in the calculation because the filter_condition specifies sales greater than $2,000.

The following expression calculates the standard deviation of all rows in the SALES port:

STDDEV(SALES)

The return value is zero because each row contains the same number (no standard deviation exists). If there is no standard deviation, the return value is zero.

SALES

2198.0

1010.90

2256.0

153.88

3001.0

NULL

8953.0

RETURN VALUE: 3254.60361129688

SALES

2198.0

2198.0

2198.0

2198.0

RETURN VALUE: 0

���� &KDSWHU����)XQFWLRQV

Page 185: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SUBSTR

Returns a portion of a string. SUBSTR counts all characters, including blanks, starting at the beginning of the string.

SyntaxSUBSTR( string, start [,length] )

Return ValueString.

Empty string if you pass a negative or zero length value.

NULL if a value passed to the function is NULL.

ExampleThe following expressions return the area code for each row in the Phone port:

SUBSTR( PHONE, 0, 3 )

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��0XVW�EH�D�FKDUDFWHU�VWULQJ��3DVVHV�WKH�VWULQJV�\RX�ZDQW�WR�VHDUFK��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��,I�\RX�SDVV�D�QXPHULF�YDOXH��WKH�IXQFWLRQ�FRQYHUWV�LW�WR�D�FKDUDFWHU�VWULQJ�

VWDUW� 5HTXLUHG��0XVW�EH�DQ�LQWHJHU��7KH�SRVLWLRQ�LQ�WKH�VWULQJ�ZKHUH�\RX�ZDQW�WR�VWDUW�FRXQWLQJ��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��,I�WKH�VWDUW�SRVLWLRQ�LV�D�SRVLWLYH�QXPEHU��68%675�ORFDWHV�WKH�VWDUW�SRVLWLRQ�E\�FRXQWLQJ�IURP�WKH�EHJLQQLQJ�RI�WKH�VWULQJ��,I�WKH�VWDUW�SRVLWLRQ�LV�D�QHJDWLYH�QXPEHU��68%675�ORFDWHV�WKH�VWDUW�SRVLWLRQ�E\�FRXQWLQJ�IURP�WKH�HQG�RI�WKH�VWULQJ��,I�WKH�VWDUW�SRVLWLRQ�LV�]HUR��68%675�VHDUFKHV�IURP�WKH�ILUVW�FKDUDFWHU�LQ�WKH�VWULQJ�

OHQJWK� 2SWLRQDO��0XVW�EH�DQ�LQWHJHU�JUHDWHU�WKDQ�]HUR��7KH�QXPEHU�RI�FKDUDFWHUV�\RX�ZDQW�68%675�WR�UHWXUQ��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��,I�\RX�RPLW�WKH�OHQJWK�DUJXPHQW��68%675�UHWXUQV�DOO�RI�WKH�FKDUDFWHUV�IURP�WKH�VWDUW�SRVLWLRQ�WR�WKH�HQG�RI�WKH�VWULQJ��,I�\RX�SDVV�D�QHJDWLYH�LQWHJHU�RU�]HUR��WKH�IXQFWLRQ�UHWXUQV�DQ�HPSW\�VWULQJ��,I�\RX�SDVV�D�GHFLPDO��WKH�IXQFWLRQ�URXQGV�LW�WR�WKH�QHDUHVW�LQWHJHU�YDOXH�

PHONE RETURN VALUE

809-555-0269 809

357-687-6708 357

NULL NULL

68%675�� ���

Page 186: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SUBSTR( CUSTOMER.PHONE, 1, 3 )

The following expressions return the phone number without the area code for each row in the Phone port:

SUBSTR( PHONE, 5, 8 )

You can also pass a negative start value to return the phone number for each row in the Phone port. The expression still reads the source string from left to right when returning the result of the length argument:

SUBSTR( PHONE, -8, 3 )

You can nest INSTR in the start or length argument to search for a specific string and return its position.

The following expression evaluates a string, starting from the end of the string. The expression finds the last (right-most) space in the string and then returns all characters preceding it:

SUBSTR( CUST_NAME,1,INSTR( CUST_NAME,’ ’ ,-1,1 ) - 1 )

The following expression strips out the character ‘#’ from a string:

SUBSTR( 1, INSTR( CUST_ID,’#’ )-1 ) || SUBSTR( INSTR( CUST_ID,’#’ )+1 )

PHONE RETURN VALUE

809-555-3915 809

357-687-6708 357

NULL NULL

PHONE RETURN VALUE

808-555-0269 555-0269

809-555-3915 555-3915

357-687-6708 687-6708

NULL NULL

PHONE RETURN VALUE

808-555-0269 555

809-555-3915 555

357-687-6708 687

NULL NULL

CUST_NAME RETURN VALUE

PATRICIA JONES PATRICIA

MARY ELLEN SHAH MARY ELLEN

���� &KDSWHU����)XQFWLRQV

Page 187: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

When the length argument is longer than the string, SUBSTR returns all the characters from the start position to the end of the string. For example:

SUBSTR(’abcd’, 2, 8)

returns ’bcd’ and

SUBSTR(’abcd’, -2, 8)

returns ’cd’.

68%675�� ���

Page 188: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SUM

Returns the sum of all values in the selected port. Optionally, you can apply a filter to limit the rows you read to calculate the total. You can nest only one other aggregate function within SUM, and the nested function must return a Numeric datatype.

SUM is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

SyntaxSUM( numeric_value [, filter_condition ] )

Return ValueNumeric value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter condition evaluates to FALSE or NULL for all rows).

-�����If the return value is decimal with precision greater than 15, you might want to select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

NullsIf a single value is NULL, SUM ignores it. However, if all values passed from the port are NULL, SUM returns NULL.

-�����By default, the Informatica Server treats null values as NULLS in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�DGG��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ��<RX�FDQ�XVH�RSHUDWRUV�WR�DGG�YDOXHV�LQ�GLIIHUHQW�SRUWV��

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

���� &KDSWHU����)XQFWLRQV

Page 189: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Group BySUM groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, SUM treats all rows as one group, returning one value.

ExampleThe following expression returns the sum of all values greater than 2000 in the Sales port:

SUM( SALES, SALES > 2000 )

TipYou can perform arithmetic on the values passed to SUM before the function calculates the total. For example:

SUM( QTY * PRICE - DISCOUNT )

SALES

2500.0

1900.0

1200.0

NULL

3458.0

4519.0

RETURN VALUE: 10477.0

680�� ���

Page 190: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TAN

Returns the tangent of a numeric value (expressed in radians).

SyntaxTAN( numeric_value )

Return ValueDouble value.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the tangent for all values in the Degrees port:

TAN( DEGREES * 3.14159 / 180 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��1XPHULF�GDWD�H[SUHVVHG�LQ�UDGLDQV��GHJUHHV�PXOWLSOLHG�E\�SL�GLYLGHG�E\�������3DVVHV�WKH�QXPHULF�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�WKH�WDQJHQW��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

DEGREES RETURN VALUE

70 2.74747741945531

50 1.19175359259435

30 0.577350269189672

5 0.0874886635259298

18 0.324919696232929

89 57.2899616310952

NULL NULL

���� &KDSWHU����)XQFWLRQV

Page 191: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TANH

Returns the hyperbolic tangent of the numeric value passed to this function.

SyntaxTANH( numeric_value )

Return ValueDouble value.

NULL if a value passed to the function is NULL.

ExampleThe following expression returns the hyperbolic tangent for the values in the Angles port:

TANH( ANGLES )

TipYou can perform arithmetic on the values passed to TANH before the function calculates the hyperbolic tangent. For example:

TANH( ARCS / 360 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��1XPHULF�GDWD�H[SUHVVHG�LQ�UDGLDQV��GHJUHHV�PXOWLSOLHG�E\�SL�GLYLGHG�E\�������3DVVHV�WKH�QXPHULF�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�WKH�K\SHUEROLF�WDQJHQW��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ANGLES RETURN VALUE

1.0 0.761594155955765

2.897 0.993926947790665

3.66 0.998676551914886

5.45 0.999963084213409

0 0.0

0.345 0.331933853503641

NULL NULL

7$1+�� ���

Page 192: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_CHAR (Dates)

Converts dates to character strings. TO_CHAR also converts numeric values to strings. You can convert the date into any format using the TO_CHAR format strings.

SyntaxTO_CHAR( date [,format] )

Return ValueString.

NULL if a value passed to the function is NULL.

ExampleThe following expression converts the dates in the DATE_PROMISED port to text in the format MON DD YYYY:

TO_CHAR( DATE_PROMISED, ’MON DD YYYY’ )

If you omit the format_string argument, TO_CHAR returns a string in the default date format:

TO_CHAR( DATE_PROMISED )

$UJXPHQW 0HDQLQJ

GDWH� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��3DVVHV�WKH�GDWH�YDOXHV�\RX�ZDQW�WR�FRQYHUW�WR�FKDUDFWHU�VWULQJV��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

IRUPDW� 2SWLRQDO��(QWHU�D�YDOLG�72B&+$5�IRUPDW�VWULQJ��7KH�IRUPDW�VWULQJ�GHILQHV�WKH�IRUPDW�RI�WKH�UHWXUQ�YDOXH��QRW�WKH�IRUPDW�IRU�WKH�YDOXHV�LQ�WKH�GDWH�DUJXPHQW��,I�\RX�RPLW�WKH�IRUPDW�VWULQJ��WKH�IXQFWLRQ�UHWXUQV�D�VWULQJ�EDVHG�RQ�WKH�GHIDXOW�GDWH�IRUPDW�RI�00�''�<<<<�++���0,�66�

DATE_PROMISED RETURN VALUE

Apr 1 1998 12:00:10AM ’Apr 01 1998’

Feb 22 1998 01:31:10PM ’Feb 22 1998’

Oct 24 1998 02:12:30PM ’Oct 24 1998’

NULL NULL

DATE_PROMISED RETURN VALUE

Apr 1 1998 12:00:10AM ’04/01/1997 00:00:01’

Feb 22 1998 01:31:10PM ’02/22/1997 13:31:10’

Oct 24 1998 02:12:30PM ’10/24/1997 14:12:30’

NULL NULL

���� &KDSWHU����)XQFWLRQV

Page 193: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The following expressions return the day of the week for each date in a port:

TO_CHAR( DATE_PROMISED, ’D’ )

TO_CHAR( DATE_PROMISED, ’DAY’ )

The following expression returns the day of the month for each date in a port:

TO_CHAR( DATE_PROMISED, ’DD’ )

The following expression returns the day of the year for each date in a port:

TO_CHAR( DATE_PROMISED, ’DDD’ )

The following expressions return the hour of the day for each date in a port:

TO_CHAR( DATE_PROMISED, ’HH’ )

TO_CHAR( DATE_PROMISED, ’HH12’ )

DATE_PROMISED RETURN VALUE

04-01-1997 12:00:10AM ’3’

02-22-1997 01:31:10PM ’7’

10-24-1997 02:12:30PM ’6’

NULL NULL

DATE_PROMISED RETURN VALUE

04-01-1997 12:00:10AM ’Tuesday’

02-22-1997 01:31:10PM ’Saturday’

10-24-1997 02:12:30PM ’Friday’

NULL NULL

DATE_PROMISED RETURN VALUE

04-01-1997 12:00:10AM ’01’

02-22-1997 01:31:10PM ’22’

10-24-1997 02:12:30PM ’24’

NULL NULL

DATE_PROMISED RETURN VALUE

04-01-1997 12:00:10AM ’091’

02-22-1997 01:31:10PM ’053’

10-24-1997 02:12:30PM ’297’

NULL NULL

DATE_PROMISED RETURN VALUE

04-01-1997 12:00:10AM ’12’

02-22-1997 01:31:10PM ’01’

72B&+$5��'DWHV��� ���

Page 194: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_CHAR( DATE_PROMISED, ’HH24’ )

The following expression converts date values to MJD values expressed as strings:

TO_CHAR( SHIP_DATE, ’J’)

The following expression converts dates to strings in the format MM/DD/YY:

TO_CHAR( SHIP_DATE, ‘MM/DD/RR’)

You can also use the format string SSSSS in a TO_CHAR expression. For example, the following expression converts the dates in the SHIP_DATE port to strings representing the total seconds since midnight:

TO_CHAR( SHIP_DATE, 'SSSSS')

In TO_CHAR expressions, the YY format string produces the same results as the RR format string.

The following expression converts dates to strings in the format MM/DD/YY:

TO_CHAR( SHIP_DATE, ‘MM/DD/YY’)

10-24-1997 02:12:30PM '02'

NULL NULL

DATE_PROMISED RETURN VALUE

04-01-1997 12:00:10AM '00'

02-22-1997 01:31:10PM '13'

10-24-1997 11:12:30PM '23'

NULL NULL

SHIP_DATE RETURN_VALUE

Dec 31 1999 03:59:59PM 2451544

Jan 1 1900 01:02:03AM 2415021

SHIP_DATE RETURN_VALUE

12/31/1999 01:02:03AM 12/31/99

09/15/1996 03:59:59PM 09/15/96

05/17/2003 12:13:14AM 05/17/03

SHIP_DATE RETURN_VALUE

12/31/1999 01:02:03AM 3783

09/15/1996 03:59:59PM 86399

SHIP_DATE RETURN_VALUE

12/31/1999 01:02:03AM 12/31/99

DATE_PROMISED RETURN VALUE

���� &KDSWHU����)XQFWLRQV

Page 195: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The following expression returns the week of the month for each date in a port:

TO_CHAR( DATE_PROMISED, ’W’ )

The following expression returns the week of the year for each date in a port:

TO_CHAR( DATE_PROMISED, ’WW’ )

TipYou can combine TO_CHAR and TO_DATE to convert a numeric value for a month into the text value for a month using a function such as:

TO_CHAR( TO_DATE( numeric_month, ‘MM’ ), ‘MONTH’ )

09/15/1996 03:59:59PM 09/15/96

05/17/2003 12:13:14AM 05/17/03

DATE_PROMISED RETURN VALUE

04-01-1997 12:00:10AM 01'

02-22-1997 01:31:10AM 04'

10-24-1997 02:12:30PM 04'

NULL NULL

DATE_PROMISED RETURN VALUE

04-01-1997 12:00:10PM '18'

02-22-1997 01:31:10AM '08'

10-24-1997 02:12:30AM '43'

NULL NULL

SHIP_DATE RETURN_VALUE

72B&+$5��'DWHV��� ���

Page 196: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_CHAR (Numbers)

Converts numeric values to text strings. TO_CHAR also converts dates to strings.

TO_CHAR converts numeric values to text strings as follows:

� Converts double values to strings of up to 16 digits, with accuracy up to 15 digits. If you pass a number with more than 15 digits, TO_CHAR rounds the number to the sixteenth digit.

� Returns decimal notation for numbers in the ranges (-1e16,-1e-16] and [1e-16, 1e16). TO_CHAR returns scientific notation for numbers outside these ranges.

Figure 6-1 illustrates that when TO_CHAR converts numbers to strings, it returns scientific notation for all numbers that fall along the bold line. It returns all other numbers in decimal notation.

-�����The Informatica Server converts the values 1e-16 and -1e16 to scientific notation, but returns the values 1e-16 and -1e-16 in decimal notation.

SyntaxTO_CHAR( numeric_value )

Return ValueString.

NULL if a value passed to the function is NULL.

Figure 6-1. Ranges for TO_CHAR Notation

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��7KH�QXPHULF�YDOXH�\RX�ZDQW�WR�FRQYHUW�WR�D�VWULQJ��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

� ��H����H���

VFLHQWLILF�QRWDWLRQVFLHQWLILFQRWDWLRQ

VFLHQWLILFQRWDWLRQ

( )��H��� �H���

� ��

���� &KDSWHU����)XQFWLRQV

Page 197: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression converts the values in the SALES port to text:

TO_CHAR( SALES )

SALES RETURN VALUE

1010.99 ‘1010.99’

-15.62567 ‘-15.62567’

10842764968208837340 ‘1.084276496820884e+019’ (rounded to 16th digit)

1.234567890123456789e-10 ‘0.0000000001234567890123457’(greater than 1e-16 but less than 1e16)

1.23456789012345e17 ‘1.23456789012345e17’ (greater than 1e16)

0 ‘0’

33.15 ‘33.15’

NULL NULL

72B&+$5��1XPEHUV��� ���

Page 198: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_DATE

Converts a character string to a date datatype in the same format as the character string. You use the TO_DATE format strings to specify the exact format of the source strings. You can use TO_DATE to convert strings from flat files to date values.

The output port must be date/time for TO_DATE expressions.

If you are converting two-digit years with TO_DATE, use either the RR or YY format string. Do not use the YYYY format string.

SyntaxTO_DATE( string [, format] )

Return ValueDate.

TO_DATE always returns a date and time. If you pass a string that does not have a time value, the date returned always includes the time 00:00:00. You can map the results of this function to any target column with a date datatype.

NULL if you pass a null value to this function.

.�������The format of the TO_DATE string must exactly match the format string. If it does not, the Informatica Server might return inaccurate values or skip the record. For details on the TO_DATE format string, see “Requirements” on page 42.

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��6WULQJ�RU�'DWH�7LPH�GDWDW\SH��3DVVHV�WKH�YDOXHV�WKDW�\RX�ZDQW�WR�FRQYHUW�WR�GDWHV��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

IRUPDW� 2SWLRQDO��(QWHU�D�YDOLG�72B'$7(�IRUPDW�VWULQJ��7KH�IRUPDW�VWULQJ�PXVW�PDWFK�WKH�SDUWV�RI�WKH�VWULQJ�DUJXPHQW�H[DFWO\��)RU�H[DPSOH��LI�\RX�SDVV�WKH�VWULQJ�0DU�����������������$0��\RX�PXVW�XVH�WKH�IRUPDW�VWULQJ�021�''�<<<<�++���0,�66$0��,I�\RX�RPLW�WKH�IRUPDW�VWULQJ��WKH�VWULQJ�YDOXH�PXVW�EH�LQ�WKH�GHIDXOW�GDWH�RI�00�''�<<<<�++���0,�66��

���� &KDSWHU����)XQFWLRQV

Page 199: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expression returns date values for the strings in the DATE_PROMISED port. TO_DATE always returns a date and time. If you pass a string that does not have a time value, the date returned always includes the time 00:00:00. If you run a session in the twentieth century, the century will be 19. The current year on the machine running the Informatica Server is 1998:

TO_DATE( DATE_PROMISED, ’MM/DD/YY’ )

The following expression returns date and time values for the strings in the DATE_PROMISED port. If you pass a string that does not have a time value, the Informatica Server returns an error. If you run a session in the twentieth century, the century will be 19. The current year on the machine running the Informatica Server is 1998:

TO_DATE( DATE_PROMISED, ’MON DD YYYY HH12:MI:SSAM’ )

The following expression converts strings in the SHIP_DATE_MJD_STRING port to date values in the default date format:

TO_DATE (SHIP_DATE_MJD_STR, ’J’)

Because the J format string does not include the time portion of a date, the return values have the time set to 00:00:00.

DATE_PROMISED RETURN VALUE

’01/22/98’ Jan 22 1998 00:00:00

’05/03/98’ May 3 1998 00:00:00

’11/10/98’ Nov 10 1998 00:00:00

’10/19/98’ Oct 19 1998 00:00:00

NULL NULL

DATE_PROMISED RETURN VALUE

’Jan 22 1998 02:14:56PM’ Jan 22 1998 02:14:56PM

’Mar 15 1998 11:11:11AM’ Mar 15 1998 11:11:11AM

’Jun 18 1998 10:10:10PM’ Jun 18 1998 10:10:10PM

’October 19 1998 ’ Error. Informatica Server skips this row.

NULL NULL

SHIP_DATE_MJD_STR RETURN_VALUE

2451544 Dec 31 1999 00:00:00

2415021 Jan 1 1900 00:00:00

72B'$7(�� ���

Page 200: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The following expression converts a string into a four-digit year format. The current year is 1998:

TO_DATE( DATE_STR, ‘MM/DD/RR’)

The following expression converts a string into a four-digit year format. The current year is 1998:

TO_DATE( DATE_STR, ‘MM/DD/YY’)

-�����For the second row, RR returns the year 2005 and YY returns the year 1905.

The following expression converts a string into a four-digit year format. The current year is 1998:

TO_DATE( DATE_STR, ‘MM/DD/Y’)

The following expression converts a string into a four-digit year format. The current year is 1998:

TO_DATE( DATE_STR, ‘MM/DD/YYY’)

The following expression converts strings that includes the seconds since midnight to date values:

TO_DATE( DATE_STR, 'MM/DD/YYYY SSSSS')

If your data warehouse accepts different date formats, you can use TO_DATE and IS_DATE with the DECODE function to test for acceptable formats. For example:

DATE_STR RETURN VALUE

04/01/98 04/01/1998 00:00:00

08/17/05 08/17/2005 00:00:00

DATE_STR RETURN VALUE

04/01/98 04/01/1998 00:00:00

08/17/05 08/17/1905 00:00:00

DATE_STR RETURN VALUE

04/01/8 04/01/1998 00:00:00

08/17/5 08/17/1995 00:00:00

DATE_STR RETURN VALUE

04/01/998 04/01/1998 00:00:00

08/17/995 08/17/1995 00:00:00

DATE_STR RETURN_VALUE

12/31/1999 3783 12/31/1999 01:02:03

09/15/1996 86399 09/15/1996 23:59:59

���� &KDSWHU����)XQFWLRQV

Page 201: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

DECODE( TRUE,

--test first format

IS_DATE( CLOSE_DATE,‘MM/DD/YYYY HH24:MI:SS’ ),

--if true, convert to date

TO_DATE( CLOSE_DATE,‘MM/DD/YYYY HH24:MI:SS’ ),

--test second format; if true, convert to date

IS_DATE( CLOSE_DATE,‘MM/DD/YYYY’), TO_DATE( CLOSE_DATE,‘MM/DD/YYYY’ ),

--test third format; if true, convert to date

IS_DATE( CLOSE_DATE,‘MON DD YYYY’), TO_DATE( CLOSE_DATE,‘MON DD YYYY’),

--if none of the above

ERROR( ‘NOT A VALID DATE’) )

You can combine TO_CHAR and TO_DATE to convert a numeric value for a month into the text value for a month using a function such as:

TO_CHAR( TO_DATE( numeric_month, ‘MM’ ), ‘MONTH’ )

72B'$7(�� ���

Page 202: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_DECIMAL

Converts any value (except binary) to a decimal value. TO_DECIMAL ignores leading spaces.

SyntaxTO_DECIMAL( value [, scale] )

Return ValueDecimal of precision and scale between 0 and 28, inclusive.

Zero if the value in the selected port is an empty string or a non-numeric character.

NULL if a value passed to the function is NULL.

If the return value is decimal with precision greater than 15, you might want to select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

ExampleThis expression uses values from the port IN_TAX. The datatype is decimal with precision of 10 and scale of 3:

TO_DECIMAL( IN_TAX, 3 )

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�ELQDU\���3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�FRQYHUW�WR�GHFLPDOV��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

VFDOH� 2SWLRQDO��0XVW�EH�DQ�LQWHJHU�OLWHUDO�EHWZHHQ���DQG�����LQFOXVLYH��6SHFLILHV�WKH�QXPEHU�RI�GLJLWV�DOORZHG�DIWHU�WKH�GHFLPDO�SRLQW��,I�\RX�RPLW�WKLV�DUJXPHQW��WKH�IXQFWLRQ�UHWXUQV�D�YDOXH�ZLWK�WKH�VDPH�VFDOH�DV�WKH�LQSXW�YDOXH�

IN_TAX RETURN VALUE

’15.6789’ 15.678

’60.2’ 60.200

’118.348’ 118.348

NULL NULL

’A12.3Grove’ 0

���� &KDSWHU����)XQFWLRQV

Page 203: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_FLOAT

Converts any value (except binary) to a double-precision floating point number (the Double datatype). TO_FLOAT ignores leading spaces.

SyntaxTO_FLOAT( value )

Return ValueDouble value.

Zero if the value in the port is blank or a non-numeric character.

NULL if a value passed to this function is NULL.

ExampleThis expression uses values from the port IN_TAX:

TO_FLOAT( IN_TAX )

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�FRQYHUW�WR�GRXEOH�YDOXHV��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

IN_TAX RETURN VALUE

’15.6789’ 15.6789

’60.2’ 60.2

’118.348’ 118.348

NULL NULL

’A12.3Grove’ 0

72B)/2$7�� ���

Page 204: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_INTEGER

Converts any value (except binary) to an integer by rounding the decimal portion of a value. TO_INTEGER ignores leading spaces.

SyntaxTO_INTEGER( value )

Return ValueInteger.

Zero if the value in the port is blank or alphanumeric.

NULL if a value passed to the function is NULL.

ExampleThis expression uses values from the port IN_TAX:

TO_INTEGER( IN_TAX )

$UJXPHQW 0HDQLQJ

YDOXH� 5HTXLUHG��$Q\�GDWDW\SH��H[FHSW�%LQDU\���3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�FRQYHUW�WR�LQWHJHUV��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

IN_TAX RETURN VALUE

’15.6789’ 16

’60.2’ 60

’118.348’ 118

NULL NULL

’A12.3Grove’ 0

‘ 123.87’ 124

‘-15.6789’ -16

‘-15.23’ -15

���� &KDSWHU����)XQFWLRQV

Page 205: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TO_NUMBER

Converts a string to a double value. TO_NUMBER ignores leading spaces.

SyntaxTO_NUMBER( string )

Return ValueDouble value.

Zero if the value in the port is blank or alphanumeric.

NULL if the value passed to the function is NULL.

-�����Windows NT recognizes ‘D’ and ‘d’ as scientific notation.

ExampleThis expression might use values from the port IN_TAX:

TO_NUMBER( IN_TAX )

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��6WULQJ�GDWDW\SH��3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�FRQYHUW�WR�QXPEHUV��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�FKDUDFWHU�VWULQJ�YDOXH�

IN_TAX RETURN VALUE

’15.6792’ 15.6792

’60.2’ 60.2

’118.351’ 118.351

NULL NULL

’A12.3Grove’ 0

‘123D9’ 123000000000.0 (Windows NT only)

‘123D9’ 0 (non-NT)

72B180%(5�� ���

Page 206: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TRUNC (Dates)

Truncates dates to a specific year, month, day, hour, or minute. You can also use TRUNC to truncate numbers.

You can truncate the following date parts:

� Year. If you truncate the year portion of the date, the function returns Jan 1 of the input year with the time set to 00:00:00. For example, the expression TRUNC(6/30/1997 2:30:55, ’YY’) returns 1/1/1997 00:00:00, and TRUNC(12/1/1997 3:10:15, ’YY’) returns 1/1/1997 00:00:00.

� Month. If you truncate the month portion of a date, the function returns the first day of the month with the time set to 00:00:00. For example, the expression TRUNC(4/15/1997 12:15:00, ’MM’) returns 4/1/1997 00:00:00, and TRUNC(4/30/1997 3:15:46, ’MM’) returns 4/1/1997 00:00:00.

� Day. If you truncate the day portion of a date, the function returns the date with the time set to 00:00:00. For example, the expression TRUNC(6/13/1997 2:30:45, ’DD’) returns 6/13/1997 00:00:00, and TRUNC(12/13/1997 22:30:45, ’DD’) returns 12/13/1997 00:00:00.

� Hour. If you truncate the hour portion of a date, the function returns the date with the minutes and seconds set to zero. For example, the expression TRUNC(4/1/1997 11:29:35, ’HH’) returns 4/1/1997 11:00:00, and TRUNC(4/1/1997 13:39:00, ’HH’) returns 4/1/1997 13:00:00.

� Minute. If you truncate the minute portion of a date, the function returns the date with the seconds set to zero. For example, the expression TRUNC(5/22/1997 10:15:29, ’MI’) returns 5/22/1997 10:15:00, and TRUNC(5/22/1997 10:18:30, ’MI’) returns 5/22/1997 10:18:00.

SyntaxTRUNC( date [,format] )

Return ValueDate.

NULL if a value passed to the function is NULL.

$UJXPHQW 0HDQLQJ

GDWH� 5HTXLUHG��'DWH�7LPH�GDWDW\SH��7KH�GDWH�YDOXHV�\RX�ZDQW�WR�WUXQFDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�GDWH�

IRUPDW�� 2SWLRQDO��(QWHU�D�YDOLG�IRUPDW�VWULQJ��7KH�IRUPDW�VWULQJ�LV�QRW�FDVH�VHQVLWLYH��,I�\RX�RPLW�WKH�IRUPDW�VWULQJ��WKH�IXQFWLRQ�WUXQFDWHV�WKH�WLPH�SRUWLRQ�RI�WKH�GDWH��VHWWLQJ�LW�WR����������

���� &KDSWHU����)XQFWLRQV

Page 207: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

ExampleThe following expressions truncate the year portion of dates in the DATE_SHIPPED port:

TRUNC( DATE_SHIPPED, ’Y’ )

TRUNC( DATE_SHIPPED, ’YY’ )

TRUNC( DATE_SHIPPED, ’YYY’ )

TRUNC( DATE_SHIPPED, ’YYYY’ )

The following expressions truncate the month portion of each date in the DATE_SHIPPED port:

TRUNC( DATE_SHIPPED, ’MM’ )

TRUNC( DATE_SHIPPED, ’MON’ )

TRUNC( DATE_SHIPPED, ’MONTH’ )

The following expressions truncate the day portion of each date in the DATE_SHIPPED port:

TRUNC( DATE_SHIPPED, ’D’ )

TRUNC( DATE_SHIPPED, ’DD’ )

TRUNC( DATE_SHIPPED, ’DDD’ )

TRUNC( DATE_SHIPPED, ’DY’ )

TRUNC( DATE_SHIPPED, ’DAY’ )

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:30AM Jan 1 1998 12:00:00AM

Apr 19 1998 1:31:20PM Jan 1 1998 12:00:00AM

Jun 20 1998 3:50:04AM Jan 1 1998 12:00:00AM

Dec 20 1998 3:29:55PM Jan 1 1998 12:00:00AM

NULL NULL

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:30AM Jan 1 1998 12:00:00AM

Apr 19 1998 1:31:20PM Apr 1 1998 12:00:00AM

Jun 20 1998 3:50:04AM Jun 1 1998 12:00:00AM

Dec 20 1998 3:29:55PM Dec 1 1998 12:00:00AM

NULL NULL

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:30AM Jan 15 1998 12:00:00AM

Apr 19 1998 1:31:20PM Apr 19 1998 12:00:00AM

Jun 20 1998 3:50:04AM Jun 20 1998 12:00:00AM

Dec 20 1998 3:29:55PM Dec 20 1998 12:00:00AM

7581&��'DWHV��� ���

Page 208: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

The following expressions truncate the hour portion of each date in the DATE_SHIPPED port:

TRUNC( DATE_SHIPPED, ’HH’ )

TRUNC( DATE_SHIPPED, ’HH12’ )

TRUNC( DATE_SHIPPED, ’HH24’ )

The following expression truncates the minute portion of each date in the DATE_SHIPPED port:

TRUNC( DATE_SHIPPED, ’MI’ )

Dec 31 1998 11:59:59PM Dec 31 1998 12:00:00AM

NULL NULL

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:31AM Jan 15 1998 2:00:00AM

Apr 19 1998 1:31:20PM Apr 19 1998 1:00:00PM

Jun 20 1998 3:50:04AM Jun 20 1998 3:00:00AM

Dec 20 1998 3:29:55PM Dec 20 1998 3:00:00PM

Dec 31 1998 11:59:59PM Dec 31 1998 11:00:00AM

NULL NULL

DATE_SHIPPED RETURN VALUE

Jan 15 1998 2:10:30AM Jan 15 1998 2:10:00AM

Apr 19 1998 1:31:20PM Apr 19 1998 1:31:00PM

Jun 20 1998 3:50:04AM Jun 20 1998 3:50:00AM

Dec 20 1998 3:29:55PM Dec 20 1998 3:29:00PM

Dec 31 1998 11:59:59PM Dec 31 1998 11:59:00PM

NULL NULL

DATE_SHIPPED RETURN VALUE

���� &KDSWHU����)XQFWLRQV

Page 209: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TRUNC (Numbers)

Truncates numbers to a specific digit. You can also use TRUNC to truncate dates.

SyntaxTRUNC( numeric_value [, precision] )

If precision is a positive integer, TRUNC returns numeric_value with the number of decimal places specified by precision. If precision is a negative integer, TRUNC changes the specified digits to the left of the decimal point to zeros. If you omit the precision argument, TRUNC truncates the decimal portion of numeric_value and returns an integer.

If you pass a decimal precision value, the Informatica Server rounds numeric_value to the nearest integer before evaluating the expression.

Return ValueNumeric value.

NULL if one of the arguments is NULL.

-�����If the return value is decimal with precision greater than 15, you can select Enable Decimal Arithmetic in the session property sheet to ensure decimal precision up to 28 digits.

ExampleThe following expressions truncate the values in the Price port:

TRUNC( PRICE, 3 )

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�WUXQFDWH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�D�1XPHULF�GDWDW\SH�

SUHFLVLRQ� 2SWLRQDO��&DQ�EH�D�SRVLWLYH�RU�QHJDWLYH�LQWHJHU��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�WKDW�HYDOXDWHV�WR�DQ�LQWHJHU��7KH�LQWHJHU�VSHFLILHV�WKH�QXPEHU�RI�GLJLWV�WR�WUXQFDWH��

PRICE RETURN VALUE

12.9995 12.999

-18.8652 -18.865

56.9563 56.956

15.9928 15.992

NULL NULL

7581&��1XPEHUV��� ���

Page 210: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

TRUNC( PRICE, -1 )

TRUNC( PRICE )

PRICE RETURN VALUE

12.99 10.0

-187.86 -180.0

56.95 50.0

1235.99 1230.0

NULL NULL

PRICE RETURN VALUE

12.99 12.0

-18.99 -18.0

56.95 56.0

15.99 15.0

NULL NULL

���� &KDSWHU����)XQFWLRQV

Page 211: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

UPPER

Converts lowercase string characters to uppercase.

SyntaxUPPER( string )

Return ValueUppercase string. If your data contains multibyte characters, the return value depends on the code page and data movement mode of the Informatica Server.

NULL if a value passed to the function is NULL.

ExampleThe following expression changes all names in the FIRST_NAME port to uppercase:

UPPER( FIRST_NAME )

$UJXPHQW 0HDQLQJ

VWULQJ� 5HTXLUHG��6WULQJ�GDWDW\SH��3DVVHV�WKH�YDOXHV�\RX�ZDQW�WR�FKDQJH�WR�XSSHUFDVH�WH[W��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

FIRST_NAME RETURN VALUE

Ramona RAMONA

NULL NULL

THOMAS THOMAS

PierRe PIERRE

Bernice BERNICE

833(5�� ���

Page 212: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

VARIANCE

Returns the variance of a value you pass to it. VARIANCE is used to analyze statistical data. You can nest only one other aggregate function within VARIANCE, and the nested function must return a Numeric datatype.

VARIANCE is one of several aggregate functions. You use aggregate functions in Aggregator transformations only. For more information, see “Aggregate Functions” on page 48.

SyntaxVARIANCE( numeric_value [, filter_condition ] )

FormulaThe function uses the following formula to calculate the variance:

where:

� xi is one of the numeric values.

� n is the number of elements in the set of numeric values. If n is 1, the variance is 0.

Return ValueDouble value.

NULL if all values passed to the function are NULL, or if no rows are selected (for example, the filter_condition evaluates to FALSE or NULL for all rows).

NullsIf a single value is NULL, VARIANCE ignores it. However, if all values passed to the function are NULL, or if no rows are selected, VARIANCE returns NULL.

$UJXPHQW 0HDQLQJ

QXPHULFBYDOXH� 5HTXLUHG��1XPHULF�GDWDW\SH��3DVVHV�WKH�YDOXHV�IRU�ZKLFK�\RX�ZDQW�WR�FDOFXODWH�D�YDULDQFH��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

ILOWHUBFRQGLWLRQ� 2SWLRQDO��/LPLWV�WKH�URZV�LQ�WKH�VHDUFK��7KH�ILOWHU�FRQGLWLRQ�PXVW�EH�D�QXPHULF�YDOXH�RU�HYDOXDWH�WR�758(��)$/6(��RU�18//��<RX�FDQ�HQWHU�DQ\�YDOLG�WUDQVIRUPDWLRQ�H[SUHVVLRQ�

���� &KDSWHU����)XQFWLRQV

Page 213: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

-�����By default, the Informatica Server treats null values as NULLs in aggregate functions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Informatica Server, you can choose how you want to handle null values in aggregate functions. You can treat null values as zero in aggregate functions (as in PowerMart 3.5) or as NULL. For more information on configuring the Informatica Server, see “Installing and Configuring the Informatica UNIX Server” or “Installing and Configuring the Informatica NT Server” in the Installation and Configuration Guide.

Group ByVARIANCE groups values based on group by ports you define in the transformation, returning one result for each group.

If there is no group by port, LAST treats all rows as one group, returning one value.

If there is not a group by port, VARIANCE treats all rows as one group, returning one value.

ExampleThe following expression calculates the variance of all rows in the TOTAL_SALES port:

VARIANCE( TOTAL_SALES )

TOTAL_SALES

2198.0

2256.0

3001.0

NULL

8953.0

RETURN VALUE: 10592444.6666667

9$5,$1&(�� ���

Page 214: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

���� &KDSWHU����)XQFWLRQV

Page 215: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� � � � � � � � � �

Function Quick Reference

This appendix provides a quick reference for all the functions available in PowerMart and PowerCenter.

For details on each function, see “Functions” on page 47.

����

Page 216: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Aggregate Functions

)XQFWLRQ 6\QWD[ 'HVFULSWLRQ

$9* $9*��QXPHULFBYDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�DYHUDJH�RI�DOO�YDOXHV�LQ�D�JURXS�

&2817 &2817��YDOXH�>��ILOWHUBFRQGLWLRQ�@��RU&2817�� �>��ILOWHUBFRQGLWLRQ�@��

5HWXUQV�WKH�QXPEHU�RI�UHFRUGV�ZLWK�QRQ�QXOO�YDOXH��LQ�D�JURXS�

),567 ),567��YDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�ILUVW�UHFRUG�LQ�D�JURXS�

/$67 /$67��YDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�ODVW�UHFRUG�LQ�D�JURXS�

0$; 0$;��YDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�PD[LPXP�YDOXH��RU�ODWHVW�GDWH��IRXQG�LQ�D�JURXS�

0(',$1 0(',$1��QXPHULFBYDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�PHGLDQ�RI�DOO�YDOXHV�LQ�D�VHOHFWHG�SRUW�

0,1 0,1��YDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�PLQLPXP�YDOXH��RU�HDUOLHVW�GDWH��IRXQG�LQ�D�JURXS�

3(5&(17,/( 3(5&(17,/(��QXPHULFBYDOXH��SHUFHQWLOH�>��ILOWHUBFRQGLWLRQ�@�� &DOFXODWHV�WKH�YDOXH�WKDW�IDOOV�DW�D�JLYHQ�SHUFHQWLOH�LQ�D�JURXS�RI�QXPEHUV�

67''(9 67''(9��QXPHULFBYDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�VWDQGDUG�GHYLDWLRQ�IRU�D�JURXS�

680 680��QXPHULFBYDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�VXP�RI�DOO�UHFRUGV�LQ�D�JURXS�

9$5,$1&( 9$5,$1&(��QXPHULFBYDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�YDULDQFH�RI�DOO�UHFRUGV�LQ�D�JURXS�

���� $SSHQGL[�$��)XQFWLRQ�4XLFN�5HIHUHQFH

Page 217: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Character Functions

)XQFWLRQ 6\QWD[ 'HVFULSWLRQ

$6&,, $6&,,���VWULQJ�� ,Q�$6&,,�PRGH��UHWXUQV�WKH�QXPHULF�$6&,,�YDOXH�RI�WKH�ILUVW�FKDUDFWHU�RI�WKH�VWULQJ�SDVVHG�WR�WKH�IXQFWLRQ�,Q�8QLFRGH�PRGH��UHWXUQV�WKH�QXPHULF�8QLFRGH�YDOXH�RI�WKH�ILUVW�FKDUDFWHU�RI�WKH�VWULQJ�SDVVHG�WR�WKH�IXQFWLRQ��7KLV�IXQFWLRQ�LV�LGHQWLFDO�LQ�EHKDYLRU�WR�WKH�&+5&2'(�IXQFWLRQ��,I�\RX�XVH�WKH�$6&,,�IXQFWLRQ�LQ�H[LVWLQJ�H[SUHVVLRQV��LW�ZLOO�VWLOO�ZRUN�FRUUHFWO\��KRZHYHU��,QIRUPDWLFD�UHFRPPHQGV�XVLQJ�WKH�&+5&2'(�IXQFWLRQ�LQVWHDG�RI�WKH�$6&,,�IXQFWLRQ�WR�FUHDWH�QHZ�H[SUHVVLRQV�

&+5 &+5��QXPHULFBYDOXH�� 5HWXUQV�WKH�$6&,,�RU�8QLFRGH�FKDUDFWHU�FRUUHVSRQGLQJ�WR�WKH�VSHFLILHG�QXPHULF�YDOXH�

&+5&2'( &+5&2'(���VWULQJ�� ,Q�$6&,,�PRGH��UHWXUQV�WKH�QXPHULF�$6&,,�YDOXH�RI�WKH�ILUVW�FKDUDFWHU�RI�WKH�VWULQJ�SDVVHG�WR�WKH�IXQFWLRQ�,Q�8QLFRGH�PRGH��UHWXUQV�WKH�QXPHULF�8QLFRGH�YDOXH�RI�WKH�ILUVW�FKDUDFWHU�RI�WKH�VWULQJ�SDVVHG�WR�WKH�IXQFWLRQ��7KLV�IXQFWLRQ�LV�LGHQWLFDO�LQ�EHKDYLRU�WR�WKH�$6&,,�IXQFWLRQ��

&21&$7 &21&$7��ILUVWBVWULQJ��VHFRQGBVWULQJ�� &RQFDWHQDWHV�WZR�VWULQJV��

,1,7&$3 ,1,7&$3��VWULQJ�� &DSLWDOL]HV�WKH�ILUVW�OHWWHU�LQ�HDFK�ZRUG�RI�D�VWULQJ�DQG�FRQYHUWV�DOO�RWKHU�OHWWHUV�WR�ORZHUFDVH��

,1675 ,1675��VWULQJ��VHDUFKBYDOXH�>��VWDUW�>��RFFXUUHQFH�@�@�� 5HWXUQV�WKH�SRVLWLRQ�RI�D�FKDUDFWHU�VHW�LQ�D�VWULQJ��FRXQWLQJ�IURP�OHIW�WR�ULJKW�

/(1*7+ /(1*7+��VWULQJ�� 5HWXUQV�WKH�QXPEHU�RI�FKDUDFWHUV�LQ�D�VWULQJ��LQFOXGLQJ�WUDLOLQJ�EODQNV��

/2:(5 /2:(5��VWULQJ�� &RQYHUWV�XSSHUFDVH�VWULQJ�FKDUDFWHUV�WR�ORZHUFDVH��

/3$' /3$'��ILUVWBVWULQJ��OHQJWK�>��VHFRQGBVWULQJ�@�� $GGV�D�VHW�RI�EODQNV�RU�FKDUDFWHUV�WR�WKH�EHJLQQLQJ�RI�D�VWULQJ��WR�VHW�D�VWULQJ�WR�D�VSHFLILHG�OHQJWK�

/75,0 /75,0��VWULQJ�>��WULPBVHW�@�� 5HPRYHV�EODQNV�RU�FKDUDFWHUV�IURP�WKH�EHJLQQLQJ�RI�D�VWULQJ��

53$' 53$'��ILUVWBVWULQJ��OHQJWK�>��VHFRQGBVWULQJ�@�� &RQYHUWV�D�VWULQJ�WR�D�VSHFLILHG�OHQJWK�E\�DGGLQJ�EODQNV�RU�FKDUDFWHUV�WR�WKH�HQG�RI�WKH�VWULQJ��

575,0 575,0��VWULQJ�>��WULPBVHW�@�� 5HPRYHV�EODQNV�RU�FKDUDFWHUV�IURP�WKH�HQG�RI�D�VWULQJ��

68%675 68%675��VWULQJ��VWDUW�>��OHQJWK�@�� 5HWXUQV�D�SRUWLRQ�RI�D�VWULQJ��

833(5 833(5��VWULQJ�� &RQYHUWV�ORZHUFDVH�VWULQJ�FKDUDFWHUV�WR�XSSHUFDVH��

&KDUDFWHU�)XQFWLRQV�� ���

Page 218: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Conversion Functions

)XQFWLRQ 6\QWD[ 'HVFULSWLRQ

72B&+$5 72B&+$5��QXPHULFBYDOXH��72B&+$5��GDWH�>��IRUPDW�@��

&RQYHUWV�QXPHULF�YDOXHV�DQG�GDWHV�WR�WH[W�VWULQJV�

72B'$7( 72B'$7(��VWULQJ�>��IRUPDW�@�� &RQYHUWV�D�FKDUDFWHU�VWULQJ�WR�D�GDWH�GDWDW\SH�LQ�WKH�VDPH�IRUPDW�DV�WKH�FKDUDFWHU�VWULQJ�

72B'(&,0$/ 72B'(&,0$/��YDOXH�>��VFDOH�@�� &RQYHUWV�DQ\�YDOXH��H[FHSW�ELQDU\��WR�D�GHFLPDO�

72B)/2$7 72B)/2$7��YDOXH�� &RQYHUWV�DQ\�YDOXH��H[FHSW�ELQDU\��WR�D�GRXEOH�SUHFLVLRQ�IORDWLQJ�SRLQW�QXPEHU��WKH�'RXEOH�GDWDW\SH���

72B,17(*(5 72B,17(*(5��YDOXH�� &RQYHUWV�DQ\�YDOXH��H[FHSW�ELQDU\��WR�DQ�LQWHJHU�E\�URXQGLQJ�WKH�GHFLPDO�SRUWLRQ�RI�D�YDOXH�

72B180%(5 72B180%(5��VWULQJ�� &RQYHUWV�D�VWULQJ�WR�D�GRXEOH�YDOXH�

���� $SSHQGL[�$��)XQFWLRQ�4XLFN�5HIHUHQFH

Page 219: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Date Functions

)XQFWLRQ 6\QWD[ 'HVFULSWLRQ

$''B72B'$7( $''B72B'$7(��GDWH��IRUPDW��DPRXQW�� $GGV�D�VSHFLILHG�DPRXQW�WR�RQH�SDUW�RI�D�GDWH�WLPH�YDOXH��DQG�UHWXUQV�D�GDWH�LQ�WKH�VDPH�IRUPDW�DV�WKH�VSHFLILHG�GDWH�1RWH��,I�\RX�GR�QRW�VSHFLI\�WKH�\HDU�DV�<<<<��WKH�,QIRUPDWLFD�6HUYHU�DVVXPHV�WKH�GDWH�LV�LQ�WKH�FXUUHQW�FHQWXU\��

'$7(B&203$5( '$7(B&203$5(��GDWH���GDWH��� 5HWXUQV�D�YDOXH�LQGLFDWLQJ�WKH�HDUOLHU�RI�WZR�GDWHV�

'$7(B',)) '$7(B',))��GDWH���GDWH���IRUPDW�� 5HWXUQV�WKH�OHQJWK�RI�WLPH�EHWZHHQ�WZR�GDWHV��PHDVXUHG�LQ�WKH�VSHFLILHG�LQFUHPHQW��\HDUV��PRQWKV��GD\V��KRXUV��PLQXWHV��RU�VHFRQGV���

*(7B'$7(B3$57 *(7B'$7(B3$57��GDWH��IRUPDW�� 5HWXUQV�WKH�VSHFLILHG�SDUW�RI�D�GDWH�DV�DQ�LQWHJHU�YDOXH��EDVHG�RQ�WKH�GHIDXOW�GDWH�IRUPDW�RI�00�''�<<<<�++���0,�66��

/$67B'$< /$67B'$<��GDWH�� 5HWXUQV�WKH�GDWH�RI�WKH�ODVW�GD\�RI�WKH�PRQWK�IRU�HDFK�GDWH�LQ�D�SRUW��

0$; 0$;��GDWH��ILOWHUBFRQGLWLRQ�� 5HWXUQV�WKH�ODWHVW�GDWH�IRXQG�LQ�D�JURXS�

0,1 0,1��GDWH��ILOWHUBFRQGLWLRQ�� 5HWXUQV�WKH�HDUOLHVW�GDWH�IRXQG�LQ�D�JURXS�

5281' 5281'��GDWH�>��IRUPDW�@�� 5RXQGV�RQH�SDUW�RI�D�GDWH��

6(7B'$7(B3$57 6(7B'$7(B3$57��GDWH��IRUPDW��YDOXH�� 6HWV�RQH�SDUW�RI�D�GDWH�WLPH�YDOXH�WR�D�VSHFLILHG�YDOXH��

7581& 7581&��GDWH�>��IRUPDW�@�� 7UXQFDWHV�GDWHV�WR�D�VSHFLILF�\HDU��PRQWK��GD\��KRXU��RU�PLQXWH��

'DWH�)XQFWLRQV�� ���

Page 220: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Numeric Functions

)XQFWLRQ 6\QWD[ 'HVFULSWLRQ

$%6 $%6��QXPHULFBYDOXH�� 5HWXUQV�WKH�DEVROXWH�YDOXH�RI�D�QXPHULF�YDOXH�

&(,/ &(,/��QXPHULFBYDOXH�� 5HWXUQV�WKH�VPDOOHVW�LQWHJHU�JUHDWHU�WKDQ�RU�HTXDO�WR�WKH�VSHFLILHG�QXPHULF�YDOXH�

&80( &80(��QXPHULFBYDOXH�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�D�UXQQLQJ�WRWDO�RI�DOO�QXPHULF�YDOXHV�

(;3 (;3��H[SRQHQW�� 5HWXUQV�H�UDLVHG�WR�WKH�VSHFLILHG�SRZHU��H[SRQHQW���ZKHUH�H ������������

)/225 )/225��QXPHULFBYDOXH�� 5HWXUQV�WKH�ODUJHVW�LQWHJHU�OHVV�WKDQ�RU�HTXDO�WR�WKH�VSHFLILHG�QXPHULF�YDOXH��

/1 /1��QXPHULFBYDOXH�� 5HWXUQV�WKH�QDWXUDO�ORJDULWKP�RI�D�QXPHULF�YDOXH�

/2* /2*��EDVH��H[SRQHQW�� 5HWXUQV�WKH�ORJDULWKP�RI�D�QXPHULF�YDOXH�

02' 02'��QXPHULFBYDOXH��GLYLVRU�� 5HWXUQV�WKH�UHPDLQGHU�RI�D�GLYLVLRQ�FDOFXODWLRQ��

029,1*$9* 029,1*$9*��QXPHULFBYDOXH��UHFRUGVHW�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�DYHUDJH��UHFRUG�E\�UHFRUG��RI�D�VSHFLILHG�VHW�RI�UHFRUGV��

029,1*680 029,1*680��QXPHULFBYDOXH��UHFRUGVHW�>��ILOWHUBFRQGLWLRQ�@�� 5HWXUQV�WKH�VXP��UHFRUG�E\�UHFRUG��RI�D�VSHFLILHG�VHW�RI�UHFRUGV��

32:(5 32:(5��EDVH��H[SRQHQW�� 5HWXUQV�D�YDOXH�UDLVHG�WR�WKH�VSHFLILHG�H[SRQHQW�

5281' 5281'��QXPHULFBYDOXH�>��SUHFLVLRQ�@�� 5RXQGV�QXPEHUV�WR�D�VSHFLILHG�GLJLW�

6,*1 6,*1��QXPHULFBYDOXH�� 1RWHV�ZKHWKHU�D�QXPHULF�YDOXH�LV�SRVLWLYH��QHJDWLYH��RU����

6457 6457��QXPHULFBYDOXH�� 5HWXUQV�WKH�VTXDUH�URRW�RI�D�SRVLWLYH�QXPHULF�YDOXH�

7581& 7581&��QXPHULFBYDOXH�>��SUHFLVLRQ�@� 7UXQFDWHV�QXPEHUV�WR�D�VSHFLILF�GLJLW�

���� $SSHQGL[�$��)XQFWLRQ�4XLFN�5HIHUHQFH

Page 221: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Scientific Functions

)XQFWLRQ 6\QWD[ 'HVFULSWLRQ

&26 &26��QXPHULFBYDOXH�� 5HWXUQV�WKH�FRVLQH�RI�D�QXPHULF�YDOXH��H[SUHVVHG�LQ�UDGLDQV��

&26+ &26+��QXPHULFBYDOXH�� 5HWXUQV�WKH�K\SHUEROLF�FRVLQH�RI�D�QXPHULF�YDOXH��H[SUHVVHG�LQ�UDGLDQV��

6,1 6,1��QXPHULFBYDOXH�� 5HWXUQV�WKH�VLQ�RI�D�QXPHULF�YDOXH��H[SUHVVHG�LQ�UDGLDQV��

6,1+ 6,1+��QXPHULFBYDOXH�� 5HWXUQV�WKH�K\SHUEROLF�VLQ�RI�D�QXPHULF�YDOXH��H[SUHVVHG�LQ�UDGLDQV��

7$1 7$1��QXPHULFBYDOXH�� 5HWXUQV�WKH�WDQJHQW�RI�D�QXPHULF�YDOXH��H[SUHVVHG�LQ�UDGLDQV��

7$1+ 7$1+��QXPHULFBYDOXH�� 5HWXUQV�WKH�K\SHUEROLF�WDQJHQW�RI�D�QXPHULF�YDOXH��H[SUHVVHG�LQ�UDGLDQV��

6FLHQWLILF�)XQFWLRQV�� ���

Page 222: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Special Functions

)XQFWLRQ 6\QWD[ 'HVFULSWLRQ

$%257 $%257��VWULQJ�� 6WRSV�WKH�VHVVLRQ�DQG�LVVXHV�D�VSHFLILHG�HUURU�PHVVDJH�

'(&2'( '(&2'(��YDOXH��ILUVWBVHDUFK��ILUVWBUHVXOW�>��VHFRQGBVHDUFK��VHFRQGBUHVXOW�@«>��GHIDXOW�@��

6HDUFKHV�D�SRUW�IRU�WKH�VSHFLILHG�YDOXH��

(5525 (5525��VWULQJ�� &DXVHV�WKH�,QIRUPDWLFD�6HUYHU�WR�VNLS�D�UHFRUG�DQG�LVVXH�WKH�VSHFLILHG�HUURU�PHVVDJH��

,,) ,,)��FRQGLWLRQ��YDOXH��>��YDOXH��@�� 5HWXUQV�RQH�RI�WZR�YDOXHV�\RX�VSHFLI\��EDVHG�RQ�WKH�UHVXOWV�RI�D�FRQGLWLRQ�

/22.83 /22.83��UHVXOW��VHDUFK���YDOXH��>��VHDUFK���YDOXH�@«�� 6HDUFKHV�IRU�D�YDOXH�LQ�D�ORRNXS�VRXUFH�FROXPQ�,QIRUPDWLFD�UHFRPPHQGV�XVLQJ�WKH�/RRNXS�WUDQVIRUPDWLRQ�

���� $SSHQGL[�$��)XQFWLRQ�4XLFN�5HIHUHQFH

Page 223: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Test Functions

)XQFWLRQ 6\QWD[ 'HVFULSWLRQ

,618// ,618//��YDOXH�� 5HWXUQV�ZKHWKHU�D�YDOXH�LV�18//�

,6B'$7( ,6B'$7(��YDOXH�� 5HWXUQV�ZKHWKHU�D�YDOXH�LV�D�YDOLG�GDWH�

,6B180%(5 ,6B180%(5��YDOXH�� 5HWXUQV�ZKHWKHU�D�VWULQJ�LV�D�YDOLG�QXPEHU�

,6B63$&(6 ,6B63$&(6��YDOXH�� 5HWXUQV�ZKHWKHU�D�YDOXH�FRQVLVWV�HQWLUHO\�RI�VSDFHV�

7HVW�)XQFWLRQV�� ���

Page 224: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

Variable Functions

)XQFWLRQ 6\QWD[ 'HVFULSWLRQ

6(7&28179$5,$%/( 6(7&28179$5,$%/(����9DULDEOH�� &RXQWV�WKH�URZV�HYDOXDWHG�E\�WKH�IXQFWLRQ�DQG�LQFUHPHQWV�WKH�FXUUHQW�YDOXH�RI�D�PDSSLQJ�EDVHG�RQ�WKH�FRXQW�

6(70$;9$5,$%/( 6(70$;9$5,$%/(����9DULDEOH��YDOXH�� 6HWV�WKH�FXUUHQW�YDOXH�RI�D�PDSSLQJ�YDULDEOH�WR�WKH�KLJKHU�RI�WZR�YDOXHV��WKH�FXUUHQW�YDOXH�RI�WKH�YDULDEOH�RU�WKH�YDOXH�VSHFLILHG��5HWXUQV�WKH�QHZ�FXUUHQW�YDOXH�

6(70,19$5,$%/( 6(70,19$5,$%/(����9DULDEOH��YDOXH�� 6HWV�WKH�FXUUHQW�YDOXH�RI�D�PDSSLQJ�YDULDEOH�WR�WKH�ORZHU�RI�WZR�YDOXHV��WKH�FXUUHQW�YDOXH�RI�WKH�YDULDEOH�RU�WKH�YDOXH�VSHFLILHG��5HWXUQV�WKH�QHZ�FXUUHQW�YDOXH�

6(79$5,$%/( 6(79$5,$%/(����9DULDEOH��YDOXH�� 6HWV�WKH�FXUUHQW�YDOXH�RI�D�PDSSLQJ�YDULDEOH�WR�D�YDOXH�\RX�VSHFLI\��5HWXUQV�WKH�VSHFLILHG�YDOXH�

���� $SSHQGL[�$��)XQFWLRQ�4XLFN�5HIHUHQFH

Page 225: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

� � � � �

AABORT function

description 55ABS function

description 57absolute values

obtaining 57ADD_TO_DATE function

description 58aggregate functions

AVG 62COUNT 71description 48FIRST 84LAST 104MAX (dates) 118MAX (numbers) 119MEDIAN 121MIN (dates) 123MIN (numbers) 125null values 15, 50PERCENTILE 133STDDEV 161SUM 166summary 194VARIANCE 190

ANDreserved word 8

arithmeticdate/time values 45

arithmetic operatorsdescription 19using to convert data 19

ASCIISee also Installation and Configuration GuideSee also Session and Server GuideCHR function 65converting ASCII values 65converting characters to ASCII values 61converting to Unicode values 66

ASCII functiondescription 61

averageaggregate functions for determining 62returning 129

AVG functiondescription 62

Ccalendars

date types supported 32capitalization

strings 93, 113, 189case

converting to uppercase 189

����

Page 226: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

CEIL functiondescription 64

character functionsASCII 61CHR 65CHRCODE 66CONCAT function 67description 50INITCAP 93INSTR 94LENGTH 108LOWER 113LPAD 114LTRIM 116RPAD 142RTRIM 144SUBSTR 163summary 195UPPER 189

character stringsconverting from dates 170converting to dates 176

charactersadding to strings 114, 142ASCII characters 61, 65capitalization 93, 113, 189counting 163removing from strings 116, 144returning number 108Unicode characters 61, 65, 66

CHR functiondescription 65inserting single quotes 5, 65

CHRCODE functiondescription 66

commentsadding to expressions 7

comparison operatorsdescription 22

CONCAT functiondescription 67inserting single quotes using 68

concatenatingstrings 21, 67

conditionsreturning results 89

constantsDD_INSERT 11DD_REJECT 12DD_UPDATE 13definition 2

FALSE 14NULL 15TRUE 16

conversion functionsdescription 51summary 196TO_CHAR (dates) 170TO_CHAR (numbers) 174TO_DATE 176TO_DECIMAL 180TO_FLOAT 181TO_INTEGER 182TO_NUMBER 183

convertingdate strings 33

COS functiondescription 69

COSH functiondescription 70

cosinecalculating 69calculating hyperbolic cosine 70

COUNT functiondescription 71

CUME functiondescription 74

Ddatatypes

Date/Time 32date functions

ADD_TO_DATE 58DATE_COMPARE 76DATE_DIFF 77GET_DATE_PART 87LAST_DAY 106MAX (dates) 118MIN (dates) 123ROUND 137SET_DATE_PART 148summary 197TRUNC (Dates) 184

date/time valuesadding 58

DATE_COMPARE functiondescription 76

DATE_DIFF functiondescription 77

dates

���� ,QGH[

Page 227: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

See also date functionsconverting to character strings 170default format 35flat files 35format strings 37functions 51Julian 32Modified Julian 32overview 32performing arithmetic 45relational databases 35rounding 137truncating 184year 2000 33

DD_DELETE constantreserved word 8update strategy example 10

DD_INSERT constantdescription 11reserved word 8update strategy example 11

DD_REJECT constantreserved word 8update strategy example 12

DD_UPDATE constantdescription 13reserved word 8update strategy example 13

decimal valuesconverting 180

DECODE functiondescription 80internationalization 3

default date formatdefined 35

division calculationreturning remainder 127

documentationconventions xvdescription xiionline xiv

double precision valuesconverting strings 183floating point numbers 181

Eempty string

testing for 108ERROR function

description 82EXP function

description 83exponent values

calculating 83returning 136

expressionsSee also Designer Guideadding comments 7conditional 14in transformations 2overview 2syntax 4using operators 18using SYSDATE 28

:EXT reference qualifierdescription 4reserved word 8

FFALSE constant

description 14reserved word 8

filter conditionsaggregate functions 50null values 15

Filter transformationSee also Designer Guideusing ISNULL function 97

FIRST functiondescription 84

flat filesdates 35

floating point numberSee double precision values

FLOOR functiondescription 86

formatfrom character string to date 176from date to character string 170

format stringsdates 37definition 32IS_DATE function 41Julian day 38, 42matching 42Modified Julian day 38, 42TO_CHAR function 38TO_DATE function 41

,QGH[�� ���

Page 228: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

functionsaggregate 48, 194character 50, 195conversion 51, 196date 51, 197definition 2internationalization 3numerical 52, 198scientific 52, 199special 53, 200test 53, 201variable 53

GGET_DATE_PART function

description 87Gregorian calendar

in date functions 32

Hhyperbolic cosine

function 70hyperbolic sine

function 159hyperbolic tangent

function 169

IIIF function

description 89internationalization 3

Informaticadocumentation xiiWebzine xvi

INITCAP functiondescription 93internationalization 3

INSTR functiondescription 94

integersconverting other values 182

internationalizationfunctions affected 3invalid expression 3sort order 3

IS_DATE function

description 98format strings 41

IS_NUMBER functiondescription 101

IS_SPACES functiondescription 103

ISNULL functiondescription 97

JJ format string

using with IS_DATE 43using with TO_CHAR 40using with TO_DATE 43

Julian datesin date functions 32

Julian dayformat string 38, 42

LLAST function

description 104LAST_DAY function

description 106LENGTH function

description 108empty string test 108

literalssingle quotes in 65, 68single quotes requirement 5

:LKP reference qualifierdescription 4reserved word 8

LN functiondescription 109

local variablesdefinition 2description 29

LOG functiondescription 110

logarithmreturning 109, 110

logical operatorsdescription 23

LOOKUP functiondescription 111

Lookup transformationSee also Designer Guide

���� ,QGH[

Page 229: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

instead of LOOKUP function 111LOWER function

description 113internationalization 3

LPAD functiondescription 114

LTRIM functiondescription 116

Mmapping parameters

See also Designer Guidedefinition 2

mapping variablesSee also Designer Guidedefinition 2

mappings See Designer GuideMAX (dates) function

description 118internationalization 3

MAX (numbers) functiondescription 119internationalization 3

MEDIAN functiondescription 121

millisecondstruncation 32

MIN (dates) functiondescription 123internationalization 3

MIN (numbers) functiondescription 125internationalization 3

minimum valuereturning 123

MOD functiondescription 127

Modified Julian dayformat string 38, 42

monthreturning last day 106

MOVINGAVG functiondescription 129

MOVINGSUM functiondescription 131

multiple searchesexample of TRUE constant 16

Nnegative values

SIGN 157nested expressions

operators 18nesting

stored procedure 26NOT

reserved word 8NULL constant

description 15reserved word 8

null valuesaggregate functions 15, 50checking for 97filter conditions 15ISNULL 97logical operators 23operators 15string operator 21

numbersrounding 140truncating 187

numeric functionsABS 57CEIL 64CUME 74EXP 83FLOOR 86LN 109LOG 110MOD 127MOVINGAVG 129MOVINGSUM 131POWER 136ROUND (numbers) 140SIGN 157SQRT 160summary 198TRUNC (numbers) 187

numeric valuesconverting to text strings 174returning absolute value 57returning cosine 69returning hyperbolic cosine of 70returning hyperbolic sine 159returning hyperbolic tangent 169returning logarithms 109, 110returning minimum 125returning sine 158

,QGH[�� ���

Page 230: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

returning square root 160returning standard deviation 161returning tangent 168SIGN 157

numerical functionsdescription 52

Ooperator precedence

expressions 18operators

arithmetic 19comparison operators 22definition 2logical operators 23null values 15string operators 21

ORreserved word 8

PPERCENTILE function

description 133ports

syntax 4positive values

SIGN 157POWER function

description 136PowerMart 3.5 functions

LOOKUP 111primary key constraint

null values 15PROC_RESULT variable

description 26example 26reserved word 8

Qquotation marks

inserting single using CHR function 5

Rreference qualifiers

:EXT 4:LKP 4:SD 5:SEQ 5:SP 5:TD 5

relational databasesdates 35

reserved wordslist 8

return valuesdefinition 2syntax 4

ROUND (dates) functiondescription 137

ROUND (numbers) functiondescription 140

roundingdates 137numbers 140

rowsavoiding spaces 103counting 71returning average 129returning first row 84returning last row 104returning sum 131running total 74skipping 82

RPAD functiondescription 142

RR format stringdescription 33difference between YY and RR 34using with IS_DATE 44using with TO_CHAR 40using with TO_DATE 44

RTRIM functiondescription 144

running totalreturning 74

Sscientific functions

COS function 69COSH 70description 52SIN 158SINH 159

���� ,QGH[

Page 231: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

summary 199TAN 168TANH 169

:SD reference qualifierdescription 5reserved word 8

:SEQ reference qualifierdescription 5reserved word 8

sessionsstopping 55

$$$SessStartTimedescription 27example using in date functions 27

SESSSTARTTIME variabledescription 28reserved word 8using in date functions 28, 45

SET_DATE_PART functiondescription 148

SETCOUNTVARIABLEfunction 146

SETMAXVARIABLEfunction 151

SETMINVARIABLEfunction 153

SETVARIABLEfunction 155

SIGN functiondescription 157

SIN functiondescription 158

sinereturning 158, 159

single quotes in string literalsCHR function 65using CHR and CONCAT functions 68

SINH functiondescription 159

skippingrows 82

sort orderinternationalization 3

:SP reference qualifierdescription 5reserved word 8

spacesavoiding in rows 103removing with DD_REJECT 12

special functionsABORT 55

DECODE 80description 53ERROR 82IIF 89LOOKUP 111summary 200

SPOUTPUTreserved word 8

SQRT functiondescription 160

square rootreturning 160

SSSSS format stringusing with IS_DATE 44using with TO_CHAR 40using with TO_DATE 44

standard deviationreturning 161

STDDEV functiondescription 161

stoppingsessions 55

stored procedurenesting 26

string conversiondates 33

string literalssingle quotes in 65, 68single quotes requirement 5

string operatorsdescription 21

stringsadding blanks 114adding characters 114capitalization 93, 113, 189character set 94concatenating 21, 67converting character strings to dates 176converting dates to characters 170converting length 142converting numeric values to text strings 174converting to double values 183number of characters 108removing blanks 116removing blanks and characters 144removing characters 116returning portion 163

SUBSTR functiondescription 163

sumreturning 131, 166

,QGH[�� ���

Page 232: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

SUM functiondescription 166

syntaxexpression 4general rules 6ports 4return values 4

SYSDATE variabledescription 28example 28reserved word 8

system variablesdescription 26

TTAN function

description 168tangent

returning 168, 169TANH function

description 169:TD reference qualifier

description 5reserved word 8

test functionsdescription 53IS_DATE 98IS_NUMBER 101IS_SPACES 103ISNULL 97summary 201

text stringsconverting numeric values 174

TO_CHAR (dates) functiondescription 170examples 39format strings 38

TO_CHAR (numbers) functiondescription 174

TO_DATE functiondescription 176examples 43format strings 41

TO_DECIMAL functiondescription 180

TO_FLOAT functiondescription 181

TO_INTEGER functiondescription 182

TO_NUMBER functiondescription 183

transformation expressionsnull constraints 15overview 2

transformation languagecompared to SQL 4operators 18overview 2reserved words 8

transformation language componentsoverview 2

transformations See Designer GuideTRUE constant

description 16reserved word 8

TRUNC (dates) functiondescription 184

TRUNC (numbers) functiondescription 187

truncatingdate/time values 32dates 184numbers 187

UUnicode

See also Installation and Configuration GuideSee also Session and Server Guideconverting characters to Unicode values 61converting to ASCII values 66converting Unicode values 65

update strategyDD_DELETE example 10DD_INSERT example 11DD_REJECT example 12DD_UPDATE example 13

UPPER functiondescription 189internationalization 3

Vvariable functions

description 53SETCOUNTVARIABLE 146SETMAXVARIABLE 151SETMINVARIABLE 153SETVARIABLE 155

���� ,QGH[

Page 233: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

with partitioned sessions 53variables

$$$SessStartTime 27local variables 29PROC_RESULT 26SESSSTARTTIME 28SYSDATE 28system variables 26

VARIANCE functiondescription 190

Wwebzine

Informatica URL xvi

Yyear 2000

dates 33YY format string

difference between RR and YY 34using with IS_DATE 44using with TO_CHAR 40using with TO_DATE 44

,QGH[�� ���

Page 234: Transformation Language Reference - drmdh.free.frdrmdh.free.fr/stad/cour_info/tlrinformatica/TLR.pdf · PowerMart and PowerCenter can simplify and accelerate the process of moving

���� ,QGH[


Recommended