pc 86 transformationlanguagereference[1] (1)

Upload: jason-berger

Post on 03-Jun-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    1/228

    InformaticaPowerCenter(Version 8.6)

    Transformation Language

    Reference

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    2/228

    Informatica PowerCenter Transformation Language Reference

    Version 8.6June 2008

    Copyright (c) 19982008 Informatica Corporation. All rights reserved.

    This software and documentation contain proprietary i nformation of Informatica Corporation and are provided under a license agreement containing restrictions on use and disclosure and are alsprotected 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. This Software may be protected by U.S. and/or international Patents and other Patents Pending.

    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 and as provided in DFARS 227.7202-1(a227.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 product or documentation is subject to change without notice. If you find any problems in this product or documentation, please report them to us in writing.

    Informatica, PowerCenter, PowerCenterRT, PowerCenter Connect, PowerCenter Data Analyzer, PowerExchange, PowerMart, Metadata Manager, Informatica Data Quality, Informatica Data ExpInformatica B2B Data Exchange and Informatica On Demand are trademarks or registered trademarks of Informatica Corporation in the United States and in jurisdictions throughout the world. other company and product names may be tr ade names or trademarks of their respective owners.

    Portions of this software and/or documentation are subject to copyright held by third parties, including wi thout limitation: Copyright DataDirect Technologies. All rights reserved. Copyright 2Adobe Systems Incorporated. All rights reserved. Copyright Sun Microsystems. All rights reserved. Copyright RSA Security Inc. All Rights Reserved. Copyright Ordinal Technology Corprights reserved. Copyright Platon Data Technology GmbH. All rights reserved. Copyright Melissa Data Corporation. All rights reserved. Copyright Aandacht c.v. All rights reserved. Copy1996-2007 ComponentSource. All rights reserved. Copyright Genivia, Inc. All rights reserved. Copyright 2007 Isomorphic Software. All rights reserved. Copyright Meta Integration TechnolInc. All rights reserved. Copyright Microsoft. All rights reserved. Copyright Oracle. All rights reserved. Copyright AKS-Labs. A ll rights reserved. Copyright Quovadx, Inc. All rights reseCopyright SAP. All rights reserved. Copyr ight 2003, 2007 Instantiations, Inc. All rights reserved. Copyright Intalio. All rights reserved.

    This product includes software developed by the Apache Software Foundation (http://www.apache.org/), software copyright 2004-2005 Open Symphony (all rights reserved) and other software whlicensed under the Apache License, Version 2.0 (the License). You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0. Unless required by applicable law or agreed

    writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License fospecific language governing permissions and limitations under the License.

    This product includes software which was developed by Mozilla (http://www.mozilla.org/), software copyright The JBoss Group, LLC, all rights r eserved; software copyright, Red Hat Middleware, Lall rights reserved; software copyright 1999-2006 by Bruno Lowagie and Paulo Soares and other software which is licensed under the GNU Lesser General Public License Agreement, which mafound at http://www.gnu.org/licenses/lgpl.html. The materials are provided free of charge by Informatica, as-is, without warranty of any kind, either express or implied, including but not limited timplied warranties of merchantability and fitness for a particular purpose.

    The product includes ACE(TM) and TAO(TM) software copyrighted by Douglas C. Schmidt and his research group at Washington University, University of California, Irvine, and VanderbiltUniversity, Copyright (c) 1993-2006, all rights reserved.

    This product includes software copyright (c) 2003-2007, Terence Parr. All rights reserved. Your right to use such materials is s et forth in the license which may be found at http://www.antlr.org/license.html. The materials are provided free of charge by Informatica, as-is, without warranty of any kind, either express or implied, including but not l imited to the implied warranties ofmerchantability and fitness for a particular purpose.

    This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit (copyright The OpenSSL Project. All Rights Reserved) and redistribution of this software is subjeterms available at http://www.openssl.org.

    This product includes Curl software which is Copyright 1996-2007, Daniel Stenberg, . All Rights Reserved. Permissions and limitations regarding this software are subject to teravailable at http://curl.haxx.se/docs/copyright.html. Permission to use, copy, modify, and distribute thi s software for any purpose with or without fee is hereby granted, provided that the above copynotice and this permission notice appear in all copies.

    The product includes software copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. Permissions and limitations regarding this software are subject to terms available at http://www.dom4license.html.

    The product includes software copyright (c) 2004-2007, The Dojo Foundation. All Rights Reserved. Permissions and limitations regarding this software are subject to terms available at http://svn.dojotoolkit.org/dojo/trunk/LICENSE.

    This product includes ICU software which is copyright (c) 1995-2003 International Business Machines Corporation and others. All rights reserved. Permissions and limitations regarding this s oftware subject to terms available at http://www-306.ibm.com/software/globalization/icu/license.jsp

    This product includes software copyright (C) 1996-2006 Per Bothner. All rights reserved. Your right to use such materials is set forth in the license which may be found at http://www.gnu.org/softkawa/Software-License.html.

    This product includes OSSP UUID software which i s Copyright (c) 2002 Ralf S . Engelschall, Copyright (c) 2002 The OSSP Project Copyright (c) 2002 Cable & Wireless Deutschland. Permissionlimitations regarding this software are subject to terms available at http://www.opensource.org/licenses/mit-license.php.

    This product includes software developed by Boost (http://www.boost.org/) or under the Boost s oftware license. Permissions and limitations r egarding this software are subject to terms available at h/www.boost.org/LICENSE_1_0.txt.

    This product includes software copyright 1997-2007 University of Cambridge. Permissions and limitations regarding this software are subject to terms available at http://www.pcre.org/license.t

    This product includes software copyright (c) 2007 The Eclipse Foundation. All Rights Reserved. Permissions and limitations regarding this software are subject to terms available at http://www.eclipse.org/org/documents/epl-v10.php.

    The product includes the zlib library copyright (c) 1995-2005 Jean-loup Gailly and Mark Adler.

    This product includes software licensed under the terms at http://www.tcl.tk/software/tcltk/license.html.

    This product includes software licensed under the terms at http://www.bosrup.com/web/overlib/?License.

    This product includes software licensed under the terms at http://www.stlport.org/doc/license.html.

    This product includes software licensed under the Academic Free License (http://www.opensource.org/licenses/afl-3.0.php). This product includes software copyright 2003-2006 Joe WaInes, 202007 XStream Committers. All rights reserved. Permissions and limitations regarding this software are subject to terms available at http://xstream.codehaus.org/license.html. This product includessoftware developed by the Indiana University Extreme! Lab. For further information please visit http ://www.extreme.indiana.edu/.

    This Software is p rotected by U.S. Patent Numbers 6,208,990; 6,044,374; 6,014,670; 6,032,158; 5,794,246; 6 ,339,775; 6,850,947; 6,895,471; 7,254,590 and other U.S. Patents Pending.

    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. Informatica Corporation does not warrant that this software or documentation is error free. The information provided in this softwadocumentation may include technical inaccuracies or typographical errors. The information in this software and documentation is subject to change at any time without notic e.

    Part Number: PC-TLR-86000-0001

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    3/228

    Table of Contents iii

    Table of Contents

    Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

    Informatica Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

    Informatica Customer Portal . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

    Informatica Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

    Informatica Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ixInformatica Knowledge Base . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix

    Informatica Global Customer Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x

    Chapter 1: The Transformation Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    Transformat ion Language Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    Internationalization and the Transformation Language . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    Expression Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    Expression Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

    Rules and Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4Adding Comments to Expres sions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5

    Chapter 2: Constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    DD_DELETE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    DD_INSERT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

    Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    DD_REJECT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8DD_UPDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    FALSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    NULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

    Work ing with Nul l Values in Boolean Expre ss ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    Work ing with Nul l Values in Comparison Expre ss ions . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    Null Values in Aggrega te Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    Null Values in Filter Condit ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

    Nulls with Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11TRUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

    Chapter 3: Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    Operator Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

    String Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    4/228

    iv Table of Contents

    Nulls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    Comparison Opera tors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15

    Logical Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    Nulls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16

    Chapter 4: Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

    Built-in Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17$PM @TableName, $PM@TableName . . . . . . . . . . . . . . . . 19

    $PMFolderName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    $PMIntegrationServiceName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    $PMMappingName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    $PMRepositoryServiceName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

    $PMRepositor yUserName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    $PMSessionName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    $PMSessionRunMode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    $PMWorkflowName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    $PMWorkflowRunId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    $PMWorkflowRunInstanceName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20

    $$$SessStartTime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    SESSSTARTTIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    SYSDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    WOR KFLOWSTARTT IME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    Transaction Control Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

    Local Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    Chapter 5: Dates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    Date/Time Datatype . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    Julian Day, Modified Julian Day, and the Gregorian Ca lendar . . . . . . . . . . . . . . . . . . . . . 26

    Dates in the Year 2000 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26

    Dates in Relational Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    Dates in Flat Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    Default Date Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    Date Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28

    TO_CHAR Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

    Examples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31

    TO_DATE and IS_DATE Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    Rules and Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    Understanding Dat e Arithmetic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34

    Chapter 6: Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    Function Categories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    Aggregate Funct ions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    5/228

    Table of Contents v

    Aggregate Funct ions and Nul ls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38

    Character Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39

    Conversion Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    Data Cleansing Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40

    Date Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    Encoding Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    Financial Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

    Numeric Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    Scientific Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    Special Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42

    String Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

    Test Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

    Variable Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

    ABORT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    ABS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44

    AD D_TO_DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

    AES_DECRYPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    AES_ENCRYPT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48

    ASCII . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49

    AVG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    CEIL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    CHOOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

    CHR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53

    CHRCODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54

    COMPRESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55

    CONCAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56

    CONVERT_BASE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57

    COS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58

    COSH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58COUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

    CRC32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61

    CUME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62

    DATE_COMPARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63

    DATE_DIFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64

    DEC_BASE64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66

    DECODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67

    DECOMPRESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69

    ENC_BASE64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70

    ERROR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70EXP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

    FIRST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72

    FLOOR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73

    FV. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74

    GET_DATE_PART . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75

    GREATEST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76

    IIF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    6/228

    vi Table of Contents

    IN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

    INDEXOF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80

    INITCAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81

    INSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

    ISNULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

    IS_DATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85

    IS_NUMBER. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87

    IS_SPACES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89

    LAST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

    LAST_DAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91

    LEAST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92

    LENGTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    LN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93

    LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

    LOOKUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95

    LOWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

    LPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97

    LTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99

    MAKE_DATE_TIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

    MAX (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101

    MAX (Numbers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102

    MAX (String) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103

    MD5 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

    MEDIAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105

    METAPHONE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106

    MIN (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109

    MIN (Numbers). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110

    MIN (String) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111

    MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112MOVINGAVG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113

    MOVINGSUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115

    NPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116

    PERCENTILE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117

    PMT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118

    POWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119

    PV. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120

    RAND . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

    RATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

    REG_EXTR ACT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122REG_MATCH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125

    REG_REPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 126

    REPLACECH R . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127

    REPLACESTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129

    REVERSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 131

    ROUND (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 132

    ROUND (Numbers). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    7/228

    Table of Contents vii

    RPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137

    RTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139

    SETCOUNTVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140

    SET_DATE_PART. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141

    SETMAXVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 144

    SETMINVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145

    SETVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147

    SIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148

    SIN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149

    SINH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150

    SOUNDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151

    SQRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152

    STDDEV. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153

    SUBSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

    SUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156

    SYSTIMESTAMP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

    TAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158

    TANH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159

    TO_BIGINT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 160

    TO_CHAR (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161

    TO_CHAR (Numbers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

    TO_DATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166

    TO_DECIMAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168

    TO_FLOAT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169

    TO_INTEGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 170

    TRUNC (Dates). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171

    TRUNC (Numbers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

    UPPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

    VARIANCE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

    Chapter 7: Creating Custom Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

    Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

    Steps to Create Custom Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179

    Installing Custom Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

    Step 1. Get Repository ID Attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180

    Step 2. Create a Header File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181

    Step 3. Create an Implementat ion File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182

    Step 4. Build the Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189

    Building the Module on Windows . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

    Building the Module on UNIX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190

    Step 5. Create the Repository P lug-in File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

    The PLUGIN Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

    The FUNCTION_GROUP Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191

    Determining a Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

    The FUNCTION Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192

    The LIBRARY Element . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    8/228

    v iii Table of Contents

    Sample Plug-in XML File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193

    Step 6. Test Custom Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

    Validating the Repos itory Plug-in File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194

    Verifying Function Accu racy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

    Installing Custom Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

    Step 1. Copy Custom Function Libraries to PowerCenter . . . . . . . . . . . . . . . . . . . . . . . 195

    Step 2. Register the Plug-in . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195

    Creating Expressions with Custom Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

    Chapter 8: Custom Function API Reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

    Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

    Common APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197

    Validation Handle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

    User Interface Validation Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198

    INFA_EXPR_OPD_M ETADATA Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

    Get Plug-in Version Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

    Run-time APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200

    Module-Level Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201

    Function-Level Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202

    Function Instance-Level Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203

    Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    9/228

    ix

    Preface

    The PowerCenter Transformation Language Referenceis written for the developers who are responsible forbuilding mappings. The PowerCenter Transformation Language Referenceassumes you have knowledge of SQL,relational database concepts, and the interface requirements for your supporting applications.

    Informatica Resources

    Informatica Customer Portal

    As an Informatica customer, you can acce ss the Informatica Customer Portal site athttp://my.informatica.com. The site contains product information, user group information, newsletters, accessto the Informatica customer support case management system (ATLAS), the Informatica Knowledge Base,Informatica Documentation Center, and access to the Informatica user community.

    Informatica Documentation

    The Informatica Documentation team takes every effort to create accurate, usable documentat ion. If you havequestions, comments, or ideas about this documentation, contact the Informatica Documentation teamthrough email at [email protected]. We will use your feedback to improve ourdocumentation. Let us know if we can contact you regarding your comments.

    Informatica Web Site

    You can access the Informatica corpora te web site at http://www.informatica.com. The site containsinformation about Informatica, its background, upcoming events, and sales offices. You will also find productand partner information. The services area of the site includes important information about technical support,training and education, and implementation services.

    Informatica Knowledge BaseAs an Informatica customer, you can access the Informatica Knowledge Base athttp://my.informatica.com. Use the Knowledge Base to search for documented so lutions to known technicalissues about Informatica products. You can also find answers to frequently asked questions, technical whitepapers, and technical tips.

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    10/228

    x Preface

    Informatica Global Customer Support

    There are many ways to access Informatica Global Customer Support. You can contact a Customer SupportCenter through telephone, email, or the WebSupport Service.

    Use the following email addresses to contact Informatica Global Customer Support:

    [email protected] for technical inquiries

    [email protected] for general customer service requests

    WebSupport requires a user name and password. You can request a user name and password at http://

    my.informatica.com.

    Use the following telephone numbers to contact Informatica Global Customer Support:

    North America / South America Europe / Middle East / Africa Asia / Australia

    Informatica Corporation

    Headquarters

    100 Cardinal Way

    Redwood City, California

    94063

    United States

    Toll F ree+1 877 463 2435

    Standard Rate

    Brazil: +55 11 3523 7761

    Mexico: +52 55 1168 9763

    United States: +1 650 385 5800

    Informatica Software Ltd.

    6 Waltham Park

    Waltham Road, White Waltham

    Maidenhead, Berkshire

    SL6 3TN

    United Kingdom

    Toll Free00 800 4632 4357

    Standard Rate

    Belgium: +32 15 281 702

    France: +33 1 41 38 92 26

    Germany: +49 1805 702 702

    Netherlands: +31 306 022 797

    United Kingdom: +44 1628 511 445

    Informatica Business

    Solutions Pvt. Ltd.

    Diamond District

    Tower B, 3rd Floor

    150 Airport Road

    Bangalore 560 008

    India

    Toll FreeAustr alia: 1 800 151 830

    Singapore: 001 800 4632 4357

    Standard Rate

    India: +91 80 4112 5738

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    11/228

    1

    C H A P T E R 1

    The Transformation Language

    This chapter includes the following topics:

    Overview, 1

    Expression Syntax, 2

    Adding Comments to Expre ssions, 4

    Reserved Words, 5

    Overview

    PowerCenter provides a transformation language that includes SQL-like functions to transform source data.Use these functions to write expressions and create functions called user-defined functions.

    User-defined functions reuse expression logic and build complex expressions. You can include them in otheruser-defined functions or in expressions. User-defined functions follow the same guidelines a s expressions. Theyuse the same syntax and can use the same transformation language components.

    Expressions modify data or test whether data matches conditions. For example, you might use the AVGfunction to calculate the average salary of all the employees, or the SUM function to calculate the total sales fora specific branch.

    You can create a simple expression that only conta ins a port, such as ORDERS, or a numer ic li tera l, such as 10.You can also write complex expressions that include functions nested within functions, or combine differentports using the transformation language operators. For more information about how transformation expressionsare evaluated, see Working with Transformations in the PowerCenter Transformation Guide.

    Transformation Language Components

    The transformation language includes the following components to create simple or complex transformationexpressions:

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

    Operators. Use transformation operators to create transformation expressions to perform mathematicalcomputations, 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 toreference values that remain constant throughout a session, such as a sta te sales tax rate. Create mappingvariables in mapplets or mappings to w rite expressions referencing values that change from session to session.For more information, see the PowerCenter Designer Guide.

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    12/228

    2 C hap ter 1: Th e Tr ans fo rm at io n L an gu ag e

    Workflow variables.Create workflow variables for use within a workflow to write expressions referencingvalues that change from workflow to workflow. For more information, see the PowerCenter WorkflowAdminist ration Guide.

    Built-in and local variables.Use built-in variables to write expressions that reference values that vary, such asthe 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.

    Internationalization and the Transformation LanguageTransformation language functions can handle character data in either ASCII o r Unicode data movement mode.Use Unicode mode to handle multibytecharacter data. The return va lues of the following functions andtransformations depend on the code page of the Integration Service and the data movement mode:

    INITCAP

    LOWER

    UPPER

    MIN (Date)

    MIN (Number)

    MIN (String)

    MAX (Date)

    MAX (Number)

    MAX (String)

    Any function that uses conditional statements to compare str ings, such as IIF and DECODE

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

    When you validate an invalid express ion in the Express ion Editor, a dialog box displays the express ion with anerror indicator, >>>>. This indicator appears to the left of and points to the part of the expression containingthe 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. TheLOWER function returns a string in lowercase based on the code page of the Integration Service.

    Expression Syntax

    Although the transformation language is based on standard SQL, there are di fference between the twolanguages. For example, SQL supports the keywords ALL and DISTINCT for aggregate functions, but thetransformation language does not. On the other hand, the transformation language supports an optional filtercondition for aggregate functions, while SQL does not.

    You can create an expression that is as simple as a port (such as ORDERS), a pre-de fined workf low var iable(such as $Start.Status), or a numeric literal (such as 10). You can also write complex expressions that includefunctions nested within functions, or combine different columns using the transformation language operators.

    Expression Components

    Expressions can consist of any combination of the following components:

    Ports (input, input/output, variable)

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    13/228

    Expression Syntax 3

    String literals, numeric literals

    Constants

    Functions

    Built-in and local variables

    Mapping parameters and mapping variables

    Pre-defined workflow variables

    User-defined workflow variables

    Operators Return values

    Ports and Return Values

    When you write an expres sion that include s a port or return value from an unconnected transformation, use thereference qualifiers in Table 1-1:

    String and Numeric Literals

    You can include numeric or string l iterals.

    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 s ingle quotation mark. For example, thefollowing string is not allowed:

    'Joan's car'

    Table 1-1. Reference Qualifiers in Transformation Language

    Reference

    QualifierDescription

    :EXT Requ ired when you w ri te an express ion that includes a re tu rn va lue f rom an Externa l

    Procedure transformation. The general syntax is::EXT.external_procedure_transformation(argument1, argument2, ...)

    :LKP Requ ired when you c reate an express ion that includes the return value from an

    unconnected Lookup transformation. The general syntax is::LKP.lookup_transformation(argument1, argument2, ...)

    The arguments are the local ports used in the lookup condition. The order must match the

    order of the ports in the transformation. The datatypes for the local ports must match the

    datatype of the Lookup ports used in the lookup condition.

    :SD Opt iona l (PowerMar t 3.5 exp ressions onl y) . Qua li fi es a source tab le po rt in an expression.

    The general syntax is:

    :SD.source_table.column_name

    :SEQ Requ ired when you c reate an express ion that includes a port in a Sequence Genera to r

    transformation. The general syntax is::SEQ.sequence_generator_transformation.CURRVAL

    :SP Requ ired when you wr ite an exp ress ion tha t includes the re tu rn value f rom an unconnectedStored Procedure transformation. The general syntax is::SP.stored_procedure_transformation( argument1, argument2, [,

    PROC_RESULT])

    The arguments must match the arguments in the unconnected Stored Procedure

    transformation.

    :TD R equi red wh en you refer enc e a ta rg et ta ble in a Powe rMar t 3.5 LO OK UP functi on. Thegeneral syntax is:LOOKUP(:TD.SALES.ITEM_NAME, :TD.SALES.ITEM_ID,

    10, :TD.SALES.PRICE, 15.99)

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    14/228

    4 C hap ter 1: Th e Tr ans fo rm at io n L an gu ag e

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

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

    Do not use single quotation marks with numeric literals. Just enter the number you want to include. Forexample:

    .05

    or

    $$Sales_Tax

    Rules and Guidelines

    Use the following rules and guidelines when you write expressions:

    You cannot include both single-level and nested aggregate functions in an Aggregator tr ansformation.

    If you need to create both single-level and nested funct ions, create separate Aggregator transformations.

    You cannot use strings in numeric express ions.

    For example, the expression 1 + '1'is not valid because you can only perform addition on numericdatatypes. You cannot add an integer and a string.

    You cannot use strings as numeric parameters.

    For example, the expression SUBSTR(TEXT_VAL, '1', 10)is not valid because the SUBSTR function

    requires an integer value, not a string, as the start position.

    You cannot mix datatypes when using comparison operators.

    For example, the expression 123.4 = '123.4'is not valid because it compares a decimal value with a string.

    You can pass a va lue from a port, li teral string or number, variable, Lookup transformation , Stored Proceduretransformation, External Procedure transformation, or the results of another expression.

    Use the ports t ab in the Expression Editor to enter a port name into an expression. If you rename a port in aconnected transformation, the Designer propagates the name change to expressions in the transformation.

    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 Integration Service ignore spaces.

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

    The Integration Service 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 usequotation marks for literal numbers. The Integration Service treats any string value enclosed in s inglequotation marks as a character string.

    When you pass a mapping paramete r or variable or a workf low variable to a function within an expression,do not use quotation marks to designate mapping parameters or variables or workflow variables.

    Do not use quotation marks to designate ports.

    You can nest multiple functions with in an expression (except aggregate functions, which allow only onenested aggregate function). The Integration Service evaluates the expression starting with the innermostfunction.

    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

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    15/228

    Reserved Words 5

    Two slashes, as in:

    // These are comments

    The Integration Service ignores all text on a line preceded by these two comment specifiers. For example, if youwant to concatenate two s trings, you can enter the following expression with comments in the middle of theexpression:

    -- 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 Integration Service 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 and Workflow Manager do not validate the expression, since the last line is not a validexpression.

    If you do not want to embed comments, you can add them by clicking Comment in the Expression Editor.

    Reserved Words

    Some keywords in the transformation language, such as constants, operators, and built-in variables, are reservedfor specific functions. These include:

    :EXT

    :INFA

    :LKP

    :MCR :SD

    :SEQ

    :SP

    :TD

    AND

    DD_DELETE

    DD_INSERT

    DD_REJECT

    DD_UPDATE

    FALSE

    NOT

    NULL

    OR

    PROC_RESULT

    SESSSTARTTIME

    SPOUTPUT

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    16/228

    6 C hap ter 1: Th e Tr ans fo rm at io n L an gu ag e

    SYSDATE

    TRUE

    WORKFLOWSTARTTIME

    The following words are reserved for workflow expressions:

    ABORTED

    DISABLED

    FAILED

    NOTSTARTED

    STARTED

    STOPPED

    SUCCEEDED

    Note:You cannot use a reser ved word to name a port or local variable. You can only use reserved words withintransformation and workflow expressions. Reserved words have predefined meanings in expressions.

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    17/228

    7

    C H A P T E R 2

    Constants

    This chapter includes the following topics:

    DD_DELETE, 7

    DD_INSERT, 7

    DD_REJECT, 8

    DD_UPDATE, 9 FALSE, 9

    NULL, 9

    TRUE, 11

    DD_DELETE

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

    Note: Use the DD_DELETE constant in the Update Strategy transformation on ly. Use DD_DELETE instead ofthe integer literal 2 to facilitate troubleshooting complex numeric expressions.

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

    Example

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

    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 )

    Note: The expression using constants is e asier to read than the expression using numeric literals.

    DD_INSERT

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

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    18/228

    8 Chapter 2: Constants

    Note: Use the DD_INSERT constant in the Update Strategy transformation only. Use DD_INSERT instead ofthe integer literal 0 to facilitate troubleshooting complex numeric expressions.

    When you run a workf low, select the data-driven update strategy to write records to a target based on thi s flag.

    Examples

    The following examples modify a mapping that calculates monthly sales by salesperson, so you can examine thesales of just one salesperson.

    The following update strategy expression flags an employees sales for insertion, and rejects everyth ing else: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 )

    Tip: 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 shipped in thelast two days and flag them for insertion. Using DATE_DIFF, the expression subtracts DATE_SHIPPED fromthe 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 theresult is greater than 2, the expression flags the records for rejection. If the result is 2 or less, it flags them forinsertion:

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

    DD_INSERT )

    DD_REJECT

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

    Note: Use the DD_REJECT constant in the Update Strategy transformation only. Use DD_REJECT instead ofthe integer literal 3 to facilitate troubleshooting complex numeric expressions.

    When you run a workflow, select the data-driven update strategy to reje ct records from a target based on thisflag.

    Use DD_REJECT to filter or validate data. If you flag a record as reject, the Integration Service skips the recordand writes it to the session reject file.

    Examples

    The following examples modify a mapping that calculates the sales for the current month, so it includes onlypositive values.

    This update strategy expression flags records less than 0 for reject and all others for inser t:

    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 charactercolumn in a target table. This expression flags records that consist ent irely of spaces for reject and flags all othersfor insert:

    IIF( IS_SPACES( CUST_NAMES ), DD_REJECT, DD_INSERT )

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    19/228

    DD_UPDATE 9

    DD_UPDATE

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

    Note: Use the DD_UPDATE constant in the Update Strategy transformation only. Use DD_UPDATE insteadof the integer literal 1 to facilitate troubleshooting complex numeric expressions.

    When you run a workf low, select the data-driven update strategy to write records to a target based on thi s flag.

    ExamplesThe following examples modify a mapping that calculates sales for the current month. The mapping loads salesfor one 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 Alexs sales for update (1) and flaggingall 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 lasttwo days and flag them for insertion. Using DATE_DIFF, the expression subtracts DATE_SHIPPED from thesystem date, returning the difference between the two dates. Because DATE_DIFF returns a Double value, theexpression uses TRUNC to truncate the difference. It then compares the result to the integer literal 2. If theresult is greater than 2, the expression flags the records for rejection. If the result is 2 or less, it flags the recordsfor update. Otherwise, it flags them for rejection:

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

    DD_UPDATE )

    FALSE

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

    Example

    The following example uses FALSE in a DECODE expression to r eturn values based on the results o f acomparison. 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.')

    NULL

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

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    20/228

    10 Chapter 2: Constants

    Although you can write expressions that return nulls , any column that has the NOT NULL or PRIMARY KEYconstraint will not accept nulls. Therefore, if the Integration Service tries to write a null value to a column withone of these constraints, the database will reject the row and the Integration Service will write it to the rejectfile. Be sure to consider nulls when you create transformations.

    Functions can handle nulls differently. If you pass a null value to a function, it might return 0 or NULL, or itmight ignore null values.

    RELATEDTOPICS:

    Functions on page 37

    Working with Null Values in Boolean Expressions

    Expressions that combine a null value with a Boolean expression produces results that are ANSI compliant. Forexample, the Integration Service produces the following results:

    NULL AND TRUE = NULL

    NULL AND FALSE = FALSE

    Working with Null Values in Comparison Expressions

    By default, when you use a null value in an expression containing a comparison operator, the Integration

    Service produces a null value. However, you can also configure the Integration Service to treat null values ashigh or low in comparison operations.

    Use the Treat Null In Comparison Operators As property to configure how the Integration Service handles nullvalues in comparison expressions. For more information, see the PowerCenter Administrator Guide.

    This Integration Service configuration property affects the behavior of the following comparison operators inexpressions:

    =, !=, ^=, , >, >=, 1 NULL TRUE FALSE

    NULL = NULL NULL TRUE TRUE

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    21/228

    TRUE 11

    returns 0). You use filter conditions with aggregate functions, and these functions CUME, MOVINGAVG, andMOVINGSUM.

    Nulls with Operators

    Any express ion that uses operators (except the str ing operator | |) and contains a null va lue a lways evaluates toNULL. For example, the following expression evaluates to NULL:

    8 * 10 - NULL

    To test for nulls, use the ISNULL function.

    TRUE

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

    Example

    The 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.')

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    22/228

    12 Chapter 2: Constants

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    23/228

    13

    C H A P T E R 3

    Operators

    This chapter includes the following topics:

    Operator Precedence, 13

    Arithmetic Operators, 14

    String Operators, 15

    Comparison Operators, 15 Logical Operators, 16

    Operator Precedence

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

    If you write an expression that includes multiple operators, the Integration Service evaluates the expression inthe following order:

    1. Arithmetic operators

    2. String operators

    3. Comparison operators

    4. Logical operators

    The Integration Service evaluates operators in the order they appear in the following table. It evaluatesoperators in an expression with equal precedence to all operators from left to right.

    Table 3-1lists the precedence for all transformation language operators:

    Table 3-1. Operators in the Transformation Language

    Operator Meaning( ) Parentheses.

    +, -, NOT Unary plus and minus and the logical NOT operator.

    *, /,% Multiplication, division, modulus.

    +, - Addition, subtraction.

    || Concatenate.

    = Less than, less than or equa l to, grea ter than , g reater than o r equal to .

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    24/228

    14 Chapter 3: Operators

    The transformation language also supports the use of operators within nested expressions. When expressionscontain parentheses, the Integration Service evaluates operations inside parentheses before operations outsideparentheses. 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:

    Arithmetic Operators

    Use arithmetic operators to perform mathematical calculations on numeric data.

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

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

    When you use arithmetic ope rators in an expression, a ll of the operands in the expression must be numeric. Forexample, the expression 1 + '1'is not valid because it adds an integer to a string. The expression1.23 + 4 / 2is valid because all of the operands a re numeric.

    Note: The transformation language provides built-in date functions that let you perform arithmetic on date/timevalues. For more information about built-in date functions, see Understanding Date Arithmetic on page 34.

    =, , !=, = Equal to, not equal to, not equal t o, not equal to.

    AND Logical AND operator, use d when specif ying conditi ons.

    OR Logical OR operator, used when specifying conditions.

    Equation Return Value

    8 + 5 - 2 * 8 -3

    8 + (5 - 2) * 8 32

    Table 3-2. Arithmetic Operators in the Transformation Language

    Operator Meaning

    +, - Unary plus and minus. Unary plus indicates a positive value. Unary minus indicates anegative value.

    *, /, % Multiplication, division, modulus. A modulus is the remainder after dividing two integers. For

    example, 13 % 2 = 1 because 13 divided by 2 equals 6 with a remainder of 1.

    +, - Addition, subtraction.The addition operator (+) does not concatenate strings. To concatenate strings, use the

    string operator ||. To perform arithmetic on date values, use the date functions.

    Table 3-1. Operators in the Transformation Language

    Operator Meaning

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    25/228

    String Operators 15

    String Operators

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

    The || operator includes leading and trailing blanks. Use the LTRIM and RTRIM functions to trim leading andtrailing blanks before concatenating two strings.

    Nulls

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

    Example

    The following example shows an expression that concatenates employee first names and employee last namesfrom two columns. This expression removes the spaces from the end of the first name and the beginning of thelast name, concatenates a space to the end of each first name, then concatenates the last name:

    LTRIM( RTRIM( EMP_FIRST ) || ' ' || LTRIM( EMP_LAST ))

    Note:You can al so use the CONCAT function to concatenate two string values. The || operator, however,produces the same results in less time.

    Comparison Operators

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

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

    Input Value Return Value

    'alpha' || 'betical' alphabetical

    'alpha' || 2 alpha2'alpha' || NULL alpha

    EMP_FIRST EMP_LAST RETURN VALUE

    ' Alfred' ' Rice ' Alfred Rice

    ' Bernice' ' Kersins' Bernice Kersins

    NULL ' Proud' Proud

    ' Curt' NULL Curt

    NULL NULL NULL

    Table 3-3. Comparison Operators in the Transformation Language

    Operator Meaning

    = Equal to.

    > Greater than.

    < Less than.

    >= Greater than or equal to.

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    26/228

    16 Chapter 3: Operators

    Use the greater than (>) and less than ( 123 is not valid because the expression compares a decimal with a string. Theexpressions 123.4 > 123 and a != b are valid because the operands are the same datatype.

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

    If a filter condition evaluates to NULL, the Integration Service returns NULL.

    Logical OperatorsUse logical operators to manipulate numeric data. Expressions that return a numeric value evaluate to TRUEfor values other than 0, FALSE for 0, and NULL for NULL.

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

    Nulls

    Expressions that combine a null value with a Boolean expression produce results that are ANSI compliant. Forexample, the Integration Service produces the following results:

    NULL AND TRUE = NULL

    NULL AND FALSE = FALSE

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    27/228

    17

    C H A P T E R 4

    Variables

    This chapter includes the following topics:

    Built-in Variables, 17

    Transaction Control Variables, 22

    Local Variables, 23

    Built-in Variables

    The transformation language provides built-in variables. Built-in variables return either run-time or systeminformation. Run-time variables return information such as source and target table name, folder name, sessionrun mode, and workflow run instance name. System variables return session start t ime, system date, andworkflow start t ime.

    You can use built-in variables in expre ssions in the Designe r or Workflow Manager. For example, you can usethe system variable SYSDATE in a DATE_DIFF function. You can use run-time variables in expressions and ininput fields that accept mapping or workflow variables. For example, you can use run-time variable$PMWorkflowRunInstanceName as part of a target output file name. The Integration Service sets the values ofbuilt-in variables. You cannot define values for built-in variables in a workflow or session parameter file.

    The following built-in variables provide run-time information:

    $PM@TableName, $PM@TableName

    $PMFolderName

    $PMIntegrationServiceName

    $PMMappingName

    $PMRepositoryServiceName

    $PMRepositoryUserName

    $PMSessionName $PMSessionRunMode

    $PMWorkflowName

    $PMWorkflowRunId

    $PMWorkflowRunInstanceName

    The following built-in variables provide system information:

    $$$SessStartTime

    SESSSTARTTIME

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    28/228

    1 8 Chapter 4: Variables

    SYSDATE

    WORKFLOWSTARTTIME

    Table 4-1describes where you use built-in variables in the Designer and Workflow Manager:

    Table 4-1. Where to Use Built-in Variables

    Variable Name Designer Workflow Manager

    $PM

    @TableName,

    $PM@TableName,

    - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept mapping

    variables

    $PMFolderName - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept workflow

    variables

    - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept workflow

    variables

    $PMIntegrationService

    Name

    - Expressions

    - Input fields that accept mapping

    variables- Input fields that accept workflow

    variables

    - Expressions

    - Input fields that accept mapping

    variables- Input fields that accept workflow

    variables

    $PMMappingName - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept mapping

    variables

    $PMRepositoryService

    Name

    - Expressions

    - Input fields that accept mappingvariables

    - Input fields that accept workflow

    variables

    - Expressions

    - Input fields that accept mappingvariables

    - Input fields that accept workflow

    variables

    $PMRepositoryUserName - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept workflow

    variables

    - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept workflow

    variables

    $PMSessionName - Expressions

    - Input fields that accept mappingvariables

    - Input fields that accept mapping

    variables

    $PMSessionRunMode - Expres sions

    - Input fields that accept mapping

    variables

    - Input fields that accept mapping

    variables

    $PMWorkflowName - Expressions

    - Input fields that accept mapping

    variables- Input fields that accept workflow

    variables

    - Expressions

    - Input fields that accept mapping

    variables- Input fields that accept workflow

    variables

    $PMWorkflowRunId - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept workflow

    variables

    - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept workflow

    variables

    $PMWorkflowRun

    InstanceName

    - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept workflow

    variables

    - Expressions

    - Input fields that accept mapping

    variables

    - Input fields that accept workflow

    variables

    $$$ Se ss Star tTim e - Ma pping or mappl et filte r c on diti ons

    - User-defined joins- SQL overrides

    - Mapping or mapplet filter conditions

    - User-defined joins- SQL overrides

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    29/228

    Built-in Variables 19

    $PM@TableName, $PM@TableName

    $PM@TableName and $PM@TableName return the source and target tablenames for relational source and target instances as string values. Use these variables with any function thataccepts string datatypes.

    The variable name depends on the source or target instance name. For example, for a source instance namedCustomers, the built-in variable name is $PMCustomers@TableName. If the relational source or t arget is partof a mapplet within a mapping, the built-in variable name includes the mapplet name:

    $PM.@TableName

    $PM.@TableName

    Use $PM@TableName and $PM@TableName in a mapping or a mapplet. Forexample, in a mapping that contains multiple relational sources, you can use $PM@TableName

    in the output port of an Expression transformation to write the source table name for each row to the target.You can also use these variables in input fields that accept mapping var iables.

    $PMFolderName

    $PMFolderName returns the name of the repository folder as a st ring value. Use $PMFolderName with anyfunction that accepts string datatypes.

    Use $PMFolderName in a mapping, a mapplet, workflow links, or in workflow tasks such a s Assignment andDecision tasks. You can also use $PMFolderName in input fields that accept mapping or workflow variables.

    $PMIntegrationServiceName

    $PMIntegrationServiceName returns the name of the Integration Service that runs the session. Use$PMIntegrationServiceName with any function that accepts st ring datatypes. $PMIntegrationServiceNamereturns the Integration Service name as a string value.

    Use $PMIntegrationServiceName in a mapping, a mapplet, workflow links, or in workflow tasks such asAssignment and Decision tasks. You can also use $PMIntegra tionServ iceName in input fields that acceptmapping or workflow variables.

    $PMMappingName

    $PMMappingName returns the mapping name as a string value. Use $PMMappingName with any functionthat accepts string datatypes.

    Use $PMMappingName in a mapping or a mapplet. You can also use $PMMappingName in input fields thataccept mapping variables.

    $PMRepositoryServiceName

    $PMRepositoryServiceName returns the name of the Repository Serv ice as a string value. Use$PMRepositoryServiceName with any function that accepts st ring datatypes.

    SESSSTARTTIME - Expressions n/a

    SYSDATE - Expressions - Expressions

    WORKFLOWSTARTTIME n/a - Expressions

    Table 4-1. Where to Use Built-in Variables

    Variable Name Designer Workflow Manager

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    30/228

    2 0 Chapter 4: Variables

    Use $PMRepositoryServiceName in a mapping, a mapplet, workflow links, or in workflow tasks su ch asAssignment and Decision tasks. You can also use $PMRepositoryServiceName in input fields that acceptmapping or workflow variables.

    $PMRepositoryUserName

    $PMRepositoryUserName returns the name of the repository user that runs the session. Use$PMRepositoryUserName with any function that accepts string datatypes. $PMRepositoryUserName returnsthe repository user name as a string value.

    Use $PMRepositoryUserName in a mapping, a mapplet, workflow links, or in workflow tasks such asAssignment and Decision ta sks. You can also use $PMRepositoryUserName in input fields that accept mappingor workflow variables.

    $PMSessionName

    $PMSessionName returns the session name as a string value. Use $PMSessionName with any function thataccepts string datatypes.

    Use $PMSessionName in a mapping or a mapplet. You can also use $PMSessionName in input fields thataccept mapping variables.

    $PMSessionRunMode$PMSessionRunMode returns the session run mode, normalor recovery, as a string value. Use$PMSessionRunMode with any function that accepts string datatypes.

    Use $PMSessionRunMode in a mapping or a mapplet. You can also use $PMSessionRunMode in input fieldsthat accept mapping variables.

    $PMWorkflowName

    $PMWorkflowName returns the name of the workflow as a string value. Use $PMWorkflowName with anyfunction that accepts string datatypes.

    Use $PMWorkflowName in a mapping, a mapplet, workflow links, or in workflow tasks such as Assignmentand Decision tasks. You can also use $PMWorkflowName in input fields that accept mapping or workflowvariables.

    $PMWorkflowRunId

    Each workflow run has a unique run ID. $PMWorkflowRunId returns the workflow run ID as a string value.Use $PMWorkflowRunId with any function that accepts string datatypes.

    Use $PMWorkflowRunId in a mapping, a mapplet, workflow links, or in workflow tasks such as Assignmentand Decision tasks. You can also use $PMWorkflowRunId in input fields that accept mapping or workflowvariables. For example, you configure a workflow to run concurrently with the s ame instance name, and youwant to track the status of each workf low run using a third-party application. Use $PMWorkflowRunId in a

    post-session shell command to pass the run ID to the application.

    $PMWorkflowRunInstanceName

    $PMWorkflowRunInstanceName returns the workflow run instance name as a string value. Use$PMWorkflowRunInstanceName with any function that accepts string datatypes.

    Use $PMWorkflowRunInstanceName in a mapping, a mapplet, workflow links, or in workflow tasks such asAssignment and Decision tasks. You can also us e $PMWorkf lowRunInstanceName in input fields that acceptmapping or workflow variables. For example, for a concurrent workflow with unique instance names, you can

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    31/228

    Built-in Variables 21

    create unique target files for each run instance by setting the target output file name in the session properties toOutFile_$PMWorkflowRunInstanceName.txt.

    Or, you want to use a post-session shell command to create an indicator file used by a predefined Event-Waittask. In the shell command that generates the indicator file, use $PMWorkflowRunInstanceName in theindicator file name to ensure that one workflow run instance does not delete an indicator file needed by anotherworkflow run instance.

    $$$SessStartTime

    $$$SessStartTime returns the initial system date value on the machine hosting the Integration Service when theserver initializes a session. $$$SessStartTime returns the session start time a s a string value. The format of thestring depends on the database you are using.

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

    Use $$$SessStartTime in a mapping or mapplet filter condition, user-defined join, or SQL override of a sourcequalifier. You can also use $$$SessStartTime in session-level overrides for mapping attributes. For moreinformation about using $$$SessStartTime in a mapping, see the PowerCenter Transformation Guide.

    Note: Changing any database environment variable such as NLS_LANG_FORMAT for Oracle or DBDATE forInformix does not affect the format string for datetime values the Integration Service uses in the SQL overridefor $$$SessStartTime.

    Example

    The following expression uses $$$SessStartTime in the source filter condition of a source qualifier to performan incremental extraction. The expression specifies a range of dates o f all days in the week prior to when theIntegration Service initializes the session. The expression uses the function DATEDIFF to find the difference inthe number of days between the value ORDER_DATE and $$$SessStartTime. If the difference between thetwo dates is less than or equal to seven days, the Integration Service extracts that row from the source:

    DATEDIFF(DAY, ORDER_DATE, '$$$SessStartTime')

  • 8/11/2019 PC 86 TransformationLanguageReference[1] (1)

    32/228

    2 2 Chapter 4: Variables

    Example

    The following expression uses SESSSTARTTIME to display the number of days an order has been open. Usingthe SQL function DATE_DIFF, the Integrat ion Service subtracts DATE_ENTERED from SESSSTARTTIMEand returns the result as a number of days:

    DATE_DIFF(SESSSTARTTIME, DATE_ENTERED, 'DD')

    SYSDATE

    SYSDATE returns the current date and time up to seconds on the machine that runs the session for each rowpassing through the trans formation. SYSDATE is stored as a transformation date/time datatype value.

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

    Example

    The following expression uses SYSDATE to find orders that have shipped in the last two days and flag them forinsertion. Using DATE_DIFF, the Integration Service subtracts DATE_SHIPPED from the system date,returning the difference between the two dates. Because DATE_DIFF returns a double value, the expressiontruncates the difference. It then compares the result to the integer literal 2. I f the result is greater than 2, theexpression flags the rows for rejection. If the result is 2 or less, it flags them for insert ion.

    IIF( TRUNC( DATE_DIFF( SYSDATE, DATE_SHIPPED, 'DD' ),

    0 ) > 2, DD_REJECT, DD_INSERT

    WORKFLOWSTARTTIME

    WORKFLOWSTARTTIME returns the current date and time on the mach ine hosting the Integra tion Servicewhen the Integration Service initial izes the workflow. Use WORKFLOWSTARTTIME with any function thataccepts t