PC - 861 - Transformation Language Reference Guide
PC - 861 - Transformation Language Reference Guide
Informatica PowerCenter Transformation Language Reference Version 8.6.1 December 2008 Copyright (c) 1998 2008 Informatica Corporation. All rights reserved. This software and documentation contain proprietary information of Informatica C orporation and are provided under a license agreement containing restrictions on use and disclosure and are also protected by copyright law. Reverse engineering of the software is prohibited. N o part of this document may be reproduced or transmitted in any form, by any mea ns (electronic, photocopying, recording or otherwise) without prior consent of Informatica Corporation. This S oftware 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 subjec t to the restrictions set forth in the applicable software license agreement and 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) (19 95), 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 no tice. If you find any problems in this product or documentation, please report t hem to us in writing. Informatica, PowerCenter, PowerCenterRT, PowerCenter Connect, PowerCenter Data A nalyzer, PowerExchange, PowerMart, Metadata Manager, Informatica Data Quality, I nformatica Data Explorer, Informatica B2B Data Exchange and Informatica On Demand are trademarks or regist ered trademarks of Informatica Corporation in the United States and in jurisdict ions throughout the world. All other company and product names may be trade names or trademarks of their respec tive owners. Portions of this software and/or documentation are subject to copyright held by third parties, including without limitation: Copyright DataDirect Technologies. All rights reserved. Copyright 2007 Adobe Systems Incorporated. All rights reserved. Copyright Sun Microsystems. All rights reserved. Copyright RSA Security Inc. All Rights Reserved. Copyright Ord inal Technology Corp. All rights reserved. Copyright Platon Data Technology GmbH. All rights reserved. Cop yright Melissa Data Corporation. All rights reserved. Copyright Aandacht c.v. Al l rights reserved. Copyright 1996-2007 ComponentSource. All rights reserved. Copyright Genivia, Inc. All right s reserved. Copyright 2007 Isomorphic Software. All rights reserved. Copyright M eta Integration Technology, Inc. All rights reserved. Copyright Microsoft. All rights reserved. Copyright Or acle. All rights reserved. Copyright AKS-Labs. All rights reserved. Copyright Qu ovadx, Inc. All rights reserved. Copyright SAP. All rights reserved. Copyright 2003, 2007 Instantiations, Inc. Al l rights reserved. Copyright Intalio. All rights reserved. This product includes software developed by the Apache Software ://www.apache.org/), software copyright 2004-2005 Open Symphony rved) and other software which is licensed under the Apache License, Version 2.0 (the License ). y of the License at http://www.apache.org/licenses/LICENSE-2.0. Foundation (http (all rights rese You may obtain a cop Unless required
by applicable law or agreed to in 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 for the specific language governing permissions and limitations under the License. This product includes software which was developed by Mozilla (http://www.mozill a.org/), software copyright The JBoss Group, LLC, all rights reserved; software copyright, Red Hat Middleware, LLC, all rights reserved; software copyright 1999-2006 by Bruno Lowagie and Paulo Soa res and other software which is licensed under the GNU Lesser General Public Lic ense Agreement, which may be found 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 i mplied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. The product includes ACE(TM) and TAO(TM) software copyrighted by Douglas C. Schm idt and his research group at Washington University, University of California, I rvine, and Vanderbilt University, 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 set forth in the license which ma y be found at http://www.antlr.org/ license.html. The materials are provided free of charge by Informatica, as-is , wit hout warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and fitness for a particular purpose. This product includes software developed by the OpenSSL Project for use in the O penSSL Toolkit (copyright The OpenSSL Project. All Rights Reserved) and redistri bution of this software is subject to terms available at http://www.openssl.org. This product includes Curl software which is Copyright 1996-2007, Daniel Stenber g, <[email protected]>. All Rights Reserved. Permissions and limitations regarding this software are subject to terms available at http://curl.haxx.se/docs/copyright.html. Permission to use, copy, m odify, and distribute this software for any purpose with or without fee is hereb y granted, provided that the above copyright notice 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 te rms available at http://www.dom4j.org/ license.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 Internationa l Business Machines Corporation and others. All rights reserved. Permissions and limitations regarding this software are 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 r
eserved. Your right to use such materials is set forth in the license which may be found at http://www.gnu.org/software/ kawa/Software-License.html. This product includes OSSP UUID software which is Copyright (c) 2002 Ralf S. Eng elschall, Copyright (c) 2002 The OSSP Project Copyright (c) 2002 Cable & Wireles s Deutschland. Permissions and limitations 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 und er the Boost software license. Permissions and limitations regarding this softwa re are subject to terms available at http:/ /www.boost.org/LICENSE_1_0.txt. This product includes software copyright 1997-2007 University of Cambridge. Perm issions and limitations regarding this software are subject to terms available a t http://www.pcre.org/license.txt. This product includes software copyright (c) 2007 The Eclipse Foundation. All Ri ghts Reserved. Permissions and limitations regarding this software are subject t o 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 a nd Mark Adler. This product includes software licensed under the terms at http://www.tcl.tk/sof tware/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.or g/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 copyrig ht 2003-2006 Joe WaInes, 20062007 XStream Committers. All rights reserved. Permissions and limitations regard ing this software are subject to terms available at http://xstream.codehaus.org/ license.html. This product includes software developed by the Indiana University Extreme! Lab. For further informati on please visit http://www.extreme.indiana.edu/. This Software is protected by U.S. Patent Numbers 6,208,990; 6,044,374; 6,014,67 0; 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 warr anty of any kind, either express or implied, including, but not limited to, the implied warranties of noninfringement, merchantability, or use for a particular purpose. Informatica Corp oration does not warrant that this software or documentation is error free. The information provided in this software or documentation may include technical inaccuracies or typographical errors. The in formation in this software and documentation is subject to change at any time wi thout notice. Part Number: PC-TLR-86100-0001
Table of Contents Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ix Informatica Resources. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ix Informatica Customer Portal. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ix Informatica Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ix Informatica Web Site . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ix Informatica How-To Library. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ix Informatica Knowledge Base. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Informatica Global Customer Support. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . x Chapter 1: The Transformation Language . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Transformation Language Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 Internationalization and the Transformation Language. . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Expression Syntax. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Expression Components. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 Rules and Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Adding Comments to Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Reserved Words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 Chapter 2: Constants. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7 DD_DELETE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 DD_INSERT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 DD_REJECT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 DD_UPDATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 FALSE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 NULL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 Working with Null Values in Boolean Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Working with Null Values in Comparison Expressions . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Null Values in Aggregate Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Null Values in Filter Conditions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 Nulls with Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 TRUE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 Chapter 3: Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13 Operator Precedence. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 Arithmetic Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Nulls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Comparison Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 Logical Operators. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Nulls. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Chapter 4: Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .17 Built-in Variables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 $PM<SourceName>@TableName, $PM<TargetName>@TableName . . . . . . . . . . . . . . . . 19 $PMFolderName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 $PMIntegrationServiceName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 $PMMappingName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 $PMRepositoryServiceName. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 $PMRepositoryUserName. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 $PMSessionName. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 $PMSessionRunMode. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 $PMWorkflowName. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 $PMWorkflowRunId . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 $PMWorkflowRunInstanceName . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 $$$SessStartTime. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
SESSSTARTTIME. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21 SYSDATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 WORKFLOWSTARTTIME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 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 Calendar. . . . . . . . . . . . . . . . . . . . . 26 Dates in the Year 2000. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 Dates in Relational Databases. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Dates in Flat Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Default Date Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Date Format Strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 TO_CHAR Format Strings. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Examples. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 30 TO_DATE and IS_DATE Format Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Rules and Guidelines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Understanding Date Arithmetic. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 34
Aggregate Functions and Nulls . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36 Character Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37 Conversion Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Data Cleansing Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Date Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Encoding Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Financial Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Numeric Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Scientific Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Special Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 String Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Test Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Variable Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 ABORT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 ABS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 ADD_TO_DATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 AES_DECRYPT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 AES_ENCRYPT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46 ASCII . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
AVG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48 CEIL. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 CHOOSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50 CHR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 CHRCODE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52 COMPRESS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53 CONCAT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 CONVERT_BASE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 COS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 COSH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 COUNT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 CRC32 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 CUME . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60 DATE_COMPARE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61 DATE_DIFF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 DEC_BASE64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 DECODE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65 DECOMPRESS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 ENC_BASE64 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68 ERROR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
IN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 INDEXOF. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78 INITCAP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79 INSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 ISNULL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82 IS_DATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 IS_NUMBER. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 85 IS_SPACES . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 LAST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88 LAST_DAY . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 LEAST . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 LENGTH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 LN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 LOG . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 LOOKUP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 LOWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 LPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 LTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 MAKE_DATE_TIME. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98
MAX (Dates). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99 MAX (Numbers) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 MAX (String). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 MD5. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102 MEDIAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 METAPHONE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104 MIN (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 107 MIN (Numbers). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 MIN (String). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 MOD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 MOVINGAVG. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 MOVINGSUM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 NPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114 PERCENTILE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115 PMT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 116 POWER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 117 PV. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 118 RAND. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 RATE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 119 REG_EXTRACT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
REG_MATCH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 123 REG_REPLACE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124 REPLACECHR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 125 REPLACESTR. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127 REVERSE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 ROUND (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
RPAD . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 RTRIM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137 SETCOUNTVARIABLE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 SET_DATE_PART. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 SETMAXVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 SETMINVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143 SETVARIABLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 SIGN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146 SIN. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 147 SINH . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 SOUNDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 SQRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 150 STDDEV. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 151 SUBSTR . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152 SUM. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 SYSTIMESTAMP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 TAN . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 TANH. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 TO_BIGINT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
TO_CHAR (Dates) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159 TO_CHAR (Numbers). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 TO_DATE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164 TO_DECIMAL . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 TO_FLOAT. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 TO_INTEGER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 TRUNC (Dates). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 TRUNC (Numbers). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171 UPPER . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 VARIANCE. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173 Chapter 7: Creating Custom Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Steps to Create Custom Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177 Installing Custom Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Step 1. Get Repository ID Attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 Step 2. Create a Header File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Step 3. Create an Implementation File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180 Step 4. Build the Modules. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 Building the Module on Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Building the Module on UNIX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188
Step 5. Create the Repository Plug-in File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 The PLUGIN Element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 The FUNCTION_GROUP Element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 189 Determining a Namespace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190 The FUNCTION Element. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 190
Sample Plug-in XML File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 Step 6. Test Custom Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191 Validating the Repository Plug-in File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Verifying Function Accuracy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 192 Installing Custom Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 Step 1. Copy Custom Function Libraries to PowerCenter. . . . . . . . . . . . . . . . . . . . . . . 193 Step 2. Register the Plug-in. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 Creating Expressions with Custom Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 Chapter 8: Custom Function API Reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .195 Overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Common APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 Validation Handle . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 User Interface Validation Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 INFA_EXPR_OPD_METADATA Structure. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Get Plug-in Version Function. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197 Run-time APIs. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Module-Level Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 Function-Level Functions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 200 Function Instance-Level Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .205
Preface The PowerCenter Transformation Language Reference is written for the developers who are responsible for building mappings. The PowerCenter Transformation Language Reference assumes 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 access the Informatica Customer Portal site at http://my.informatica.com. The site contains product information, user group information, newsletters, acce ss to the Informatica customer support case management system (ATLAS), the Informatica How-To Library, the Info rmatica 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 documentation. If you have questions, comments, or ideas about this documentation, contact the Informatica Documentation team through email at [email protected]. We will use your feedback t o improve our documentation. Let us know if we can contact you regarding your comments.
Informatica Web Site You can access the Informatica corporate web site at http://www.informatica.com. The site contains information about Informatica, its background, upcoming events, and sales office s. You will also find product and partner information. The services area of the site includes important inform ation about technical support, training and education, and implementation services.
Informatica How-To Library As an Informatica customer, you can access the Informatica How-To Library at htt p://my.informatica.com. The How-To Library is a collection of resources to help you learn more about Inf ormatica products and features. It includes articles and interactive demonstrations that provide solut ions to common problems, compare features and behaviors, and guide you through performing specific real-w orld tasks.
Informatica Knowledge Base As an Informatica customer, you can access the Informatica Knowledge Base at htt p://my.informatica.com. Use the Knowledge Base to search for documented solutions to known technical issues about Informatica products. You can also find answers to frequently asked questions, technical white papers, and technical tips.
Informatica Global Customer Support There are many ways to access Informatica Global Customer Support. You can conta ct a Customer Support Center 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 pa ssword at http:// my.informatica.com. Use the following telephone numbers to contact Informatica Global Customer Suppo rt: North America / South America Europe / Middle East / Africa Asia / Australia Informatica Corporation Headquarters 100 Cardinal Way Redwood City, California 94063 United States Toll Free +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 Free 00 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 Spain and Portugal: +34 93 480 3760 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 Free Australia: 1 800 151 830 Singapore: 001 800 4632 4357 Standard Rate India: +91 80 4112 5738
CHAPTER 1 The Transformation Language This chapter includes the following topics: .Overview, 1 .Expression Syntax, 2 .Adding Comments to Expressions, 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-define d functions. User-defined functions reuse expression logic and build complex expressions. You can include them in other user-defined functions or in expressions. User-defined functions follow the same guidelines as expressions. They use the same syntax and can use the same transformation language components. Expressions modify data or test whether data matches conditions. For example, yo u might use the AVG function to calculate the average salary of all the employees, or the SUM functi on to calculate the total sales for a specific branch. You can create a simple expression that only contains a port, such as ORDERS, or a numeric literal, such as 10. You can also write complex expressions that include functions nested within func tions, or combine different ports using the transformation language operators. For more information about ho w transformation expressions are evaluated, see Working with Transformations in the PowerCenter Transformation Guide. Transformation Language Components The transformation language includes the following components to create simple o r complex transformation expressions: .Functions. Over 100 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, suc h as TRUE. .Mapping parameters and variables. Create mapping parameters for use within a ma pping or mapplet to reference values that remain constant throughout a session, such as a state sale s tax rate. Create mapping
variables in mapplets or mappings to write expressions referencing values that c hange from session to session. For more information, see the PowerCenter Designer Guide.
.Workflow variables. Create workflow variables for use within a workflow to writ e expressions referencing values that change from workflow to workflow. For more information, see the Powe rCenter Advanced Workflow Guide. .Built-in and local variables. Use built-in variables to write expressions that reference values 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 fr om Lookup, Stored Procedure, and External Procedure transformations.
Internationalization and the Transformation Language Transformation language functions can handle character data in either ASCII or U nicode data movement mode. Use Unicode mode to handle multibyte character data. The return values of the fo llowing functions and transformations 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 strings, such as IIF a nd DECODE
MIN and MAX also return values based on the sort order associated with the Integ ration Service code page. When you validate an invalid expression in the Expression Editor, a dialog box d isplays the expression with an error indicator, >>>> . This indicator appears to the left of and points to the par t of the expression containing the error. For example, if the expression a = b + c contains an error at c, the error message displays: Transformation language functions that evaluate character data are character-ori
ented, not byte-oriented. For example, the LENGTH function returns the number of characters in a string, not t he number of bytes. The LOWER function returns a string in lowercase based on the code page of the Integ ration Service.
Expression Syntax Although the transformation language is based on standard SQL, there are differe nce between the two languages. For example, SQL supports the keywords 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), a pre -defined workflow variable (such as $Start.Status), or a numeric literal (such as 10). You can also write c omplex expressions that include functions nested within functions, or combine different columns using the transf ormation language operators. Expression Components Expressions can consist of any combination of the following components: .Ports (input, input/output, variable)
.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 expression that includes a port or return value from an unconn ected transformation, use the reference qualifiers in the following table: Reference Qualifier Description :EXT Required when you write an expression that includes a return value from an Exter nal Procedure transformation. The general syntax is: :EXT.external_procedure_transformation(argument1, argument2, ...) :LKP Required when you create an expression 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 m atch 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 Optional (PowerMart 3.5 expressions only). Qualifies a source table port in an e xpression. The general syntax is:
:SD.source_table.column_name :SEQ Required when you create an expression that includes a port in a Sequence Genera tor transformation. The general syntax is: :SEQ.sequence_generator_transformation.CURRVAL :SP Required when you write an expression that includes the return value from an unc onnected Stored 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 Required when you reference a target table in a PowerMart 3.5 LOOKUP function. T he general syntax is: LOOKUP(:TD.SALES.ITEM_NAME, :TD.SALES.ITEM_ID, 10, :TD.SALES.PRICE, 15.99)
String and Numeric Literals You can include numeric or string literals. Be sure to enclose string literals within single quotation marks. For example: String literals are case sensitive and can contain any character except a single quotation mark. For example, the following string is not allowed:
To return a string containing a single quote, use the CHR function: Do not use single quotation marks with numeric literals. Just enter the number y ou want to include. For example: or
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 Aggre gator transformation. .If you need to create both single-level and nested functions, create separate A ggregator transformations. .You cannot use strings in numeric expressions. For example, the expression 1 + '1' is not valid because you can only perform ad dition on numeric datatypes. 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 S UBSTR 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 d ecimal value with a string. .You can pass a value from a port, literal string or number, variable, Lookup tr ansformation, Stored Procedure transformation, External Procedure transformation, or the results of another exp ression. .Use the ports tab in the Expression Editor to enter a port name into an express ion. If you rename a port in a connected 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 use d 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 singl e quotation marks. Do not use
quotation marks for literal numbers. The Integration Service treats any string v alue enclosed in single quotation marks as a character string. .When you pass a mapping parameter or variable or a workflow variable to a funct ion within an expression, do not use quotation marks to designate mapping parameters or variables or workf low variables. .Do not use quotation marks to designate ports. .You can nest multiple functions within an expression (except aggregate function s, which allow only one nested aggregate function). The Integration Service evaluates the expression sta rting with the innermost function.
Adding Comments to Expressions The transformation language provides two comment specifiers to let you insert co mments in expressions: .Two dashes, as in:
The Integration Service 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 com ments 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
The Integration Service ignores the comments and evaluates the expression as fol lows: 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
In this case, the Designer and Workflow Manager do not validate the expression, since the last line is not a valid expression. If you do not want to embed comments, you can add them by clicking Comment in th e Expression Editor.
Reserved Words Some keywords in the transformation language, such as constants, operators, and built-in variables, are reserved for 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
The following words are reserved for workflow expressions: .ABORTED .DISABLED .FAILED .NOTSTARTED .STARTED .STOPPED .SUCCEEDED Note: You cannot use a reserved word to name a port or local variable. You can o nly use reserved words within transformation and workflow expressions. Reserved words have predefined meanings in expressions.
CHAPTER 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 equiva lent to the integer literal 2. Note: Use the DD_DELETE constant in the Update Strategy transformation only. Use DD_DELETE instead of the integer literal 2 to facilitate troubleshooting complex numeric expressions.
When you run a workflow, select the data-driven update strategy to delete record s from a target based on this flag. Example The following expression marks items with an ID number of 1001 for deletion, and all other items for insertion: This update strategy expression uses numeric literals to produce the same result : Note: The expression using constants is easier to read than the expression using numeric literals.
DD_INSERT Flags records for insertion in an update strategy expression. DD_INSERT is equiv alent to the integer literal 0.
Note: Use the DD_INSERT constant in the Update Strategy transformation only. Use DD_INSERT instead of the integer literal 0 to facilitate troubleshooting complex numeric expressions.
When you run a workflow, select the data-driven update strategy to write records to a target based on this flag. Examples The following examples modify a mapping that calculates monthly sales by salespe rson, so you can examine the sales of just one salesperson. The following update strategy expression flags an employee s sales for insertion, and rejects everything else: This update strategy expression uses numeric literals to produce the same result : 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 o rders that shipped in the last two days and flag them for insertion. Using DATE_DIFF, the expression subtr acts DATE_SHIPPED from the system date, returning the difference between the two dates. Because DATE_DI FF returns a Double value, the expression uses TRUNC to truncate the difference. It then compares the resul t 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:
DD_REJECT Flags records for rejection in an update strategy expression. DD_REJECT is equiv alent to the integer literal 3. Note: Use the DD_REJECT constant in the Update Strategy transformation only. Use DD_REJECT instead of the integer literal 3 to facilitate troubleshooting complex numeric expressions.
When you run a workflow, select the data-driven update strategy to reject record s from a target based on this flag. Use DD_REJECT to filter or validate data. If you flag a record as reject, the In tegration Service skips the record and writes it to the session reject file. Examples The following examples modify a mapping that calculates the sales for the curren
t month, so it includes only positive values. This update strategy expression flags records less than 0 for reject and all oth ers for insert: This expression uses numeric literals to produce the same result: 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:
DD_UPDATE Flags records for update in an update strategy expression. DD_UPDATE is equivale nt to the integer literal 1. Note: Use the DD_UPDATE constant in the Update Strategy transformation only. Use DD_UPDATE instead of the integer literal 1 to facilitate troubleshooting complex numeric expressio ns.
When you run a workflow, select the data-driven update strategy to write records to a target based on this flag. Examples The following examples modify a mapping that calculates sales for the current mo nth. The mapping loads sales for one employee. This expression flags records for Alex as updates and flags all others for rejec tion: 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): 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 r eturns 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:
FALSE Clarifies a conditional expression. FALSE is equivalent to the integer 0. Example The following example uses FALSE in a DECODE expression to return values based o n the results of a comparison. This is useful if you want to perform multiple searches based on a s ingle search value: DECODE( FALSE, Var1 = 22,'Variable 1 was 22!', Var2 = 49,'Variable 2 was 49!', Var1 < 23, 'Variable 1 was less than 23.',
NULL Indicates that a value is either unknown or undefined. NULL is not equivalent to a blank or empty string (for character columns) or 0 (for numerical columns).
Although you can write expressions that return nulls, any column that has the NO T NULL or PRIMARY KEY constraint will not accept nulls. Therefore, if the Integration Service tries to write a null value to a column with one of these constraints, the database will reject the row and the Integration S ervice will write it to the reject file. 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 it might ignore null values. . Functions on page 35
Working with Null Values in Boolean Expressions Expressions that combine a null value with a Boolean expression produces results that are ANSI compliant. For example, 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 o perator, the Integration Service produces a null value. However, you can also configure the Integration S ervice to treat null values as high or low in comparison operations. Use the Treat Null In Comparison Operators As property to configure how the Inte gration Service handles null values in comparison expressions. For more information, see the PowerCenter Admi nistrator Guide. This Integration Service configuration property affects the behavior of the foll owing comparison operators in expressions: For example, consider the following expressions: NULL > 1
The following table describes how the Integration Service evaluates the expressi ons: Expression Treat Null in Comparison Operators As NULL HIGH
LOW NULL > 1 NULL TRUE FALSE NULL = NULL NULL TRUE TRUE
Null Values in Aggregate Functions By default, the Integration Service treats null values as nulls in aggregate fun ctions. If you pass an entire port or group of null values, the function returns NULL. However, when you configure the Integration Service, you can choose how you want it to handle null values in aggregate functions. You can have the Integration Service treat null values as 0 in aggregate functions or as NULLs.
Null Values in Filter Conditions If 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 NUL L (except COUNT, which returns 0). You use filter conditions with aggregate functions, and these functi ons CUME, MOVINGAVG, and MOVINGSUM.
Nulls with Operators Any 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: To test for nulls, use the ISNULL function.
TRUE Returns a value based on the result of a comparison. TRUE is equivalent to the i nteger 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 s ingle 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.',
CHAPTER 3 Operators This chapter includes the following topics: .Operator Precedence, 13 .Arithmetic Operators, 14 .String Operators, 14 .Comparison Operators, 15 .Logical Operators, 16
Operator Precedence The transformation language supports the use of multiple operators and the use o f operators within nested expressions. If you write an expression that includes multiple operators, the Integration Ser vice evaluates the expression in the 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 foll owing table. It evaluates operators in an expression with equal precedence to all operators from left to r ight. The following table lists the precedence for all transformation language operato rs: Operator Meaning ( ) Parentheses. +, -, NOT Unary plus and minus and the logical NOT operator. *, /,% Multiplication, division, modulus.
+, Addition, subtraction. || Concatenate. <, <=, >, >= Less than, less than or equal to, greater than, greater than or equal to. =, <>, !=, ^= Equal to, not equal to, not equal to, not equal to.
AND Logical AND operator, used when specifying conditions. OR Logical OR operator, used when specifying conditions.
The transformation language also supports the use of operators within nested exp ressions. When expressions contain parentheses, the Integration Service evaluates operations inside parenth eses 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: Equation Return Value 8 + 5 - 2 * 8 -3 8 + (5 - 2) * 8 32
Arithmetic Operators Use arithmetic operators to perform mathematical calculations on numeric data. The following table lists the arithmetic operators in order of precedence in the transformation language: Operator Meaning +, Unary plus and minus. Unary plus indicates a positive value. Unary minus indicat es a negative 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 .
If you perform arithmetic on a null value, the function returns NULL. When you use arithmetic operators in an expression, all of the operands in the e xpression must be numeric. For example, the expression 1 + '1' is not valid because it adds an integer to a string. The expression 1.23 + 4 / 2 is valid because all of the operands are numeric. Note: The transformation language provides built-in date functions that let you perform arithmetic on date/time values. For more information about built-in date functions, see Understanding Dat e Arithmetic on page 34.
String Operators Use the || string operator to concatenate two strings. The || operator converts operands of any datatype (except Binary) to String datatypes before concatenation: Input Value Return Value 'alpha' || 'betical' alphabetical 'alpha' || 2 alpha2 'alpha' || NULL alpha
The || operator includes leading and trailing blanks. Use the LTRIM and RTRIM fu nctions to trim leading and trailing blanks before concatenating two strings. Nulls The || operator ignores null values. However, if both values are NULL, the || op erator returns NULL.
Example The following example shows an expression that concatenates employee first names and employee last names from two columns. This expression removes the spaces from the end of the first n ame and the beginning of the last name, concatenates a space to the end of each first name, then concatenates the last name: Note: You can also 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 dat a, and return a TRUE (1) or FALSE (0) value. The following table lists the comparison operators in the transformation languag e: Operator Meaning = Equal to. > Greater than. < Less than. >= Greater than or equal to. <= Less than or equal to. <>
Use the greater than (>) and less than (<) operators to compare numeric values o r return a range of rows based on the sort order for a primary key in a particular port. When you use comparison operators in an expression, the operands must be the sam e datatype. For example, the expression 123.4 > 123 is not valid because the expression compares a decimal with a string. The expressions 123.4 > 123 and a != b are valid because the operands are the same datat ype. If you compare a value to a null value, the result is NULL.
Logical Operators Use logical operators to manipulate numeric data. Expressions that return a nume ric value evaluate to TRUE for values other than 0, FALSE for 0, and NULL for NULL. The following table lists the logical operators in the transformation language: Operator Meaning NOT Negates result of an expression. For example, if an expression evaluates to TRUE , the operator NOT returns FALSE. If an expression evaluates to FALSE, NOT returns TRU E. AND Joins two conditions and returns TRUE if both conditions evaluate to TRUE. Retur ns FALSE if one condition is not true. OR Connects two conditions and returns TRUE if any condition evaluates to TRUE. Ret urns FALSE if both conditions are not true.
Nulls Expressions that combine a null value with a Boolean expression produce results that are ANSI compliant. For example, the Integration Service produces the following results: .NULL AND TRUE = NULL .NULL AND FALSE = FALSE
CHAPTER 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 retu rn either run-time or system information. Run-time variables return information such as source and target tab le name, folder name, session run mode, and workflow run instance name. System variables return session start time, system date, and workflow start time. You can use built-in variables in expressions in the Designer or Workflow Manage r. For example, you can use the system variable SYSDATE in a DATE_DIFF function. You can use run-time variab les in expressions and in input 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 of built-in variables. You cannot define values for built-in variables in a workflo w or session parameter file. The following built-in variables provide run-time information: .$PM<SourceName>@TableName, $PM<TargetName>@TableName .$PMFolderName .$PMIntegrationServiceName .$PMMappingName .$PMRepositoryServiceName .$PMRepositoryUserName .$PMSessionName .$PMSessionRunMode .$PMWorkflowName .$PMWorkflowRunId .$PMWorkflowRunInstanceName
.$$$SessStartTime .SESSSTARTTIME
.SYSDATE .WORKFLOWSTARTTIME
The following table describes where you use built-in variables in the Designer a nd Workflow Manager: Variable Name Designer Workflow Manager $PM<SourceName> @TableName, $PM<TargetName> @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 mapping variables - Input fields that accept workflow variables - Expressions - Input fields that accept mapping variables - 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 mapping variables - Input fields that accept mapping
variables $PMSessionRunMode - Expressions - 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 $$$SessStartTime - Mapping or mapplet filter conditions - User-defined joins - SQL overrides - Mapping or mapplet filter conditions - User-defined joins - SQL overrides SESSSTARTTIME - Expressions n/a
$PM<SourceName>@TableName, $PM<TargetName>@TableName $PM<SourceName>@TableName and $PM<TargetName>@TableName return the source and ta rget table names for relational source and target instances as string values. Use these var iables with any function that accepts string datatypes. The variable name depends on the source or target instance name. For example, fo r a source instance named Customers, the built-in variable name is $PMCustomers@TableName. If the relational source or target is part of a mapplet within a mapping, the built-in variable name includes the mapplet n ame: .$PM<MappletName>.<SourceName>@TableName .$PM<MappletName>.<TargetName>@TableName
Use $PM<SourceName>@TableName and $PM<TargetName>@TableName in a mapping or a ma pplet. For example, in a mapping that contains multiple relational sources, you can use $PM <SourceName>@TableName in the output port of an Expression transformation to write the source table nam e for each row to the target. You can also use these variables in input fields that accept mapping variables.
$PMFolderName $PMFolderName returns the name of the repository folder as a string value. Use $ PMFolderName with any function that accepts string datatypes. Use $PMFolderName in a mapping, a mapplet, workflow links, or in workflow tasks such as Assignment and Decision tasks. You can also use $PMFolderName in input fields that accept mappi ng or workflow variables.
$PMIntegrationServiceName $PMIntegrationServiceName returns the name of the Integration Service that runs
the session. Use $PMIntegrationServiceName with any function that accepts string datatypes. $PMIn tegrationServiceName returns the Integration Service name as a string value. Use $PMIntegrationServiceName in a mapping, a mapplet, workflow links, or in wor kflow tasks such as Assignment and Decision tasks. You can also use $PMIntegrationServiceName in inp ut fields that accept mapping or workflow variables.
$PMMappingName $PMMappingName returns the mapping name as a string value. Use $PMMappingName wi th any function that accepts string datatypes. Use $PMMappingName in a mapping or a mapplet. You can also use $PMMappingName in input fields that accept mapping variables.
$PMRepositoryServiceName $PMRepositoryServiceName returns the name of the Repository Service as a string value. Use $PMRepositoryServiceName with any function that accepts string datatypes. Use $PMRepositoryServiceName in a mapping, a mapplet, workflow links, or in work flow tasks such as Assignment and Decision tasks. You can also use $PMRepositoryServiceName in inpu t fields that accept mapping or workflow variables.
$PMRepositoryUserName $PMRepositoryUserName returns the name of the repository user that runs the sess ion. Use $PMRepositoryUserName with any function that accepts string datatypes. $PMReposi toryUserName returns the repository user name as a string value. Use $PMRepositoryUserName in a mapping, a mapplet, workflow links, or in workflo w tasks such as Assignment and Decision tasks. You can also use $PMRepositoryUserName in input f ields that accept mapping or workflow variables.
$PMSessionName $PMSessionName returns the session name as a string value. Use $PMSessionName wi th any function that accepts string datatypes. Use $PMSessionName in a mapping or a mapplet. You can also use $PMSessionName in input fields that accept mapping variables.
$PMSessionRunMode $PMSessionRunMode returns the session run mode, normal or 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 $PMSessionRunM ode in input fields that accept mapping variables.
$PMWorkflowName $PMWorkflowName returns the name of the workflow as a string value. Use $PMWorkf lowName with any function that accepts string datatypes. Use $PMWorkflowName in a mapping, a mapplet, workflow links, or in workflow task s such as Assignment and Decision tasks. You can also use $PMWorkflowName in input fields that accept mapping or workflow variables.
$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 tas ks such as Assignment and Decision tasks. You can also use $PMWorkflowRunId in input fields that accep t mapping or workflow
variables. For example, you configure a workflow to run concurrently with the sa me instance name, and you want to track the status of each workflow run using a third-party application. U se $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 va lue. Use $PMWorkflowRunInstanceName with any function that accepts string datatypes. Use $PMWorkflowRunInstanceName in a mapping, a mapplet, workflow links, or in wo rkflow tasks such as Assignment and Decision tasks. You can also use $PMWorkflowRunInstanceName in in put fields that accept mapping or workflow variables. For example, for a concurrent workflow with uniqu e instance names, you can create unique target files for each run instance by setting the target output fi le name in the session properties to OutFile_$PMWorkflowRunInstanceName.txt. Or, you want to use a post-session shell command to create an indicator file use d by a predefined Event-Wait task. In the shell command that generates the indicator file, use $PMWorkflowRun InstanceName in the
indicator file name to ensure that one workflow run instance does not delete an indicator file needed by another workflow run instance.
$$$SessStartTime $$$SessStartTime returns the initial system date value on the node hosting the I ntegration Service 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. The following table lists the $$$SessStartTime date and time format according to different database types: Database Type Date/time format Oracle MM/DD/YYYY HH24:MI:SS Sybase MM/DD/YYYY HH24:MI:SS Microsoft SQL Server MM/DD/YYYY HH24:MI:SS Informix YYYY-MM-DD HH24:MI:SS ODBC YYYY-MM-DD HH24:MI:SS IBM DB2 YYYY-MM-DD-HH24:MI:SS
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 mapp ing attributes. For more information about using $$$SessStartTime in a mapping, see the PowerCenter Trans formation Guide. Note: Changing any database environment variable such as NLS_LANG_FORMAT for Ora cle or DBDATE for Informix does not affect the format string for datetime values the Integration S ervice uses in the SQL override for $$$SessStartTime.
Example The 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 Integration Service initializes the session. The expression uses the function DA TEDIFF to find the difference in the number of days between the value ORDER_DATE and $$$SessStartTime. If the dif ference between the two dates is less than or equal to seven days, the Integration Service extracts that row from the source:
SESSSTARTTIME SESSSTARTTIME returns the current date and time value on the node that runs the session when the Integration Service initializes the session. Use SESSSTARTTIME with any function that accepts transformation date/time datatypes. SESSSTARTTIME is stored as a transformation date/time datat ype value. Use SESSSTARTTIME in a mapping or a mapplet. You can reference SESSSTARTTIME onl y within the expression language. Example The following expression uses SESSSTARTTIME to display the number of days an ord er has been open. Using the SQL function DATE_DIFF, the Integration Service subtracts DATE_ENTERED from SESSSTARTTIME and returns the result as a number of days:
SYSDATE SYSDATE returns the current date and time up to seconds on the node that runs th e session for each row passing through the transformation. SYSDATE is stored as a transformation date/t ime datatype value. To capture a static system date, use the SESSSTARTTIME variable instead of SYSDA TE. Example The following expression uses SYSDATE to find orders that have shipped in the la st two days and flag them for insertion. 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 doub le 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 th em for insertion.
WORKFLOWSTARTTIME WORKFLOWSTARTTIME returns the current date and time on the node hosting the Inte gration Service when the Integration Service initializes the workflow. Use WORKFLOWSTARTTIME wit h any function that accepts transformation date/time datatypes. WORKFLOWSTARTTIME is stored as a tra nsformation date/time datatype value. Use WORKFLOWSTARTTIME in workflow links and tasks such as Assignment and Decisio n tasks. You can reference WORKFLOWSTARTTIME only within the expression language. Example The following expression uses WORKFLOWSTARTTIME to display the number of minutes between the workflow start time and the start time of a task in the workflow. Using the SQL function DATE_DIFF, the Integration Service subtracts the task start time from WORKFLOWSTARTTIME and ret urns the result as a number of days:
Transaction Control Variables Transaction control variables define conditions to commit or rollback transactio ns during the processing of database rows. You use these variables in transaction control expressions that y ou build in the Expression Editor. Transaction control expressions use the IIF function to test each row against a condition. Depending on the return value of the condition, the Integration Service commits, rolls back, or m
akes no transaction changes for the row. For more information about transaction control, see the PowerCenter Tra nsformation Guide. The following example uses transaction control variables to determine where to p rocess a row: If NEWTRAN=1, the TC_COMMIT_BEFORE variable causes a commit to occur before the current row processes. Otherwise, the TC_CONTINUE_TRANSACTION variable forces the row to pro cess in the current transaction. Use the following variables in the Expression Editor when you create a transacti on control expression: .TC_CONTINUE_TRANSACTION. The Integration Service does not perform any transacti on change for the current row. This is the default transaction control variable value. .TC_COMMIT_BEFORE. The Integration Service commits the transaction, begins a new transaction, and writes the current row to the target. The current row is in the new transaction.
.TC_COMMIT_AFTER. The Integration Service writes the current row to the target, commits the transaction, and begins a new transaction. The current row is in the committed t ransaction. .TC_ROLLBACK_BEFORE. The Integration Service rolls back the current transaction, begins a new transaction, and writes the current row to the target. The current row is in the new transaction.
Local Variables If you use local variables in a mapping, use them in any transformation expressi on in the mapping. For example, if you use a complex tax calculation throughout a mapping, you might want to wri te the expression once and designate it as a variable. This increases performance since the Integration Ser vice performs the calculation only once. Local variables are useful when used with stored procedure expressions to captur e multiple return values. For more information about local variables, see the PowerCenter Transformation G uide.
CHAPTER 5 Dates This chapter includes the following topics: .Overview, 25 .Date Format Strings, 28 .TO_CHAR Format Strings, 29 .TO_DATE and IS_DATE Format Strings, 31 .Understanding Date Arithmetic, 34
Overview The transformation language provides a set of date functions and built-in date v ariables to perform transformations on dates. With the date functions, you can round, truncate, or c ompare dates, extract one part of a date, or perform arithmetic on a date. You can pass any value with a date d atatype to a date function. Use date variables to capture the current date or session start time on the node hosting the Integration Service. 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 w ant to convert to a date or test.
Date/Time Datatype PowerCenter provides a set of generic datatypes to transform data from different sources. These transformation datatypes include a Date/Time datatype that supports datetime values up to the n anosecond. PowerCenter stores dates internally in binary format. Date functions accept datetime values only. To pass a string to a date function, first use TO_DATE to convert it to a datetime value. For example, the following expression converts a string por t to datetime values and then adds one month to each date: PowerCenter supports dates between 1 A.D. and 9999 A.D in the Gregorian calendar system.
Julian Day, Modified Julian Day, and the Gregorian Calendar PowerCenter supports dates in the Gregorian calendar system only. Dates expresse d in a different calendar system are not supported. Dates in the Julian calendar are called Julian dates a nd are not supported in PowerCenter. This term should not be confused with Julian Day or with Modified J ulian Day. PowerCenter provides 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 B.C . 00:00:00 (midnight). By definition, MJD includes a time component expressed as a decimal, which represen ts 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: Because the J format string does not include the time portion of a date, the ret urn values have the time set to 00:00:00.000000000. You can also use the J format string in TO_CHAR expressions. For example, use th e J format string in a TO_CHAR expression to convert date values to MJD values expressed as strings. Fo r example: Note: The Integration Service ignores the time portion of the date in a TO_CHAR expression.
Dates in the Year 2000 All transformation language date functions support the year 2000. PowerCenter su pports dates between 1 A.D. and 9999 A.D. RR Format String The transformation language provides the RR format string to convert strings wit h two-digit years to dates. Using TO_DATE and the RR format string, you can convert a string in the format M M/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 Integration Service returns the current century pl us the two-digit year from the source string. If the source string year is between 50 and 99, the Integration S ervice 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 Integration Service returns the next centur y plus the two-digit year from
the source string. If the source string year is between 50 and 99, the Integrati on Service returns the current century plus the specified two-digit year.
The following table summarizes how the RR format string converts to dates: Current year Source year RR Format String Returns 0-49 0-49 Current century 0-49 50-99 Previous century
Example The following expression produces the same return values for any current year be tween 1950 and 2049: Difference Between the YY and RR Format Strings PowerCenter also provides 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 funct ions except TO_DATE. In TO_DATE expressions, RR and YY produce different results. The following table shows the different results each format string returns: String Current Year TO_DATE(String, TO_DATE(String, 04/12/98 1998 04/12/1998 00:00:00.000000000 04/12/1998 00:00:00.000000000 11/09/01 1998 11/09/2001 00:00:00.000000000 11/09/1901 00:00:00.000000000 04/12/98 2003 04/12/1998 00:00:00.000000000 MM/DD/RR ) MM/DD/YY )
For dates in the year 2000 and beyond, the YY format string produces less meanin gful results than the RR format string. Use the RR format string for dates in the twenty-first century.
Dates in Relational Databases In 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, seconds, and sub-seco nds. You can pass datetime data to any of the date functions.
Dates in Flat Files Use the TO_DATE function to convert strings to datetime values. You can also use IS_DATE to check if a string is a valid date before converting it with TO_DATE. The transformation lan guage date functions accept date values only. 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 Format The Integration Service uses a default date format to store and manipulate strin gs that represent dates. To specify the default date format, enter a date format in the DateTime Format Stri ng attribute on the Config Object tab for a session or session configuration object. By default, the date f ormat is MM/DD/YYYY HH24:MI:SS.US. Because PowerCenter stores dates in binary format, the Integration Service uses the default date format when you perform the following actions:
.Convert a date to a string by connecting a date/time port to a string port. The Integration Service converts the date to a string in the date format defined in the session configuration obj ect. .Convert a string to a date by connecting a string port to a date/time port. The Integration Service expects the string values to be in the date format defined by the session configuration object. If an input value does not match this format, or if it is an invalid date, the Integration Service skip s the row. If the string is in this format, the Integration Service 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 Integration Service returns the string in the date format defined in the session properties. If you specify a format string, the Integration Service 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 Integration Service expects the string in the date format defined in the session properties. If you specify a format string, the Integration Service expects a string in the specified format.
The default date format of MM/DD/YYYY HH24:MI:SS.US consists of: .Month (January = 01, September = 09) .Day (of the month) .Year (expressed in four digits, such as 1998) .Hour (in 24-hour format, for example, 12:00:00AM = 0, 1:00:00AM = 1, 12:00:00PM = 12, 11:00:00PM = 23) .Minutes .Seconds .Microseconds
Date Format Strings You can evaluate input dates using a combination of format strings and date func tions. Date format strings are not internationalized and must be entered in predefined formats as listed in the following table. The following table summarizes the format strings to specify a part of a date: Format String
Description D, DD, DDD, DAY, DY, J Days (01-31). Use any of these format strings to specify the entire day portion of a date. For example, if you pass 12-APR-1997 to a date function, use any of these format strings specify 12. HH, HH12, HH24 Hour of day (0-23), where 0 is 12 AM (midnight). Use any of these formats to specify the entire hour portion of a date. For example, if you pass the date 12APR-1997 2:01:32 PM, use HH, HH12, or HH24 to specify the hour portion of the date. MI Minutes (0-59). MM, MON, MONTH Month (01-12). Use any of these format strings to specify the entire month porti on of a date. For example, if you pass 12-APR-1997 to a date function, use MM, MON, or MONTH to specify APR. MS Milliseconds (0-999). NS Nanoseconds (0-999999999). SS, SSSS Seconds (0-59). US Microseconds (0-999999). Y, YY, YYY, YYYY, RR Year portion of date (0001 to 9999). Use any of these format strings to specify the entire year portion of a date. For example, if you pass 12-APR-1997 to a date function, use Y, YY, YYY, or YYYY to specify 1997.
Note: The format string is not case sensitive. It must always be enclosed within single quotation marks.
The following table describes date functions that use date format strings to eva luate input dates: Function Description ADD_TO_DATE The part of the date you want to change. DATE_DIFF The part of the date to use to calculate the difference between two dates. GET_DATE_PART The part of the date you want to return. This function returns an integer value based on the default date format. IS_DATE The date you want to check. ROUND The part of the date you want to round. SET_DATE_PART The part of the date you want to change. SYSTIMESTAMP The timestamp precision. TO_CHAR (Dates) The character string. TO_DATE The character string. TRUNC (Dates) The part of the date you want to truncate.
The TO_CHAR function converts a Date/Time datatype to a string with the format y ou 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 strings, 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. The following table summarizes the format strings for dates in the function TO_C HAR: Format String Description AM, A.M., PM, P.M. Meridian indicator. Use any of these format strings to specify AM and PM hours. AM and PM return the same values as A.M. and P.M. D Day of week (1-7), where Sunday equals 1. DAY Name of day, including up to nine characters (for example, Wednesday). DD Day of month (01-31). DDD Day of year (001-366, including leap years). DY Abbreviated three-character name for a day (for example, Wed). HH, HH12 Hour of day (01-12). HH24 Hour of day (00-23), where 00 is 12AM (midnight). J Modified Julian Day. Converts the calendar date to a string equivalent to its Mo dified Julian Day value, calculated from Jan 1, 4713 00:00:00 B.C. It ignores the time component o f the date. For
example, the expression TO_CHAR( SHIP_DATE, J ) converts Dec 31 1999 23:59:59 to the string 2451544. MI Minutes (00-59). MM Month (01-12). MONTH Name of month, including up to nine characters (for example, January).
MON Abbreviated three-character name for a month (for example, Jan). MS Milliseconds (0-999). NS Nanoseconds (0-999999999). Q Quarter of year (1-4), where January to March equals 1. RR Last two digits of a year. The function removes the leading digits. For example, if you use RR and pass the year 1997, TO_CHAR returns 97. When used with TO_CHAR, RR produces th e same results as, and is interchangeable with, YY. However, when used with TO_DATE, RR calculates the closest appropriate century and supplies the first two digits of the year. SS Seconds (00-59). SSSSS Seconds since midnight (00000 - 86399). When you use SSSSS in a TO_CHAR expressi on, the Integration Service only evaluates the time portion of a date. For example, the expression TO_CHAR(SHIP_DATE, MM/DD/YYYY SSSSS ) converts 12/31/1999 01:02:03 to 12/31/1999 03723. US Microseconds (0-999999). Y Last digit of a year. The function removes the leading digits. For example, if y ou use Y and pass the year 1997, TO_CHAR returns 7. YY Last two digits of a year. The function removes the leading digits. For example, if you use YY and pass the year 1997, TO_CHAR returns 97. YYY Last three digits of a year. The function removes the leading digits. For exampl
e, if you use YYY and pass the year 1997, TO_CHAR returns 997. YYYY Entire year portion of date. For example, if you use TO_CHAR returns 1997. W Week of month (1-5), where week 1 starts on the first day of the month and ends on the seventh, week 2 starts on the eighth day and ends on the fourteenth day. For example, Feb 1 designates the first week of February. WW Week of year (01-53), where week 01 starts on Jan 1 and ends on Jan 7, week 2 starts on Jan 8 and ends on Jan 14, and so on. - / . ; : Punctuation that displays in the output. You might use these symbols to separate date parts. For example, you create the following expression to separate date parts with a perio d: TO_CHAR( DATES, MM.DD.YYYY ). text Text that displays in the output. For example, if you create an output port with the expression: TO_CHAR( DATES, MM/DD/YYYY Sales Were Up ) and pass the date Apr 1 1997, the function returns the string 04/01/1997 Sales Were Up . You can enter multibyte char acters that are valid in the repository code page. YYYY and pass the year 1997,
Use double quotation marks to separate ambiguous format strings, for example D The empty quotation marks do not appear in the output.
DDD.
Note: The format string is not case sensitive. It must always be enclosed within single quotation marks.
Examples The following examples illustrate the J, SSSSS, RR, and YY format strings. See t
he individual functions for more examples. Note: The Integration Service ignores the time portion of the date in a TO_CHAR expression.
J Format String Use the J format string in a TO_CHAR expression to convert date values to MJD va lues expressed as strings. For example:
SSSSS Format String You can also use the format string SSSSS in a TO_CHAR expression. For example, t he following expression converts the dates in the SHIP_DATE port to strings representing the total secon ds since midnight: RR Format String The following expression converts dates to strings in the format MM/DD/YY: YY Format String 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_DATE and IS_DATE Format Strings The TO_DATE function converts a string with the format you specify to a datetime value. TO_DATE is generally used to convert strings from flat files to datetime values. TO_DATE fo rmat strings are not internationalized and must be entered in predefined formats as listed in Table 5 -1. Note: 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 d ate in the source string. The source string format and the format string must match, including any date separa tor. If any part does not match, the Integration Service does not convert the string, and it skips the row . If you omit the format string, the source string must be in the date format specified in the session. IS_DATE indicates if a value is a valid date. A valid date is any string represe nting a valid date in the date format specified in the session. If the strings you want to test are not in this date format, use the format strings listed in Table 5-1 to specify the date format. If a string does not match the s pecified 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-1 summarizes the format strings for the functions TO_DATE and IS_DATE: Table 5-1. TO_DATE and IS_DATE Format Strings Format String Description AM, a.m., PM, p.m. Meridian indicator. Use any of these format strings to specify AM and PM hours. AM and PM return the same values as do a.m. and p.m. DAY Name of day, including up to nine characters (for example, Wednesday). The DAY format string is not case sensitive. DD Day of month (1-31). DDD Day of year (001-366, including leap years). DY Abbreviated three-character name for a day (for example, Wed). The DY format string is not case sensitive. HH, HH12 Hour of day (1-12). HH24 Hour of day (0-23), where 0 is 12AM (midnight). J Modified Julian Day. Convert strings in MJD format to date values. It ignores th e time component of the source string, assigning all dates the time of 00:00:00.000000000. For example, the expression TO_DATE( 2451544 , J ) converts 2451544 to Dec 31 1999 00:00:00.000000000. MI Minutes (0-59). MM Month (1-12).
MONTH Name of month, including up to nine characters (for example, August). Case does not matter. MON Abbreviated three-character name for a month (for example, Aug). Case does not matter. MS Milliseconds (0-999). NS Nanoseconds (0-999999999). RR Four-digit year (for example, 1998, 2034). Use when source strings include twodigit years. Use with TO_DATE to convert two-digit years to four-digit years. - Current Year Between 50 and 99. If the current year is between 50 and 99 (such as 1998) and the year value of the source string is between 0 and 49, the Integration Service returns the next century plus the two-digit year from the source string. If the year value of the source string is between 50 and 99, the Integration Service returns the current century plus the specified two-digit yea r. - Current Year Between 0 and 49. If the current year is between 0 and 49 (such a s 2003) and the source string year is between 0 and 49, the Integration Service returns the current century plus the two-digit year from the source string. If t he source string year is between 50 and 99, the Integration Service returns the previous century plus the two-digit year from the source string.
SS Seconds (0-59). SSSSS Seconds since midnight. When you use SSSSS in a TO_DATE expression, the Integration Service only evaluates the time portion of a date. For example, the expression TO_DATE( DATE_STR, MM/DD/YYYY SSSSS ) converts 12/31/1999 3783 to 12/31/1999 01:02:03. US Microseconds (0-999999). Y The current year on the node running the Integration Service with the last digit
of the year replaced with the string value. YY The current year on the node running the Integration Service with the last two digits of the year replaced with the string value.
YYY The current year on the node running the Integration Service with the last three digits of the year replaced with the string value. YYYY Four digits of a year. Do not use this format string if you are passing two-digi t years. Use the RR or YY format string instead.
Rules and Guidelines Use the following rules and guidelines when you work with date format strings: .The format of the TO_DATE string must match the format string including any dat e separators. If it does not, the Integration Service 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 forma t string YYYYMMDD. If you do not include a format string, the Integration Service expects the string in the date format specified in the session. Likewise, if you pass a string that does not ma tch the format string, the Integration Service 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 Integration Service returns an error and skips the row because the string does not match the format string. .The format string must be enclosed within single quotation marks. .The Integration Service uses the default date time format specified in the sess ion. Default is MM/DD/YYYY HH24:MI:SS.US. The format string is not case sensitive.
Example The following examples illustrate the J, RR, and SSSSS format strings. See the i ndividual functions for more examples. J Format String The following expression converts strings in the SHIP_DATE_MJD_STRING port to da te values in the default date format: Because the J format string does not include the time portion of a date, the ret urn values have the time set to 00:00:00.000000000.
RR Format String The following expression converts a string to a four-digit year format. The curr ent year is 1998: YY Format String The following expression converts a string to a four-digit year format. The curr ent year is 1998:
Note: For the second row, RR returns the year 2005, but YY returns the year 1905 .
SSSSS Format String The following expression converts strings that include the seconds since midnigh t to date values:
Understanding Date Arithmetic The transformation language provides built-in date functions so you can perform arithmetic on datetime values as follows: .ADD_TO_DATE. Add or subtract a specific portion of a date. .DATE_DIFF. Subtract two dates. .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, 0001 00:00:00.000000000 A.D. and Dec. 31, 9999 23:59:59.999999999 A.D. Note: The transformation language uses the transformation Date/Time datatype to specify date values. You can only use the date functions on datetime values.
CHAPTER 6 Functions This chapter describes the functions in the transformation language in alphabeti cal order. Each function description includes: .Syntax .Return value .Example
Function Categories The transformation language provides the following types of functions: .Aggregate .Character .Conversion .Data Cleansing .Date .Encoding .Financial .Numerical .Scientific .Special .String .Test .Variable
Aggregate Functions Aggregate 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) .MAX (String) .MEDIAN .MIN (Date) .MIN (Number) .MIN (String) .PERCENTILE .STDDEV .SUM .VARIANCE
If you configure the Integration Service to run in Unicode mode, MIN and MAX ret urn values according to the sort order of the code page you specify in the session properties. Use aggregate functions in Aggregator transformations only. You can nest only on e aggregate function within another aggregate function. The Integration Service evaluates the innermost aggr egate function expression and uses 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: where the dataset contains the following values: ID EARNINGS 1
32 1 45 1 100 2 65 2 75 2 76 3 21 3 45 3 99
The return value is 186. The Integration Service groups by ID, evaluates the AVG expression, and returns three values. Then it adds the values with the SUM function to get the result.
Aggregate Functions and Nulls When you configure the Integration Service, you can choose how you want to handl e null values in aggregate functions. You can have the Integration Service treat null values in aggregate f unctions as NULL or 0.
By default, the Integration Service treats null values as NULL in aggregate func tions. If you pass an entire port of null values, the function returns NULL. You can optionally configure the Inte gration Service if you pass an entire port of null values to an aggregate function to return 0. Filter Conditions A filter limits the rows returned in a search. You can apply a filter condition to all aggregate functions and to CUME, MOVINGAVG, and MOVINGSUM. The filter condition must evaluate to TRUE, FALS E, or NULL. If the filter condition evaluates to NULL or FALSE, the Integration Service does not select the row. You can enter any valid transformation expression. For example, the following ex pression calculates the median salary for all employees who make more than $50,000: 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: In all cases, the Integration Service 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 0, the filter condition retu rns FALSE. If you do not want to round up a value, use the TRUNC function to truncate the value to an integer: If you omit the filter condition, the function selects all rows in the port.
Character Functions The transformation language includes the following character functions: .ASCII .CHR .CHRCODE .CONCAT .INITCAP .INSTR .LENGTH .LOWER .LPAD .LTRIM .METAPHONE .REPLACECHR
The character functions MAX, MIN, LOWER, UPPER, and INITCAP use the code page of the Integration Service to evaluate character data.
Conversion Functions The transformation language includes the following conversion functions: .TO_BIGINT .TO_CHAR(Number) .TO_DATE .TO_DECIMAL .TO_FLOAT .TO_INTEGER
Data Cleansing Functions The transformation language includes a group of functions to eliminate data erro rs. You can complete the following tasks with data cleansing functions: .Test input values. .Convert the datatype of an input value. .Trim string values. .Replace characters in a string. .Encode strings. .Match patterns in regular expressions.
The transformation language includes the following data cleansing functions: .BETWEEN .GREATEST .IN .INSTR .IS_DATE .IS_NUMBER .IS_SPACES .ISNULL .LEAST .LTRIM .METAPHONE
.REG_EXTRACT .REG_MATCH .REG_REPLACE .REPLACECHR .REPLACESTR .RTRIM .SOUNDEX .SUBSTR .TO_BIGINT .TO_CHAR .TO_DATE .TO_DECIMAL
.TO_FLOAT .TO_INTEGER
Date Functions The transformation language includes a group of date functions to round, truncat e, 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. Howeve r, if you want to pass a string to a date function, you must first use the TO_DATE function to convert it to a t ransformation Date/Time datatype. The transformation language includes the following date functions: .ADD_TO_DATE .DATE_COMPARE .DATE_DIFF .GET_DATE_PART .IS_DATE .LAST_DAY .MAKE_DATE_TIME .MAX .MIN .ROUND(Date) .SET_DATE_PART .SYSTIMESTAMP .TO_CHAR(Date) .TRUNC(Date)
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 Date Format Strings on page 28. The Date/Time transformation datatype supports dates with precision to the nanos econd.
Encoding Functions The transformation language includes the following functions for data encryption , compression, encoding, and checksum: .AES_DECRYPT .AES_ENCRYPT .COMPRESS .CRC32 .DEC_BASE64 .DECOMPRESS .ENC_BASE64 .MD5
Financial Functions The transformation language includes the following financial functions:
Numeric Functions The transformation language includes the following numeric functions: .ABS .CEIL .CONV .CUME .EXP .FLOOR .LN .LOG .MAX .MIN .MOD .MOVINGAVG .MOVINGSUM .POWER .RAND .ROUND .SIGN .SQRT .TRUNC
Scientific Functions
The transformation language includes the following scientific functions: .COS .COSH .SIN .SINH .TAN .TANH
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 i n an aggregate function.
String Functions The transformation language includes the following string functions: .CHOOSE .INDEXOF .MAX .MIN .REVERSE
Test Functions The transformation language includes the following test functions: .ISNULL .IS_DATE .IS_NUMBER .IS_SPACES
Variable Functions The transformation language includes a group of variable functions to update the current value of a mapping variable throughout the session. When you run a workflow, the Integration Servic e evaluates the start and current value of a variable at the beginning of the session based on the final v alue of the variable from the last session run. Use the following variable functions: .SetCountVariable .SetMaxVariable .SetMinVariable .SetVariable
Use different variable functions with a variable based on the aggregation type o f the variable. When using mapping variables in sessions with multiple partitions, use variable functions to determine the final value of the variable for each partition. At the end of the session, the Integra tion Service performs the aggregate function across all partitions to determine one final value to save to the repos itory. Unless overridden, it uses the saved value as the start value of the variable for the next time you use thi s session. For example, you use SetMinVariable to set a variable to the minimum evaluated v alue. The Integration Service calculates the minimum current value for the variable for each partition. Then a t the end of the session, it finds the minimum current value across all partitions and saves that value into the re pository. Use SetVariable only once for each mapping variable in a pipeline. When you crea te multiple partitions in a pipeline, the Integration Service uses multiple threads to process that pipeline . If you use this function more than once for the same variable, the current value of a mapping variable may hav e indeterministic results.
Stops the session, and issues a specified error message to the session log file. When the Integration Service encounters an ABORT function, it stops transforming data at that row. It process es any rows read before the session aborts and loads them based on the source- or target-based commit interv al and the buffer block size defined for the session. The Integration Service 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 sessi on after rollback. Use ABORT to validate data. Generally, you use ABORT within an IIF or DECODE fun ction to set rules for aborting a session. 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 t o handle any kind of transformation error, including ERROR function calls within an expression. The d efault 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 Integration Servi ce does not run the ABORT function. Note: The Integration Service handles the ABORT function and the Abort command y ou issue from the Workflow Manager differently.
Syntax Return Value Positive numeric value. ABS returns the same datatype as the numeric value passe d as an argument. If you pass a Double, it returns a Double. Likewise, if you pass an Integer, it returns an I nteger. NULL if you pass a null value to the function. Note: If the return value is Decimal with precision greater than 15, you can ena ble high precision in the session properties to ensure decimal precision up to 28 digits.
Example The following expression returns the difference between two numbers as a positiv e value, regardless of which number is larger:
Adds a specified amount to one part of a datetime value, and returns a date in t he same format as the date you pass to the function. ADD_TO_DATE accepts positive and negative integer values. Use ADD_TO_DATE to change the following parts of a date: .Year. Enter a positive or negative integer in the amount argument. Use any of t he year format strings: Y, YY, YYY, or YYYY. The following expression adds 10 years to all dates in the SHIP_DA TE port: .Month. Enter a positive or negative integer in the amount argument. Use any of the month format strings: MM, MON, MONTH. The following expression subtracts 10 months from each date in t he SHIP_DATE port: .Day. Enter a positive or negative integer in the amount argument. Use any of th e day format strings: D, DD, DDD, DY, and DAY. The following expression adds 10 days to each date in the SHIP _DATE port:
.Hour. Enter a positive or negative integer in the amount argument. Use any of t he hour format strings: HH, HH12, HH24. The following expression adds 14 hours to each date in the SHIP_DATE port: .Minute. Enter a positive or negative integer in the amount argument. Use the MI format string to set the minute. The following expression adds 25 minutes to each date in the SHIP_DATE p ort: .Seconds. Enter a positive or negative integer in the amount argument. Use the S S format string to set the second. The following expression adds 59 seconds to each date in the SHIP_DATE p ort: .Milliseconds. Enter a positive or negative integer in the amount argument. Use the MS format string to set the milliseconds. The following expression adds 125 milliseconds to each date in the SHIP_DATE port: .Microseconds. Enter a positive or negative integer in the amount argument. Use the US format string to set the microseconds. The following expression adds 2,000 microseconds to each date in the SHIP_DATE port: .Nanoseconds. Enter a positive or negative integer in the amount argument. Use t he NS format string to set the nanoseconds. The following expression adds 3,000,000 nanoseconds to each dat e in the SHIP_DATE port:
Syntax Return Value Date 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. Examples The following expressions all add one month to each date in the DATE_SHIPPED por t. If you pass a value that creates a day that does not exist in a particular month, the Integration Service returns the last day of the month. For example, if you add one month to Jan 31 1998, the Integration Service return s 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 )
The following expressions subtract 10 days from each date in the DATE_SHIPPED po rt: 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 )
The following expressions subtract 15 hours from each date in the DATE_SHIPPED p ort: Working with Dates Use 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 mont h, the Integration Service returns the last day of the month. For example, if you add one month to Jan 31 1998, the Integration Service returns Feb 28 1998. .You can nest TRUNC and ROUND to 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 mod ify a date so that it changes from standard to daylight savings time, you need to change the hour port ion of the date.
Returns encrypted data to string format. The Integration Service uses Advanced E ncryption Standard (AES) algorithm with 128-bit encoding. The AES algorithm is a FIPS-approved cryptograp hic algorithm. Syntax Return Value Decrypted binary value. NULL if the input value is a null value. Example The following example returns decrypted social security numbers. In this example , the Integration Service derives the key from the first three numbers of the social security number using the SUBSRT function:
Returns data in encrypted format. The Integration Service uses Advanced Encrypti on Standard (AES) algorithm with 128-bit encoding. The AES algorithm is a FIPS-approved cryptograp hic algorithm. Use this function to prevent sensitive data from being visible to everyone. For example, to store social security numbers in a data warehouse, use the AES_ENCRYPT function to encrypt the social security numbers to maintain confidentiality.
Syntax Return Value Encrypted binary value. NULL if the input is a null value. Example The following example returns encrypted values for social security numbers. In t his example, the Integration Service derives the key from the first three numbers of the social security numb er using the SUBSTR function: Tip If the target does not support binary data, use AES_ENCRYPT with the ENC_BASE64 function to store the data in a format compatible with the database.
When you configure the Integration Service to run in ASCII mode, the ASCII funct ion returns the numeric ASCII value of the first character of the string passed to the function. When you configure the Integration Service to run in Unicode mode, the ASCII fun ction returns the numeric Unicode value of the first character of the string passed to the function. Unico de 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 char acter in the string. Before you pass any string value to ASCII, you can 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. 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 existing expressions, they will still work correctly. However, when you create new expressions, use th e CHRCODE function instead of the ASCII function. Syntax Return Value Integer. The ASCII or Unicode value of the first character in the string. NULL if a value passed to the function is NULL. Example The following expression returns the ASCII or Unicode value for the first charac ter of each value in the ITEMS port:
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. You can nest only one other aggregate function within AVG, and the nested function must return a Numeric datatype. Syntax
Return Value Numeric value. NULL if all values passed to the function are NULL or if no rows are selected. F or example, the filter condition evaluates to FALSE or NULL for all rows. Note: If the return value is decimal with precision greater than 15, you can ena ble high precision in the session properties to ensure decimal precision up to 28 digits.
Nulls If a value is NULL, AVG ignores the row. However, if all values passed from the port are NULL, AVG returns NULL. Note: By default, the Integration Service treats null values as NULLs in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when you confi gure the Integration Service, you can choose how you want to handle null values in aggregate functions. You ca n treat null values as 0 in aggregate functions or as NULL.
Group By AVG groups values based on group by ports you define in the transformation, retu rning one result for each group. If there is not a group by port, AVG treats all rows as one group, returning one value. Example The following expression returns the average wholesale cost of flashlights: Tip You can perform arithmetic on the values passed to AVG before the function calcu lates the average. For example:
Returns the smallest integer greater than or equal to the numeric value passed t o this function. For example, if you pass 3.14 to CEIL, the function returns 4. If you pass 3.98 to CEIL, the fun ction returns 4. Likewise, if you pass -3.17 to CEIL, the function returns -3. Syntax Return Value Integer 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. Example The following expression returns the price rounded to the next integer: Tip: You 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 t he smallest integer less than the modified value, you might write the function as follows:
Chooses a string from a list of strings based on a given position. You specify t he position and the value. If the value matches the position, the Integration Service returns the value.
Syntax Return Value The string that matches the position of the index value. NULL if no string matches the position of the index value. Example The following expression returns the string 2: flashlight based on an index value of
The following expression returns NULL based on an index value of 4: CHOOSE returns NULL because the expression does not contain a fourth argument.
When you configure the Integration Service to move data in ASCII mode, CHR retur ns 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 Integration Service to move data in Unicode mode, CHR ret urns the Unicode character corresponding to the numeric value you pass to this function. Unicode values fall in the range 0 to 65,535. Syntax Return Value ASCII or Unicode character. A string containing one character. NULL if a value passed to the function is NULL.
Example The following expression returns the ASCII or Unicode character for each numeric value in the ITEM_ID port: Use the CHR function to concatenate a single quote onto a string. The single quo te is the only character that you cannot use inside a string literal. Consider the following example: The return value is:
When you configure the Integration Service 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 Integration Service to run in Unicode mode, CHRCODE retur ns the numeric Unicode value of the first character of the string passed to the function. Unico de values fall in the range 0 to 65,535. Normally, before you pass any string value to CHRCODE, you parse out the specifi c character you want to convert to an ASCII or Unicode value. For example, you might use RTRIM or anothe r string-manipulation function. 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 u se ASCII in expressions, it will still work correctly. However, when you create new expressions, use the CHRCODE function instead of the ASCII function. Syntax Return Value ASCII or Unicode character. A string containing one character.
NULL if a value passed to the function is NULL. Example The following expression returns the ASCII or Unicode value for the first charac ter of each value in the ITEMS port:
Compresses data using the zlib 1.2.1 compression algorithm. Use the COMPRESS fun ction before you send large amounts of data over a wide area network. Syntax Return Value Compressed binary value of the input value. NULL if the input is a null value. Example Your organization has an online order service. You want to send customer order d ata over a wide area network. The source contains a row that is 10 MB. You can compress the data in this row u sing COMPRESS. When you compress the data, you decrease the amount of data the Integration Service write s over the network. As a result, you may increase session performance.
Concatenates two strings. CONCAT converts all data to text before concatenating the strings. Alternatively, use the || string operator to concatenate strings. Using the || string operator instead of CONCAT improves Integration Service performance when you run sessions. Syntax Return Value String. NULL if both string values are NULL. Nulls If one of the strings is NULL, CONCAT ignores it and returns the other string. If both strings are NULL, CONCAT returns NULL. Example The following expression concatenates the names in the FIRST_NAME and LAST_NAME ports: CONCAT does not add spaces to separate strings. If you want to add a space betwe en two strings, you can write an expression with two nested CONCAT functions. For example, the following expre ssion first concatenates a space on the end of the first name and then concatenates the last name:
Use the CHR and CONCAT functions to concatenate a single quote onto a string. Th e single quote is the only character you cannot use inside a string literal. Consider the following example : The return value is:
Converts a number from one base value to another base value. Syntax Return Value Numeric value. Example The following example converts 2222 from the decimal base value 10 to the binary base value 2: The Integration Service returns 100010101110.
Returns the cosine of a numeric value (expressed in radians). Syntax Return Value Double value. NULL if a value passed to the function is NULL. Example The following expression returns the cosine for all values in the Degrees port: Tip: You 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 th e cosine, as follows:
Syntax Return Value Double value. NULL if a value passed to the function is NULL. Example The following expression returns the hyperbolic cosine for the values in the Ang les port: Tip: You can perform arithmetic on the values passed to COSH before the function calculates the hyperbolic cosine. For example:
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. You can nest only one ot her aggregate function within COUNT. You can apply a condition to filter rows before counting them. Syntax or
Return Value Integer. 0 if all values passed to this function are NULL (unless you include the asteris k argument). Nulls If all values are NULL, the function returns 0. If you apply the asterisk argument, this function counts all rows, regardless if a column in a row contains a null value. If you apply the value argument, this function ignores columns with null values. Note: By default, the Integration Service treats null values as NULLs in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when you confi gure the Integration Service, you can choose how you want to handle null values in aggregate functions. You ca n treat null values as 0 in aggregate functions or as NULL.
Group By COUNT groups values based on group by ports you define in the transformation, re turning one result for each group. If there is no group by port COUNT treats all rows as one group, returnin g one value. Examples The following expression counts the items with less than 5 quantity in stock, ex cluding null values: In this example, the function counted the Halogen flashlight but not the NULL it em. The function counts all rows in a transformation, including null values, as illustrated in the following example:
In this example, the function counts the NULL item and the Halogen Flashlight. I f you include the asterisk argument, but do not use a filter, the function counts all rows that pass into t he transformation. For example:
Returns a 32-bit Cyclic Redundancy Check (CRC32) value. Use CRC32 to find data t ransmission errors. You can also use CRC32 if you want to verify that data stored in a file has not been modified. If you use CRC32 to perform a redundancy check on data in ASCII mode and Unicode mode, the Integrati on Service may generate different results on the same input value. Note: CRC32 can return the same output for different input strings. If you want to generate keys in a mapping, use a Sequence Generator transformation. If you use CRC32 to generate keys in a mapping, you may receive unexpected results.
Example You want to read data from a source across a wide area network. You want to make sure the data has been modified during transmission. You can compute the checksum for the data in the f ile and store it along with the file. When you read the source data in PowerCenter, the Integration Service can use CRC32 to compute the checksum and compare it to the stored value. If the two values are the same, the data has not been modified.
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 rep orting by calculating running values. Syntax Return Value Numeric 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). Note: If the return value is decimal with precision greater than 15, you can ena ble high precision in the session properties to ensure decimal precision up to 28 digits.
Nulls If 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.
Examples The following sample rowset might result from using the CUME function: Likewise, you can add values before calculating a running total:
Returns an integer indicating which of two dates is earlier. DATE_COMPARE return s an integer value rather than a date value. Syntax 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. Example The following expression compares each date in the DATE_PROMISED and DATE_SHIPPE D ports, and returns an integer indicating which date is earlier:
Returns the length of time between two dates. You can request the format to be y ears, months, days, hours, minutes, seconds, milliseconds, microseconds, or nanoseconds. The Integration Se rvice subtracts the second date from the first date and returns the difference. Syntax Return Value Double value. If date1 is later than date2, the return value is a positive numbe r. If date1 is earlier than date2, the return value is a negative number. 0 if the dates are the same. NULL if one (or both) of the date values is NULL.
Examples The following expressions return the number of hours between the DATE_PROMISED a nd DATE_SHIPPED ports: DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, 'HH' ) DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, 'HH12' )
The following expressions return the number of days between the DATE_PROMISED an d 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' )
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' )
The following expressions return the number of years between the DATE_PROMISED a nd DATE_SHIPPED ports: DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, 'Y' ) DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, 'YY' ) DATE_DIFF( DATE_PROMISED, DATE_SHIPPED, 'YYY' )
Decodes a base 64 encoded value and returns a string with the binary data repres entation of the data. If you encode data using ENC_BASE64, and you want to decode data using DEC_BASE64, you must run the decoding session using the same data movement mode. Otherwise, the output of the decoded data may differ from the original data. Syntax Return Value Binary decoded value.
NULL if the input is a null value. Return values differ if you run the session in Unicode mode versus ASCII mode. Example You encoded WebSphere MQ message IDs and wrote them to a flat file during a work flow. You want to read data from the flat file source, including the WebSphere MQ message IDs. You can use DEC_BASE64 to decode the IDs and convert them to their original binary value.
Searches a port for a value you specify. If the function finds the value, it ret urns a result value, which you define. You can build an unlimited number of searches within a DECODE function. If you use DECODE to search for a value in a string port, you can either trim tr ailing blanks with the RTRIM function or include the blanks in the search string. Syntax Return Value First_result if the search finds a matching value. 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 va lue. Even if multiple conditions are met, the Integration Service returns the first m atching result. If the data contains multibyte characters and the DECODE expression compares str ing data, the return value depends on the code page and data movement mode of the Integration Service.
DECODE and Datatypes When you use DECODE, the datatype of the return value is always the same as the datatype of the result with the greatest precision. For example, you have the following expression: The return values in this expression are 5, 1.414213562, and 3.141592654. The fi rst result is an Integer, and the other results are Decimal. The Decimal datatype has greater precision than I nteger. This expression always writes the result as a Decimal. When you run a session in high precision mode, if at least one result is Double, the datatype of the return value is Double. You cannot create a DECODE function with both string and numeric return values. For example, the following expression is invalid: When you validate the expression above, the Designer writes the following error message: Examples You might use DECODE in an expression that searches for a particular ITEM_ID and returns the ITEM_NAME: 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 t op to bottom order for TRUE or FALSE:
Decompresses data using the zlib 1.2.1 compression algorithm. Use the DECOMPRESS function on data that has been compressed with the COMPRESS function or a compression tool that uses t he zlib 1.2.1 algorithm. If the session that decompresses the data uses a different data movement mode than the session that compressed the data, the output of the decompressed data may differ from the original data. Syntax Return Value Decompressed binary value of the input value. NULL if the input is a null value. Example Your organization has an online order service. You received compressed customer order data over a wide area network. You want to read the data using PowerCenter and load the data to a data warehouse. You can decompress each row of data using DECOMPRESS for the row. The Integration Servic e can then load the decompressed data to the target.
Encodes data by converting binary data to string data using Multipurpose Interne t Mail Extensions (MIME) encoding. Encode data when you want to store data in a database or file that doe s not allow binary data. You can also encode data to pass binary data through PowerCenter transformations in string format. The encoded data is approximately 33% longer than the original data. It displays as a set of random characters. Syntax Return Value Encoded value. NULL if the input is a null value. Example You want to read messages from WebSphere MQ and write the data to a flat file ta rget. You want to include the WebSphere MQ message ID as part of the target data. However, the MsgID field is Binary, and the flat file target does not support binary data. Use ENC_BASE64 to encode the MsgID before t he Integration Service writes the data to the target.
Causes the Integration Service to skip a row and issue an error message, which y ou define. The error message displays in the session log. The Integration Service does not write these skippe d rows to the session reject file. Use ERROR in Expression transformations to validate data. Generally, you use ERR OR within an IIF or DECODE function to set rules for skipping rows. 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. Use ERROR for output ports to handle any kind of transformation error, including
ERROR function calls within an expression. When you use the ERROR function in an expression and in th e output port default value, the Integration Service skips the row and logs both the error message from the e xpression and the error message from the default value. If you want to ensure the Integration Service skips rows that produce an error, assign ERROR as the default value. If you use an output default value other than ERROR, the default value overrides the ERROR function in an expression. For example, you use the ERROR function in an expression, and you as sign the default value, 1234 , to the output port. Each time the Integration Service encounters the ERROR f unction in the
expression, it overrides the error with the value 1234 and passes ransformation. It does not skip the row, and it does not log an error in the session log.
For more information about using default values, see the PowerCenter Transformat ion Guide. Syntax Return Value String. Example The following example shows how to reference a mapping that calculates the avera ge salary for employees in all departments of the organization, but skip negative values. The following express ion nests the ERROR function in an IIF expression so that if the Integration Service finds a negative salary in the Salary port, it skips the row and displays an error:
Returns e raised to the specified power (exponent), where e=2.71828183. For exam ple, EXP(2) returns 7.38905609893065. You might use this function to analyze scientific and technica l data rather than business data. EXP is the reciprocal of the LN function, which returns the natural logari thm of a numeric value. Syntax
Return Value Double value. NULL if a value passed as an argument to the function is NULL. Example The following expression uses the values stored in the Numbers port as the expon ent value:
Returns the first value found within a port or group. Optionally, you can apply a filter to limit the rows the Integration Service reads. You can nest only one other aggregate function within FIRST. Syntax Return Value First value in a group. NULL if all values passed to the function are NULL or if no rows are selected (f or example, the filter condition evaluates to FALSE or NULL for all rows). Nulls If a value is NULL, FIRST ignores the row. However, if all values passed from th e port are NULL, FIRST returns NULL. Note: By default, the Integration Service treats null values as NULLs in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when you confi gure the Integration Service, you can choose how you want to handle null values in aggregate functions. You ca n treat null values as 0 in aggregate functions or as NULL.
Group By FIRST groups values based on group by ports you define in the transformation, re turning one result for each group. If there is no group by port, FIRST treats all rows as one group, returning one value. Examples The following expression returns the first value in the ITEM_NAME port with a pr ice greater than $10.00: The following expression returns the first value in the ITEM_NAME port with a pr ice greater than $40.00:
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 funct ion returns 3. Likewise, if you pass -3.17 to FLOOR, the function returns -4. Syntax
Return Value Integer 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. Example The following expression returns the largest integer less than or equal to the v alues in the PRICE port: Tip: You can perform arithmetic on the values you pass to FLOOR. For example, to multiply a numeric value by 10 and then calculate the largest integer that is less than the product, you mig ht write the function as follows:
Returns the future value of an investment, where you make periodic, constant pay ments and the investment earns a constant interest rate. Syntax Return Value Numeric.
Example You deposit $2,000 into an account that earns 9% annual interest compounded mont hly (monthly interest of 9%/12, or 0.75%). You plan to deposit $250 at the beginning of every month for t he next 12 months. The following expression returns $5,337.96 as the account balance at the end of 12 m onths: Notes To calculate interest rate earned in each period, divide the annual rate by the number of payments made in a year. The payment value and present value are negative because these are amounts that you pay.
Returns the specified part of a date as an integer value. Therefore, if you crea te 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. Syntax Return Value Integer representing the specified part of the date. NULL if a value passed to the function is NULL. Examples The following expressions return the hour for each date in the DATE_SHIPPED port . 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' )
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' ) GET_DATE_PART( DATE_SHIPPED, 'DDD' ) GET_DATE_PART( DATE_SHIPPED, 'DY' )
The following expressions return the month for each date in the DATE_SHIPPED por t: GET_DATE_PART( DATE_SHIPPED, 'MM' ) GET_DATE_PART( DATE_SHIPPED, 'MON' )
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' )
Returns the greatest value from a list of input values. Use this function to ret urn the greatest string, date, or number. By default, the match is case sensitive.
Syntax Return Value value1 if it is the greatest of the input values, value2 if it is the greatest o f the input values, and so on. NULL if any of the arguments is null. Example The following expression returns the greatest quantity of items ordered:
Returns one of two values you specify, based on the results of a condition.
Syntax Unlike conditional functions in some systems, the FALSE (value2) condition in th e IIF function is not required. If you omit value2, the function returns the following when the condit ion 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 val ue1 is a string datatype so the Integration Service returns an empty string for each row that evaluates to F ALSE: Return Value value1 if the condition is TRUE. value2 if the condition is FALSE. For example, the following expression includes the FALSE condition NULL so the I ntegration Service returns NULL for each row that evaluates to FALSE: If the data contains multibyte characters and the condition argument compares st ring data, the return value depends on the code page and data movement mode of the Integration Service. IIF and Datatypes When you use IIF, the datatype of the return value is the same as the datatype o f the result with the greatest precision. For example, you have the following expression:
The TRUE result (1) is an integer and the FALSE result (.3333) is a decimal. The Decimal datatype has greater precision than Integer, so the datatype of the return value is always a Decimal. When you run a session in high precision mode and at least one result is Double, the datatype of the return value is Double. Special Uses of IIF Use nested IIF statements to test multiple conditions. The following example tes ts for various conditions and returns 0 if sales is 0 or negative: You can make this logic more readable by adding comments: Use IIF in update strategies. For example: Alternative to IIF Use DECODE instead of IIF in many cases. DECODE may improve readability. The fol lowing shows how you use DECODE instead of IIF using the first example from the previous section: DECODE( TRUE,
You can often use a Filter transformation instead of IIF to maximize session per formance.
Matches input data to a list of values. By default, the match is case sensitive.
Syntax Return Value TRUE (1) if the input value matches the list of values. FALSE (0) if the input value does not match the list of values. NULL if the input is a null value. Example The following expression determines if the input value is a safety knife, chisel point knife, or medium titanium knife. The input values do not have to match the case of the values in the comma -separated list:
Finds the index of a value among a list of values. By default, the match is case sensitive. Syntax
Return Value 1 if the input value matches string1, 2 if the input value matches string2, and so on. 0 if the input value is not found. NULL if the input is a null value. Example The following expression determines if values from the ITEM_NAME port match the first, second, or third string: Safety Knife returns a value of 0 because it does not match the case of the inpu t value.
Capitalizes the first letter in each word of a string and converts all other let ters 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. Syntax
Return Value String. If the data contains multibyte characters, the return value depends on t he code page and data movement mode of the Integration Service. NULL if a value passed to the function is NULL. Example The following expression capitalizes all names in the FIRST_NAME port.
Returns the position of a character set in a string, counting from left to right . Syntax
Return Value Integer if the search is successful. Integer represents the position of the firs t character in the search_value, counting from left to right. 0 if the search is unsuccessful. NULL if a value passed to the function is NULL. Examples The following expression returns the position of the first occurrence of the let ter 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 : The following expression returns the position of the second occurrence of the le tter a , starting at the beginning of each company name. Because the search_value argument is case sensitive, it sk ips the A in Blue Fin Aqua Center , and returns 0:
The following expression returns the position of the second occurrence of the le tter a in each company name, starting from the last character in the company name. Because the search_value a rgument is case sensitive, it skips the A in 'Blue Fin Aqua Center , and returns 0: The following expression returns the position of the first character in the stri ng Blue Fin Aqua Center (starting from the last character in the company name): Using Nested INSTR You can nest the INSTR function within other functions to accomplish more comple x 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 i t: The following expression removes the character '#' from a string:
Syntax Return Value TRUE (1) if the value is NULL. FALSE (0) if the value is not NULL. Example The following example checks for null values in the items table:
Returns whether a string value is a valid date. A valid date is any string in th e date portion of the date time format specified in the session. If the string you want to test is not in this d ate format, use the TO_DATE format string to specify the date format. If the strings passed to IS_DATE do no t 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. 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. Use the RR format string with IS_DATE instead of the YY format string. In most c ases, the two format strings return the same values, but there are some unique cases where YY returns incorre ct 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 Integration Service computes the expression IS_DATE( 0 2/29/00 , RR ) as IS_DATE(02/29/2000 00:00:00), which returns TRUE. In the first case, year 1900 i s not a leap year, so there is no February 29th. Note: IS_DATE uses the same format strings as TO_DATE.
Syntax Return Value TRUE (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. Warning: The format of the IS_DATE string must match the format string, includin g any date separators. If it does not, the Integration Service might return inaccurate values or skip the rec ord.
Examples The following expression checks the INVOICE_DATE port for valid dates: This expression returns data similar to the following: INVOICE_DATE RETURN VALUE NULL NULL '180' 0 (FALSE) '04/01/98' 0 (FALSE) '04/01/1998 00:12:15.7008' 1 (TRUE) '02/31/1998 12:13:55.9204' 0 (FALSE) (February does not have 31 days) 'John Smith' 0 (FALSE)
The following IS_DATE expression specifies a format string of YYYY/MM/DD : If the string value does not match this format, IS_DATE returns FALSE:
INVOICE_DATE RETURN VALUE NULL NULL '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)
The following example shows how you use IS_DATE to test data before using TO_DAT E to convert the strings to dates. This expression checks the values in the INVOICE_DATE port and convert s each valid date to a date value. If the value is not a valid date, the Integration Service returns ERROR a nd skips the row.
This example returns a Date/Time value. Therefore, the output port for the expre ssion needs to be Date/Time:
Returns whether a string is a valid number. A valid number consists of the follo wing parts: .Optional space before the number .Optional sign (+/-) .One or more digits with an optional decimal point .Optional scientific notation, such as the letter e ws) followed by an optional sign (+/-), followed by one or more digits .Optional white space following the number or E (and the letter d or
D on Wi
The following numbers are all valid: ' 100 ' ' +100' '-100' '-3.45e+32' '+3.45E-32' '+3.45d+32' (Windows only) '+3.45D-32' (Windows only)
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. Syntax Return Value
FALSE (0) if the row is not a valid number. NULL if a value in the expression is NULL. Examples The following expression checks the ITEM_PRICE port for valid numbers: 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 c onverts each valid number to a double-precision floating point value. If the value is not a valid number, the Integration Service returns 0.00:
Returns whether a string value consists entirely of spaces. A space is a blank s pace, 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 tes t for an empty string, use LENGTH. Syntax Return Value TRUE (1) if the row consists entirely of spaces. FALSE (0) if the row contains data. NULL if a value in the expression is NULL. Example The following expression checks the y of spaces: Tip: Use IS_SPACES to avoid writing le. For example, if you have a transformation that writes customer target table, you might want to write 00000 instead of spaces. llowing: ITEM_NAME port for rows that consist entirel spaces to a character column in a target tab names to a fixed length CHAR(5) column in a You would create an expression similar to the fo
Returns the last row in the selected port. Optionally, you can apply a filter to limit the rows the Integration Service reads. You can nest only one other aggregate function within LAST. Syntax Return Value Last 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). Note: By default, the Integration Service treats null values as NULLs in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when you confi gure the Integration Service, you can choose how you want to handle null values in aggregate functions. You ca n treat null values as 0 in aggregate functions or as NULL.
Example The following expression returns the last row in the ITEMS_NAME port with a pric e greater than $10.00:
Returns the date of the last day of the month for each date in a port. Syntax Return Value Date. 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. Null If a value is NULL, LAST_DAY ignores the row. However, if all values passed from the port are NULL, LAST_DAY returns NULL. Group By LAST_DAY 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_DAY treats all rows as one group, returning one value. Examples The following expression returns the last day of the month for each date in the ORDER_DATE port: You can nest TO_DATE to convert string values 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 th e time 00:00:00. The following example returns the last day of the month for each order date in t he same format as the string:
Returns the smallest value from a list of input values. By default, the match is case sensitive. Syntax Return Value value1 if it is the smallest of the input values, value2 if it is the smallest o f the input values, and so on. NULL if any of the arguments is null. Example The following expression returns the smallest quantity of items ordered:
Returns the number of characters in a string, including trailing blanks. Syntax Return Value Integer representing the length of the string. NULL if a value passed to the function is NULL. Example The following expression returns the length of each customer name: Tips Use LENGTH to test for empty string conditions. If you want to find fields in wh ich customer name is empty, use an expression such as: To test for a null field, use ISNULL. To test for spaces, use IS_SPACES.
Returns the natural logarithm of a numeric value. For example, LN(3)returns 1.09 8612. You usually use this function to analyze scientific data rather than business data. This function is the reciprocal of the function EXP.
Syntax Return Value Double value. NULL if a value passed to the function is NULL. Example The following expression returns the natural logarithm for all values in the NUM BERS port: Note: The Integration Service displays an error and does not write the row when you pass a negative number or 0. The numeric_value must be a positive number greater than 0.
Returns the logarithm of a numeric value. Most often, you use this function to a nalyze scientific data rather than business data. Syntax
Return Value Double value. NULL if a value passed to the function is NULL. Example The following expression returns the logarithm for all values in the NUMBERS por t: The Integration Service displays an error and does not write the row if you pass a negative number, 0, or 1 as a base value, or if you pass a negative value for the exponent.
Searches for a value in a lookup source column. The LOOKUP function compares data in a lookup source to a value you specify. Whe n the Integration Service finds the search value in the lookup table, it returns the value from a specifie d column in the same row in the lookup table. When you create a session based on a mapping that uses the LOOKUP function, you must specify the database connections for $Source Connection Value and $Target Connection Value in the ses sion properties. To validate a lookup function in an Expression transformation, verify that the lookup defini tion is in the mapping. Note: This function is not supported in mapplets.
Using the Lookup Transformation or the LOOKUP Function Use the Lookup transformation rather than the LOOKUP function to look up values in PowerCenter mappings. If you use the LOOKUP function in a mapping, you need to enable the lookup cachi ng option for 3.5 compatibility in the session properties. This option exists expressly for PowerM art 3.5 users who want to continue using the LOOKUP function, rather than creating Lookup transformations. For more information, see Lookup Transformation in the PowerCenter Transformation 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.
Syntax Return Value Result if all searches find matching values. If the Integration Service finds ma tching values, it returns the result from the same row as the search1 argument. NULL if the search does not find any matching values. Error if the search finds more than one matching value. Example The following expression searches the lookup source :TD.SALES for a specific ite m ID and price, and returns the item name if both searches find a match: Tips When you compare char and varchar values, the LOOKUP function returns a result o nly if the two rows match. This means that both the value and the length for each row must match. If the lo okup source is a padded char value of a specified length and the lookup search is a varchar value, you need t o use the RTRIM function to trim trailing blanks from the lookup source so that the values match the lookup search: Use the :TD reference qualifier in the result and search arguments of a LOOKUP f unction:
Converts uppercase string characters to lowercase. Syntax Return Value Lowercase character string. If the data contains multibyte characters, the retur n value depends on the code page and data movement mode of the Integration Service. NULL if a value in the selected port is NULL. Example The following expression returns all first names to lowercase:
Adds a set of blanks or characters to the beginning of a string to set the strin g to a specified length.
Syntax Return Value String of the specified length. NULL if a value passed to the function is NULL or if length is a negative number . Examples The following expression standardizes numbers to six digits by padding them with leading zeros. LPAD counts the length from left to right. If the first string is longer than th e length, LPAD truncates the string from right to left. For example, LPAD( alphabetical , 5, x ) returns the string lpha . If the second string is longer than the total characters needed to return the sp ecified length, LPAD uses a portion of the second string: The following expression shows how LPAD handles negative values for the length a rgument for each row in the ITEM_NAME port:
Removes blanks or characters from the beginning of a string. You can use LTRIM w ith 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 the expression: .In UNICODE mode, LTRIM removes both single- and double-byte spaces from the beg inning 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 stri ng. If the character in the string matches any character in the trim_set, LTRIM removes it. LTRIM continues compari ng and removing characters until it fails to find a matching character in the trim_set. Then it returns the string, which does not include matching characters. Syntax Return Value String. 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 fun ction returns NULL. Example The following expression removes the characters _NAME port: S and . from the strings in the LAST
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 o f characters you specify in the trim_set argument. If the first character in the string matches the first charac ter in the trim_set, LTRIM removes it. Then LTRIM looks at the second character in the string. If it matches the se cond character in the trim_set, LTRIM removes it, and so on. When the first character in the string does not mat ch 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 a rgument, so LTRIM returns the string in the LAST_NAME port and moves to the next row. Tips Use RTRIM and LTRIM with || or CONCAT to remove leading and trailing blanks afte r you concatenate two strings. You can also remove multiple sets of characters by nesting LTRIM. For example, i f you want to remove leading blanks and the character 'T' from a column of names, you might create an express ion similar to the following:
Returns the date and time based on the input values. Syntax Return Value Date as MM/DD/YYYY HH24:MI:SS. Returns a null value if you do not pass the funct ion a year, month, or day.
Example The following expression creates a date and time from the input ports:
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. You can also use MAX to return the largest numeric value or the highest string v alue in a port or group. Syntax Return Value 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). Example You can return the maximum date for a port or group. The following expression re turns the maximum order date for flashlights:
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. You can a lso use MAX to return the latest date or the highest string value in a port or group. Syntax Return Value Numeric value. NULL if all values passed to the function are NULL or if no rows are selected (f or 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 enable hi gh precision in the session properties to ensure decimal precision up to 28 digits. Nulls If a value is NULL, MAX ignores it. However, if all values passed from the port are NULL, MAX returns NULL. Note: By default, the Integration Service treats null values as NULLs in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when you confi gure the Integration Service, you can choose how you want to handle null values in aggregate functions. You ca n treat null values as 0 in aggregate functions or as NULL.
Group By MAX groups values based on group by ports you define in the transformation, retu rning one result for each group. If there is no group by port, MAX treats all rows as one group, returning one va lue.
Example The first expression returns the maximum price for flashlights:
Returns the highest string value found within a port or group. You can apply a f ilter to limit the rows in the search. You can nest only one other aggregate function within MAX. Note: The MAX function uses the same sort order that the Sorter transformation u ses. However, the MAX function is case sensitive, and the Sorter transformation may not be case sensit ive.
You can also use MAX to return the latest date or the largest numeric value in a port or group. Syntax Return Value String. 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). Nulls If a value is NULL, MAX ignores it. However, if all values passed from the port are NULL, MAX returns NULL. Note: By default, the Integration Service treats null values as NULLs in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when you confi gure the Integration Service,
you can choose how you want to handle null values in aggregate functions. You ca n treat null values as 0 in aggregate functions or as NULL.
Group By MAX groups values based on group by ports you define in the transformation, retu rning one result for each group. If there is no group by port, MAX treats all rows as one group, returning one va lue. Example The following expression returns the maximum item name for manufacturer ID 104:
Calculates the checksum of the input value. The function uses Message-Digest alg orithm 5 (MD5). MD5 is a one-way cryptographic hash function with a 128-bit hash value. You can conclude that input values are different when the checksums of the input values are different. Use MD5 to verif y data integrity. Syntax Return Value Unique 32-character string of hexadecimal digits 0-9 and a-f. NULL if the input is a null value.
Example You want to write changed data to a database. Use MD5 to generate checksum value s for rows of data you read from a source. When you run a session, compare the previously generated checksum values against the new checksum values. Then, write the rows with updated checksum values to the target . You can conclude that an updated checksum value indicates that the data has changed. Tip You can use the return value as a hash key.
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 t he middle two values when all values are placed ordinally on a number line. If there is an odd number of value s in the port, the median is the middle number. You can nest only one other aggregate function within MEDIAN, and the nested fun ction must return a Numeric datatype. The Integration Service reads all rows of data to perform the median calculation . The process of reading rows of data to perform the calculation may affect performance. Optionally, you can appl y a filter to limit the rows you read to calculate the median. Syntax Return Value Numeric 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. Note: If the return value is decimal with precision greater than 15, you can ena ble high precision in the session properties to ensure decimal precision up to 28 digits.
Nulls If a value is NULL, MEDIAN ignores the row. However, if all values passed from t
Note: By default, the Integration Service treats null values as NULLs in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when you confi gure the Integration Service, you can choose how you want to handle null values in aggregate functions. You ca n treat null values as 0 in aggregate functions or as NULL.
Group By MEDIAN groups values based on group by ports you define in the transformation, r eturning one result for each group. If there is no group by port, MEDIAN treats all rows as one group, returning one value. Example To calculate the median salary for all departments, you create an Aggregator tra nsformation grouped by departments with a port specifying the following expression: The following expression returns the median value for orders of stabilizing vest s:
Encodes string values. You can specify the length of the string that you want to encode. METAPHONE encodes characters of the English language alphabet (A-Z). It encodes both uppercase and lowercase letters in uppercase. METAPHONE encodes characters according to the following list of rules: .Skips vowels (A, E, I, O, and U) unless one of them is the first character of t he input string. METAPHONE( CAR ) returns KR and METAPHONE( AAR ) returns AR . .Uses special encoding guidelines.
The following table lists the METAPHONE encoding guidelines: Input Returns Condition Example B - n/a - B - when it follows M - in all other cases - METAPHONE ( Lamb ) returns LM. - METAPHONE ( Box ) returns BKS. C - X - S - n/a - K - when followed by IA or H - when followed by I, E, or Y - when it follows S, and is followed by I, E, or Y - in all other cases - METAPHONE ( Facial ) returns FXL. - METAPHONE ( Fence ) returns FNS. - METAPHONE ( Scene ) returns SN. - METAPHONE ( Cool ) returns KL. D - J - T - when followed by GE, GY, or GI
- in all other cases - METAPHONE ( Dodge ) returns TJ. - METAPHONE ( David ) returns TFT. F - F - in all cases - METAPHONE ( FOX ) returns FKS. G - F - n/a - J - K - when followed by H and the first character in the input string is not B, D, or H - when followed by H and the first character in the input string is B, D, or H - when followed by I, E or Y and does not repeat - in all other cases - METAPHONE ( Tough ) returns TF. - METAPHONE ( Hugh ) returns HF. - METAPHONE ( Magic ) returns MJK. - METAPHONE( GUN ) returns KN. H - H - n/a - when it does not follow C, G, P, S, or T and is followed by A, E, I, or U - in all other cases
- METAPHONE ( DHAT ) returns THT. - METAPHONE ( Chain ) returns XN. J - J - in all cases - METAPHONE ( Jen ) returns JN. K - n/a - K - when it follows C - in all other cases - METAPHONE ( Ckim ) returns KM. - METAPHONE ( Kim ) returns KM. L - L - in all cases - METAPHONE ( Laura ) returns LR. M - M - in all cases - METAPHONE ( Maggi ) returns MK. N - N - in all cases - METAPHONE ( Nancy ) returns NNS. P - F - P - when followed by H
- in all other cases - METAPHONE ( Phone ) returns FN. - METAPHONE ( Pip ) returns PP. Q - K - in all cases - METAPHONE ( Queen ) returns KN. R - R - in all cases - METAPHONE ( Ray ) returns R. S - X - S - when followed by H, IO, IA, or CHW - in all other cases - METAPHONE ( Cash ) returns KX. - METAPHONE ( Sing ) returns SNK. T - X - 0* - n/a - T - when followed by IA or IO - when followed by H - when followed by CH - in all other cases - METAPHONE ( Patio ) returns PX. - METAPHONE ( Thor ) returns 0R. - METAPHONE ( Glitch ) returns KLTX.
- METAPHINE ( Tim ) returns TM. V - F - in all cases - METAPHONE ( Vin ) returns FN. W - W - n/a - when followed by A, E, I, O, or U - in all other cases - METAPHONE ( Wang ) returns WNK. - METAPHONE ( When ) returns HN. X - KS - in all cases - METAPHONE ( Six ) returns SKS. Y - Y - n/a - when followed by A, E, I, O, or U - in all other cases - METAPHONE ( Yang ) returns YNK. - METAPHONE ( Bobby ) returns BB. Z - S - in all cases - METAPHONE ( Zack ) returns SK. *The integer 0.
.Skips the initial character and encodes the remaining string if the first two c haracters of the input string have one of the following values: -KN. For example, METAPHONE( KNOT ) returns -GN. For example, METAPHONE( GNOB ) returns -PN. For example, METAPHONE( PNRX ) returns -AE. For example, METAPHONE( AERL ) returns NT . NB . NRKS . ERL .
.If a character other than C occurs more than once in the input string, encodes th e first occurrence only. For example, METAPHONE( BBOX ) returns BKS and METAPHONE( CCOX ) returns KKKS .
Syntax Return Value String. NULL if one of the following conditions is true: .All values passed to the function are NULL. .No character in string is a letter of the English alphabet. .string is empty.
Examples The following expression encodes the first two characters in EMPLOYEE_NAME port to a string: The following expression encodes the first four characters in EMPLOYEE_NAME port to a string:
Returns the earliest date found in a port or group. You can apply a filter to li mit the rows in the search. You can nest only one other aggregate function within MIN, and the nested function must return a date datatype. You can also use MIN to return the smallest numeric value or the lowest string v alue in a port or group. Syntax Return Value Date 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). Nulls If a single value is NULL, MIN ignores it. However, if all values passed from th e port are NULL, MIN returns NULL. Group By MIN groups values based on group by ports you define in the transformation, retu rning one result for each group. If there is no group by port, MIN treats all rows as one group, returning one va lue. Example The following expression returns the oldest order date for flashlights:
Returns the smallest numeric value found in a port or group. You can apply a fil ter to limit the rows in the search. You can nest only one other aggregate function within MIN, and the neste d function must return a numeric datatype. You can also use MIN to return the latest date or the lowest string value in a p ort or group. Syntax Return Value Numeric 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). Note: If the return value is a decimal with precision greater than 15, you can e nable high precision in the session properties to ensure decimal precision up to 28 digits.
Nulls If a single value is NULL, MIN ignores it. However, if all values passed from th e port are NULL, MIN returns NULL. Note: By default, the Integration Service treats null values as NULLS in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when yo u configure the Integration Service, you can choose how you want to handle null values in aggregate function s. You can treat null values as 0 in aggregate functions or as NULL.
Group By MIN groups values based on group by ports you define in the transformation, retu rning one result for each group. If there is no group by port, MIN treats all rows as one group, returning one va lue. Example The following expression returns the minimum price for flashlights:
Returns the lowest string 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 functi on must return a string datatype. Note: The MIN function uses the same sort order that the Sorter transformation u ses. However, the MIN function is case sensitive, but the Sorter transformation may not be case sensit ive.
You can also use MIN to return the latest date or the minimum numeric value in a port or group. Syntax Return Value String 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). Nulls If a single value is NULL, MIN ignores it. However, if all values passed from th e port are NULL, MIN returns NULL. Note: By default, the Integration Service treats null values as NULLS in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when yo u configure the Integration Service, you can choose how you want to handle null values in aggregate function s. You can treat null values as 0 in aggregate functions or as NULL.
Group By MIN groups values based on group by ports you define in the transformation, retu rning one result for each group. If there is no group by port, MIN treats all rows as one group, returning one va lue. Example The following expression returns the minimum item name for manufacturer ID 104:
Returns the remainder of a division calculation. For example, MOD(8,5) returns 3 . Syntax Return Value Numeric value of the datatype you pass to the function. The remainder of the num eric value divided by the divisor. NULL if a value passed to the function is NULL.
Examples The following expression returns the modulus of the values in the PRICE port div ided by the values in the QTY port: The last row (25, 0) produced an error because you cannot divide by 0. To avoid dividing by 0, you can create an expression similar to the following, which returns the modulus of Price divid ed by Quantity only if the quantity is not 0. If the quantity is 0, the function returns NULL: The last row (25, 0) produced a NULL rather than an error because the IIF functi on replaces NULL with the 0 in the QTY port.
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.
Syntax Return Value Numeric value. NULL if all values passed to the function are NULL or if no rows are selected (f or example, the filter condition evaluates to FALSE or NULL for all rows). Note: If the return value is a decimal with precision greater than 15, you can e nable high precision in the session properties to ensure decimal precision up to 28 digits.
Nulls MOVINGAVG ignores null values when calculating the moving average. However, if a ll values are NULL, the function returns NULL. Example The 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: The function returns the average for a set of five rows: 358 based on rows 1 thr ough 5, 245.8 based on rows 2 through 6, and 243 based on rows 3 through 7.
Returns the sum (row-by-row) of a specified set of rows. Optionally, you can apply a condition to filter rows before calculating the movi ng sum. Syntax Return Value Numeric 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). Note: If the return value is a Decimal with precision greater than 15, you can e nable high precision in the session properties to ensure decimal precision up to 28 digits.
Nulls MOVINGSUM ignores null values when calculating the moving sum. However, if all v alues are NULL, the function returns NULL. Example The 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:
The function returns the sum for a set of five rows: 1790 based on rows 1 throug h 5, 1229 based on rows 2 through 6, and 1215 based on rows 3 through 7.
Returns the number of periods for an investment based on a constant interest rat e and periodic, constant payments. Syntax Return Value Numeric. Example The present value of an investment is $2,000. Each payment is $500 and the futur e value of the investment is $20,000. The following expression returns 9 as the number of periods for which y ou need to make the payments: Notes To calculate interest rate earned in each period, divide the annual rate by the number of payments made in an year. For example, if you make monthly payments at an annual interest rate of 15 percent, the value of the Rate argument is 15% divided by 12. If you make annual payments, the value of the Rat e argument is 15%. The payment value and present value are negative because these are amounts that you pay.
Calculates the value that falls at a given percentile in a group of numbers. You can nest only one other aggregate function within PERCENTILE, and the nested function must return a Numeric dataty pe. The Integration Service reads all rows of data to perform the percentile calcula tion. The process of reading rows to perform the calculation may affect performance. Optionally, you can apply a f ilter to limit the rows you read to calculate the percentile. Syntax Return Value Numeric 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). Note: If the return value is decimal with precision greater than 15, you can ena ble high precision in the session properties to ensure decimal precision up to 28 digits.
Nulls If a value is NULL, PERCENTILE ignores the row. However, if all values in a grou p are NULL, PERCENTILE returns NULL. Note: By default, the Integration Service treats null values as NULLs in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when you confi gure the Integration Service, you can choose how you want to handle null values in aggregate functions. You ca n treat null values as 0 in aggregate functions or as NULL.
Group By PERCENTILE groups values based on group by ports you define in the transformatio n, returning one result for each group. If there is no group by port, PERCENTILE treats all rows as one group, returning one value. Example
ix1+()percentile100---------------------------------------------------= Use the following guidelines for this equation: .x is the number of elements in the group of values for which you are calculatin g 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 th e list. .Otherwise PERCENTILE returns the value of n: nithelementii ()[]ithelementii ()[]+=
The following expression returns the salary that falls at the 75th percentile of salaries greater than $50,000:
Returns the payment for a loan based on constant payments and a constant interes t rate. Syntax
Return Value Numeric. Example The following expression returns -2111.64 as the monthly payment amount of a loa n: Notes To calculate interest rate earned in each period, divide the annual rate by the number of payments made in a year. For example, if you make monthly payments at an annual interest rate of 15 %, the rate is 15%/12. If you make annual payments, the rate is 15%. The payment value is negative because these are amounts that you pay.
Returns a value raised to the exponent you pass to the function. Syntax Return Value Double value. NULL if you pass a null value to the function.
Example The following expression returns the values in the Numbers port raised to the va lues in the Exponent port: The value -3.0 raised to 6 returns the same results as -3.0 raised to 5.5. If th e base is negative, the exponent must be an integer. Otherwise, the Integration Service rounds the exponent to th e nearest integer value.
Example The following expression returns 12,524.43 as the amount you must deposit in the account today to have a future value of $20,000 in one year if you also deposit $500 at the beginning of each period:
Returns a random number between 0 and 1. This is useful for probability scenario s. Syntax Return Value Numeric. For the same seed, the Integration Service generates the same sequence of number s. Example The following expression may return a value of 0.417022004702574:
Syntax Return Value Numeric. Example The following expression returns 0.0077 as the monthly interest rate of a loan: To calculate the annual interest rate of the loan, multiply 0.0077 by 12. The an nual interest rate is 0.0924 or 9.24%.
Extracts subpatterns of a regular expression within an input value. For example, from a regular expression pattern for a full name, you can extract the first name or last name. Note: Use the REG_REPLACE function to replace a character pattern in a string wi th another character pattern.
Syntax
Using perl Compatible Regular Expression Syntax You must use perl compatible regular expression syntax with REG_EXTRACT, REG_MAT CH and REG_REPLACE functions. The following table provides perl compatible regular expression syntax guideline s: Syntax Description . (a period) Matches any one character. [a-z] Matches one instance of a character in lower case. For example, [a-z] matches ab . Use [AZ] to match characters in upper case. \d Matches one instance of any digit from 0-9. \s Matches a whitespace character. \w Matches one alphanumeric character, including underscore (_) () Groups an expression. For example, the parentheses in (\d-\d-\d\d) groups the ex pression \d\d-\d\d, which finds any two numbers followed by a hyphen and any two numbers, as in 12-34. {} Matches the number of characters. For example, \d{3} matches any three numbers, such as 650 or 510. Or, [a-z]{2} matches any two letters, such as CA or NY. ? Matches the preceding character or group of characters zero or one time. For exa mple, \d{3}(-{d{4})? matches any three numbers, which can be followed by a hyphen and any four numbers. * (an asterisk) Matches zero or more instances of the values that follow the asterisk. For examp
le, *0 is any value that precedes a 0. + Matches one or more instances of the values that follow the plus sign. For examp le, \w+ is any value that follows an alphanumeric character.
For example, the following regular expression finds 5-digit U.S.A. zip codes, su ch as 93930, and 9-digit zip codes, such as 93930-5407: \d{5} refers to any five numbers, such as 93930. The parentheses surrounding -\d {4} group this segment of the expression. The hyphen represents the hyphen of a 9-digit zip code, as in 939305407. \d{4} refers to any four numbers, such as 5407. The question mark states that the hyphen and last four di gits are optional or can appear one time. Converting COBOL Syntax to perl Compatible Regular Expression Syntax If you are familiar with COBOL syntax, you can use the following information to write perl compatible regular expressions.
The following table shows examples of COBOL syntax and their perl equivalents: COBOL Syntax perl Syntax Description 9 \d Matches one instance of any digit from 0-9. 9999 \d\d\d\d or \d{4} Matches any four digits from 0-9, as in 1234 or 5936. x [a-z] Matches one instance of a letter. 9xx9 \d[a-z][a-z]\d Matches any number followed by two letters and another number, as in 1ab2.
Converting SQL Syntax to perl Compatible Regular Expression Syntax If you are familiar with SQL syntax, you can use the following information to wr ite perl compatible regular expressions. The following table shows examples of SQL syntax and their perl equivalents: SQL Syntax perl Syntax Description % . * Matches any string.
A% A.* Matches the letter _ . (a period) Matches any one character. A_ A. Matches A followed by any one character, such as AZ. A followed by any string, as in Area.
Return Value Returns the value of the nth subpattern that is part of the input value. The nth subpattern is based on the value you specify for subPatternNum. NULL if the input is a null value or if the pattern is null. Example You might use REG_EXTRACT in an expression to extract last names from a regular expression that matches first name and last name. For example, the following expression returns the last name of a regular expression:
Returns whether a value matches a regular expression pattern. This lets you vali date data patterns, such as IDs, telephone numbers, postal codes, and state names. Note: Use the REG_REPLACE function to replace a character pattern in a string wi th a new character pattern.
Syntax Return Value TRUE if the data matches the pattern. FALSE if the data does not match the pattern. NULL if the input is a null value or if the pattern is NULL. Example You might use REG_MATCH in an expression to validate telephone numbers. For exam ple, the following expression matches a 10-digit telephone number against the pattern and returns a Boolean value based on the match: Tip You can also use REG_MATCH for the following tasks: .To verify that a value matches a pattern. This use is similar to the SQL LIKE f unction. .To verify that values are characters. This use is similar to the SQL IS_CHAR fu nction.
To verify that a value matches a pattern, use a period (.) and an asterisk (*) w ith the REG_MATCH function in an expression. A period matches any one character. An asterisk matches 0 or more instances of values that follow it. For example, use the following expression to find account numbers that begin wit h 1835: To verify that values are characters, use a REG_MATCH function with the regular expression [a-zA-Z]+. a-z matches all lowercase characters. A-Z matches all uppercase characters. The plus sign (+) indicates that there should be at least one character. For example, use the following expression to verify that a list of last names co ntain only characters:
Replaces characters in a string with a another character pattern. By default, RE G_REPLACE searches the input string for the character pattern you specify and replaces all occurrences with t he replacement pattern. You can also indicate the number of occurrences of the pattern you want to replace in th e string. Syntax Return Value String Example The following expression removes additional spaces from the Employee name data f or each row of the Employee_name port:
Replaces characters in a string with a single character or no character. REPLACE CHR searches the input string for the characters you specify and replaces all occurrences of all characters wi th the new character you specify. Syntax Return Value String. Empty string if REPLACECHR removes all characters in InputString. NULL if InputString is NULL. InputString if OldCharSet is NULL or empty. Examples The following expression removes the double quotes from web log data for each ro w in the WEBLOG port:
The following expression removes multiple characters for each row in the WEBLOG port: The following expression changes part of the value of the customer code for each row in the CUSTOMER_CODE port: The following expression changes part of the value of the customer code for each row in the CUSTOMER_CODE port: The following expression changes part of the value of the customer code for each row in the CUSTOMER_CODE port:
The following expression removes multiple numbers for each row in the INPUT port : When you want to use a single quote (') in either OldCharSet or NewChar, you mus t use the CHR function. The single quote is the only character that cannot be used inside a string liter al. The following expression removes multiple characters, including the single quote , for each row in the INPUT port:
Replaces characters in a string with a single character, multiple characters, or no character. REPLACESTR searches the input string for all strings you specify and replaces them with the new string you specify. Syntax
Return Value String. Empty string if REPLACESTR removes all characters in InputString. NULL if InputString is NULL. InputString if all OldString arguments are NULL or empty. Examples The following expression removes the double quotes and two different text string s from web log data for each row in the WEBLOG port: The following expression changes the title for certain values for each row in th e TITLE port: The following expression changes the title for certain values for each row in th e TITLE port:
The following expression shows how the REPLACESTR function replaces multiple Old String arguments for each row in the INPUT port: The following expression shows how the REPLACESTR function replaces multiple Old String arguments for each row in the INPUT port: When you want to use a single quote (') in either OldString or NewString, you mu st use the CHR function. Use both the CHR and CONCAT functions to concatenate a single quote onto a string. T he single quote is the only character that cannot be used inside a string literal. Consider the followi ng example: The return value is: The following expression changes a string that includes the single quote, for ea ch row in the INPUT port:
Syntax REVERSE( string ) Argument Required/ Optional Description string Required Any character value. Value you want to reverse.
Return Value String. Reverse of the input value. Example The following expression reverses the numbers of the customer code:
Rounds one part of a date. You can also use ROUND to round numbers. This function can round the following parts of a date: .Year. Rounds the year portion of a date based on the month. .Month. Rounds the month portion of a date based on the day of the month. .Day. Rounds the day portion of the date based on the time. .Hour. Rounds the hour portion of the date based on the minutes in the hour. .Minute. Rounds the minute portion of the date based on the seconds. .Second. Rounds the second portion of the date based on the milliseconds. .Millisecond. Rounds the millisecond portion of the date based on the microsecon ds.
.Microsecond. Rounds the microsecond portion of the date based on the nanosecond s.
The following table shows the conditions used by the ROUND expression and the re turn values: Condition Expression Return Value Month between January and June, function returns January 1 of the same year and sets time to 00:00:00.000000000. ROUND(4/16/1998 8:24:19, 'YY') 01/01/1998 00:00:00.000000000 Month between July and December, function returns January 1 of next year and sets time to 00:00:00.000000000. ROUND(07/30/1998 2:30:55, 'YY') 01/01/1999 00:00:00.000000000
Day of month between 1 and 15, function returns date to the first day of the input month and sets time to 00:00:00.000000000. ROUND(4/15/1998 8:24:19, 'MM') 4/1/1998 00:00:00.000000000 Day of month between 16 and the last day of the month, function returns the first day of the next month and sets time to 00:00:00.000000000. ROUND(05/22/1998 10:15:29, 'MM') 5/1/1998 00:00:00.000000000 Time between 00:00:00 (12 a.m.) and 11:59:59 a.m., function returns the current date and sets time to 00:00:00.000000000 (12 a.m.). ROUND(06/13/1998 2:30:45, 'DD') 06/13/1998 00:00:00.000000000 Time 12:00:00 (12 p.m.) or later, function rounds the date to the next day and sets time to 00:00:00.000000000 (12 a.m.). ROUND(06/13/1998 22:30:45, 'DD') 06/14/1998 00:00:00.000000000 Minute portion of time between 0 and 29 minutes, function returns the current hour, and sets the minutes, seconds, and subseconds to 0. ROUND(04/01/1998 11:29:35, 'HH') 04/01/1998 11:00:00.000000000 Minute portion of the time 30 or greater, function returns the next hour, and sets the minutes, seconds, and subseconds to 0. ROUND(04/01/1998 13:39:00, 'HH')
04/01/1998 14:00:00.000000000 Time between 0 and 29 seconds, function returns the current minutes, and sets the seconds and subseconds to 0. ROUND(05/22/1998 10:15:29, 'MI') 05/22/1998 10:15:00.000000000 Time between 30 and 59 seconds, function returns the next minute and sets the seconds and subseconds to 0. ROUND(05/22/1998 10:15:30, 'MI') 05/22/1998 10:16:00.000000000 Time between 0 to 499 milliseconds, function returns the current second, and sets the milliseconds to 0. ROUND(05/22/1998 10:15:29.499, 'SS') 05/22/1998 10:15:29.000000000 Time between 500 to 999 milliseconds, function returns the next second, and sets the milliseconds to 0. ROUND(05/22/1998 10:15:29.500, 'SS') 05/22/1998 10:15:30.000000000 Time between 0 and 499 microseconds, function returns the current millisecond, and sets the microseconds to 0. ROUND(05/22/1998 10:15:29.498125, 'MS') 05/22/1998 10:15:29.498000000 Time between 500 to 999 microseconds, function returns the next millisecond, and sets the microseconds to 0. ROUND(05/22/1998
10:15:29.498785, 'MS') 05/22/1998 10:15:29.499000000 Time between 0 and 499 nanoseconds, function returns the current microsecond, and sets the nanoseconds to 0. ROUND(05/22/1998 10:15:29.498125345, 'US') 05/22/1998 10:15:29.498125000 Time between 500 and 999 nanoseconds, function returns the next microsecond, and sets the nanoseconds to 0. ROUND(05/22/1998 10:15:29.498125876, 'US') 05/22/1998 10:15:29.498126000
Syntax Return Value Date 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. Examples The following expressions round the year portion of dates in the DATE_SHIPPED po rt: ROUND( DATE_SHIPPED, 'Y' ) ROUND( DATE_SHIPPED, 'YY' ) ROUND( DATE_SHIPPED, 'YYY' )
The following expressions round the month portion of each date in the DATE_SHIPP ED port: ROUND( DATE_SHIPPED, 'MM' ) ROUND( DATE_SHIPPED, 'MON' )
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' )
The following expressions round the hour portion of each date in the DATE_SHIPPE D port: ROUND( DATE_SHIPPED, 'HH' ) ROUND( DATE_SHIPPED, 'HH12' )
The following expression rounds the minute portion of each date in the DATE_SHIP PED port:
Rounds numbers to a specified number of digits or decimal places. You can also u se ROUND to round dates.
Syntax Return Value Numeric value. If one of the arguments is NULL, ROUND returns NULL. Note: If the return value is a decimal with precision greater than 15, you can e nable high precision in the session properties to ensure decimal precision up to 28 digits.
Examples The following expression returns the values in the Price port rounded to three d ecimal places. You can round digits to the left of the decimal point by passing a negative inte ger in the precision argument: If you pass a decimal value in the precision argument, the Integration Service r ounds it to the nearest integer before evaluating the expression:
If you omit the precision argument, the function rounds to the nearest integer: Tip You can also use ROUND to explicitly set the precision of calculated values and achieve expected results. When the Integration Service runs in low precision mode, it truncates the result of c alculations if the precision of the value exceeds 15 digits. For example, you might want to process the following ex pression in low precision mode: In this case, the Integration Service evaluates the left hand side of the expres sion as 6.999999999999999 because it truncates the result of the first division operation. The Integration Service evaluates the entire expression as FALSE. This may not be the result you expect. To achieve the expected result, use ROUND to round the truncated result of the l eft hand side of the expression to the expected result. The Integration Service evaluates the following expressi on as TRUE:
Converts a string to a specified length by adding blanks or characters to the en d of the string. Syntax
Return Value String of the specified length. NULL if a value passed to the function is NULL or if length is a negative number . Examples The following expression returns the item name with a length of 16 characters, a ppending the string '.' to the end of each item name: RPAD counts the length from left to right. So, if the first string is longer tha n the length, RPAD truncates the string from right to left. For example, RPAD( alphabetical , 5, x ) would return the st ring alpha . RPAD uses a partial part of the second_string when necessary. The following expression returns the item name with a length of 16 characters, a ppending the string *..* to the end of each item name: The following expression shows how RPAD handles negative values for the length a rgument for each row in the ITEM_NAME port:
Removes blanks or characters from the end of a string. If you do not specify a trim_set parameter in the 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 str ing. If the character in the string matches any character in the trim_set, RTRIM removes it. RTRIM continues compari ng and removing characters until it fails to find a matching character in the trim_set. It retur ns the string without the matching characters. Syntax Return Value String. The string values with the specified characters in the trim_set argument removed. NULL if a value passed to the function is NULL. Example The following expression removes the characters ME port: re from the strings in the LAST_NA
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 t rim_set argument. If the last
character in the string matches the first character in the trim_set, RTRIM remov es it. If, however, the last character in the string does not match, RTRIM compares the second character in t he 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 i n the trim_set argument, so RTRIM returns the string 'Nelson' and evaluates the next row. Tips Use RTRIM and LTRIM with || or CONCAT to remove leading and trailing blanks afte r you concatenate two strings. You can also remove multiple sets of characters by nesting RTRIM. For example, i f you want to remove trailing blanks and the character t from the end of each string in a column of names, you m ight create an expression similar to the following:
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. Dec reases 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 Integration Service saves the last curre nt value to the repository. When used with a session that contains multiple partitions, the Integration Service g enerates 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 time you use this session. Use the SETCOUNTVARIABLE function only once for each mapping variable in a pipel ine. The Integration Service processes variable functions as it encounters them in the mapping. The o rder in which the Integration Service encounters variable functions in the mapping may not be the same for eve ry session run. This may cause
inconsistent results when you use the same variable function multiple times in a mapping. Use SETCOUNTVARIABLE with mapping variables with a Count aggregation type. Use SETCOUNTVARIABLE in the following transformations: .Expression .Filter .Router .Update Strategy
The Integration Service does not save the final value of a mapping variable to t he 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 more information about mapping variables, see the PowerCenter Designer Guide . Syntax Return Value The current value of the variable. Example You have a mapping that updates a slowly changing dimension table containing dis tributor 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 inc reases 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 sess ion run is 23. At the end of the session, the Integration Service saves 25 to the repository as t he current value for $$CurrentDistributors. The next time the session runs, the Integration Service e valuates the initial value to $$CurrentDistributors to 25 . The Integration Service saves the same value for $$CurrentDistributors to the re pository for sessions with multiple partitions as for sessions with a single partition.
Sets one part of a Date/Time value to a value you specify. With SET_DATE_PART, y ou can change the following parts of a date: .Year. Change the year by entering a positive integer in the value argument. Use any of the year format strings: Y, YY, YYY, or YYYY to set the year. For example, the following express ion 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 (Januar y=1 and December=12) in the value argument. Use any of the month format strings: MM, MON, MONTH to se t the month. For example, the following expression 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 argum ent. Use any of the month format strings (D, DD, DDD, DY, and DAY) to set the day. For example, the following expression 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. Use any of the hour format strings (HH, HH12, HH24 ) to set the hour. For example, the following expression changes the hour to 14:00:00 (or 2:00:00PM) fo r all dates in the SHIP_DATE port: .Minute. Change the minutes by entering a positive integer between 0 and 59 in t he value argument. Use the MI format string to set the minute. For example, the following expression change s the minute to 25 for all dates in the SHIP_DATE port: .Seconds. Change the seconds by entering a positive integer between 0 and 59 in the value argument. Use the SS format string to set the second. For example, the following expression change s the second to 59 for all dates in the SHIP_DATE port: .Milliseconds. Change the milliseconds by entering a positive integer between 0 and 999 in the value argument. Use the MS format string to set the milliseconds. For example, the fol lowing expression changes the milliseconds to 125 for all dates in the SHIP_DATE port: .Microseconds. Change the microseconds by entering a positive integer between 10 00 and 999999 in the value argument. Use the US format string to set the microseconds. For example, t he following expression changes the microseconds to 12555 for all dates in the SHIP_DATE port: .Nanoseconds. Change the nanoseconds by entering a positive integer between 1000 000 and 999999999 in the value argument. Use the NS format string to set the nanoseconds. For example , the following expression changes the nanoseconds to 12555555 for all dates in the SHIP_DATE port:
Date in the same format as the source date with the specified part changed.
NULL if a value passed to the function is NULL. Examples The following expressions change the hour to 4PM for each date in the DATE_PROMI SED port: SET_DATE_PART( DATE_PROMISED, 'HH', 16 ) SET_DATE_PART( DATE_PROMISED, 'HH12', 16 )
The following expressions change the month to June for the dates in the DATE_PRO MISED port. The Integration Service displays an error when you try to create a date that does no t exist, such as changing March 31 to June 31: SET_DATE_PART( DATE_PROMISED, 'MM', 6 ) SET_DATE_PART( DATE_PROMISED, 'MON', 6 )
The following expressions change the year to 2000 for the dates in the DATE_PROM ISED port: SET_DATE_PART( DATE_PROMISED, 'Y', 2000 ) SET_DATE_PART( DATE_PROMISED, 'YY', 2000 ) SET_DATE_PART( DATE_PROMISED, 'YYY', 2000 )
Tip If you want to change multiple parts of a date at one time, you can nest multipl e 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:
Sets the current value of a mapping variable to the higher of two values: the cu rrent value of the variable or the value you specify. Returns the new current value. The function executes only if a row is marked as insert. SETMAXVARIABLE ignores all other row types and the current value remains unchang ed. At the end of a successful session, the Integration Service saves the final curr ent value to the repository. When used with a session that contains multiple partitions, the Integration Service g enerates different current values for each partition. At the end of the session, it saves the highest current valu e across all partitions to the repository. Unless overridden, it uses the saved value as the initial value of t he variable for the next session run. When used with a string mapping variable, SETMAXVARIABLE returns the higher stri ng based on the sort order selected for the session. Use the SETMAXVARIABLE function only once for each mapping variable in a pipelin e. The Integration Service processes variable functions as it encounters them in the mapping. The o rder in which the Integration Service encounters variable functions in the mapping may not be the same for eve ry session run. This can cause inconsistent results when you use the same variable function multiple times in a mapping. Use SETMAXVARIABLE with mapping variables with a Max aggregation type. Use SETMA XVARIABLE in the following transformations: .Expression .Filter .Router .Update Strategy
The Integration Service does not save the final value of a mapping variable to t he repository when any of the following conditions 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.
Syntax Return Value The higher of two values: the current value of the variable or the value you spe cified. The return value is the new current value of the variable. When value is NULL the Integration Service returns the current value of $$Variab le.
Examples The following expression compares the number of items purchased in each transact ion with a mapping variable $$MaxItems. It sets $$MaxItems to the higher of two values and returns the histo rically 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. At the end of the session, the Integration Service saves 35 to the repository as t he maximum current value for $$MaxItems. The next time the session runs, the Integration Service evaluates th e initial value to $$MaxItems to 35 . If the same session contains three partitions, the Integration Service evaluates $$MaxItems for each partition. Then, it saves the largest value to the repository. For example, the last evalua ted value for $$MaxItems in each partition is as follows: Partition Final Current Value for $$MaxItems Partition 1 35 Partition 2 23 Partition 3 22
Sets the current value of a mapping variable to the lower of two values: the cur rent value of the variable or the value you specify. Returns the new current value. The SETMINVARIABLE function ex ecutes only if a row is marked as insert. SETMINVARIABLE ignores all other row types and the current val ue remains unchanged. At the end of a successful session, the Integration Service saves the final curr ent value to the repository. When
used with a session that contains multiple partitions, the Integration Service g enerates 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 t he variable for the next session run. When used with a string mapping variable, SETMINVARIABLE returns the lower strin g based on the sort order selected for the session. Use the SETMINVARIABLE function only once for each mapping variable in a pipelin e. The Integration Service processes variable functions as it encounters them in the mapping. The o rder in which the Integration Service encounters variable functions in the mapping may not be the same for eve ry session run. This may cause inconsistent results when you use the same variable function multiple times in a mapping. Use SETMINVARIABLE with mapping variables with a Min aggregation type. Use SETMI NVARIABLE in the following transformations: .Expression
The Integration Service does not save the final value of a mapping variable to t he repository when any of the following conditions 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.
Syntax Return Value The lower of two values: the current value of the variable or the value you spec ified. The return value is the new current value of the variable. When value is NULL, the Integration Service returns the current value of $$Varia ble. Example The 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 p rice to the MIN_PRICE port. The initial value of $$MinPrice from the previous session run is 22.50. At the end of the session, the Integration Service saves 22.00 to the repository as the minimum current value for $$MinPrice. The next time the session runs, the Integration Service evaluates th e initial value to $$MinPrice to 22.00.
If the same session contains three partitions, the Integration Service evaluates $$MinPrice for each partition. Then, it saves the smallest value to the repository. For example, the last evalu ated value for $$MinPrice in each partition is as follows: Partition Final Current Value for $$MinPrice Partition 1 22.00 Partition 2 22.50 Partition 3 22.50
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 or update. SETVA RIABLE ignores all other row types and the current value remains unchanged. At the end of a successful session, the Integration Service compares the final c urrent value of the variable to the start value of the variable. Based on the aggregate type of the variable, it sav es a final current value to the repository. Unless overridden, it uses the saved value as the initial value of t he variable for the next session run. Use the SETVARIABLE function only once for each mapping variable in a pipeline. The Integration Service processes variable functions as it encounters them in the mapping. The order in which the Integration Service encounters variable functions in the mapping may not be the same for every sessi on run. This may cause inconsistent results when you use the same variable function multiple times in a mapping. Use SETVARIABLE in the following transformations: .Expression
The Integration Service does not save the final value of a mapping variable to t he repository when any of the following conditions 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.
Syntax
Return Value Current value of the variable. When value is NULL, the Integration Service returns the current value of $$Varia ble. Examples The following expression sets a mapping variable $$Time to the system date at th e time the Integration Service evaluates the row and returns the system date to the SET_$$TIME port: At the end of the session, the Integration Service 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 Integrat ion Service 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: At the end of the session, the Integration Service 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 Integration Service evaluates the initial va lue of $$Timestamp to 10/01/2000 12:40:31.
Syntax Return Value -1 for negative values. 0 for 0. 1 for positive values. NULL if NULL. Example The following expression determines if the SALES port includes any negative valu es:
Returns the sine of a numeric value (expressed in radians). Syntax Return Value Double value. NULL if a value passed to the function is NULL.
Example The following expression converts the values in the Degrees port to radians and then calculates the sine for each radian: You can perform arithmetic on the values passed to SIN before the function calcu lates the sine. For example:
Returns the hyperbolic sine of the numeric value. Syntax Return Value Double value. NULL if a value passed to the function is NULL. Example The following expression returns the hyperbolic sine for the values in the Angle s port:
Tip You can perform arithmetic on the values passed to SINH before the function calc ulates the hyperbolic sine. For example:
Encodes a string value into a four-character string. SOUNDEX works for characters in the English alphabet (A-Z). It uses the first ch aracter of the input string as the first character in the return value and encodes the remaining three unique c onsonants as numbers. SOUNDEX encodes characters according to the following list of rules: .Uses the first character in string as the first character in the return value a nd encodes it in uppercase. For example, both SOUNDEX( John ) and SOUNDEX( john ) return J500 . .Encodes the first three unique consonants following the first character in stri ng and ignores the rest. For example, both SOUNDEX( JohnRB ) and SOUNDEX( JohnRBCD ) return J561 . .Assigns a single code to consonants that sound alike. Table 6-1 lists SOUNDEX encoding guidelines for consonants: Table 6-1. SOUNDEX Encoding Guidelines for Consonants Code Consonant 1 B, P, F, V 2 C, S, G, J, K, Q, X, Z 3 D, T 4 L 5
M, N 6 R
.Skips the characters A, E, I, O, U, H, and W unless one of them is the first ch aracter in string. For example, SOUNDEX( A123 ) returns A000 and SOUNDEX( MAeiouhwC ) returns M000 . .If string produces fewer than four characters, SOUNDEX pads the resulting strin g with zeroes. For example, SOUNDEX( J ) returns J000 . .If string contains a set of consecutive consonants that use the same code liste d in Table 6-1 on page 149, SOUNDEX encodes the first occurrence and skips the remaining occurrences in the set. For example, SOUNDEX( AbbpdMN ) returns A135 . .Skips numbers in string. For example, both SOUNDEX( Joh12n ) and SOUNDEX( 1John ) retur n J500 . .Returns NULL if string is NULL or if all the characters in string are not lette rs of the English alphabet.
Syntax Return Value String. NULL if one of the following conditions is true: .If value passed to the function is NULL. .No character in string is a letter of the English alphabet. .string is empty.
Example The following expression encodes the values in the EMPLOYEE_NAME port:
Returns the square root of a non-negative numeric value. Syntax Return Value Double value.
NULL if a value passed to the function is NULL. Example The following expression returns the square root for the values in the Numbers p ort: The value -100 results in an error during the session, since the function SQRT o nly evaluates positive numeric values. If you pass a negative value or character value, the Integration Service displays a Transformation Evaluation Error and does not write the row. You can perform arithmetic on the values passed to SQRT before the function calc ulates the square root.
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. Syntax Return Value Numeric value. NULL if all values passed to the function are NULL or if no rows are selected (f or example, the filter condition evaluates to FALSE or NULL for all rows). Note: If the return value is decimal with precision greater than 15, you can ena ble high precision in the session properties to ensure decimal precision up to 28 digits.
Nulls If a single value is NULL, STDDEV ignores it. However, if all values are NULL, S TDDEV returns NULL.
Note: By default, the Integration Service treats null values as NULLS in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when yo u configure the Integration Service, you can choose how you want to handle null values in aggregate function s. You can treat null values as 0 in aggregate functions or as NULL.
Group By STDDEV groups values based on group by ports you define in the transformation, r eturning one result for each group. If there is no group by port, STDDEV treats all rows as one group, returning one value. Examples The following expression calculates the standard deviation of all rows greater t han $2000.00 in the TOTAL_SALES port: The function does not include the values 1010.90 and 153.88 in the calculation b ecause the filter_condition specifies sales greater than $2,000. The following expression calculates the standard deviation of all rows in the SA LES port: The return value is 0 because each row contains the same number (no standard dev iation exists). If there is no standard deviation, the return value is 0.
Returns a portion of a string. SUBSTR counts all characters, including blanks, s tarting at the beginning of the string.
Syntax Return Value String. Empty string if you pass a negative or 0 length value. NULL if a value passed to the function is NULL. Examples The following expressions return the area code for each row in the Phone port: The following expressions return the phone number without the area code for each row in the Phone port:
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 r esult of the length argument: You can nest INSTR in the start or length argument to search for a specific stri ng 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: The following expression removes the character '#' from a string: When the length argument is longer than the string, SUBSTR returns all the chara cters from the start position to the end of the string. Consider the following example: The return value is bcd . Compare this result to the following example:
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. Syntax
Return Value Numeric value. NULL if all values passed to the function are NULL or if no rows are selected (f or example, the filter condition evaluates to FALSE or NULL for all rows). Note: If the return value is decimal with precision greater than 15, you can ena ble high precision in the session properties to ensure decimal precision up to 28 digits.
Nulls If a single value is NULL, SUM ignores it. However, if all values passed from th e port are NULL, SUM returns NULL. Note: By default, the Integration Service treats null values as NULLS in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when yo u configure the Integration Service, you can choose how you want to handle null values in aggregate function s. You can treat null values as 0 in aggregate functions or as NULL.
Group By SUM groups values based on group by ports you define in the transformation, retu rning one result for each group. If there is no group by port, SUM treats all rows as one group, returning one va lue. Example The following expression returns the sum of all values greater than 2000 in the Sales port: Tip You can perform arithmetic on the values passed to SUM before the function calcu lates the total. For example:
Returns the current date and time of the node hosting the Integration Service wi
th precision to the nanosecond. The precision to which you display the date and time depends on the platform.
The return value of the function varies depending on how you configure the argum ent: .When you configure the argument of SYSTIMESTAMP as a variable, the Integration Service evaluates the function for each row in the transformation. .When you configure the argument of SYSTIMESTAMP as a constant, the Integration Service evaluates the function once and retains the value for each row in the transformation.
Syntax Return Value Timestamp. Returns date and time to the specified precision. Examples Your organization has an online order service and processes real-time data. You can use the SYSTIMESTAMP function to generate a primary key for each transaction in the target database. Create an Expression transformation with the following ports and values: Port Name Port Type Expression Customer_Name Input n/a Order_Qty Input n/a Time_Counter Variable US Transaction_Id Output SYSTIMESTAMP ( Time_Counter )
At run time, the Integration Service generates the system time to the precision of microseconds for each row: Customer_Name Order_Qty Transaction_Id Vani Deed 14 07/06/2007 18:00:30.701015000 Kalia Crop 3 07/06/2007 18:00:30.701029000 Vani Deed 6 07/06/2007 18:00:30.701039000 Harry Spoon 32 07/06/2007 18:00:30.701048000
Syntax Return Value Double value. NULL if a value passed to the function is NULL. Example The following expression returns the tangent for all values in the Degrees port:
Returns the hyperbolic tangent of the numeric value passed to this function. Syntax Return Value Double value. NULL if a value passed to the function is NULL.
Example The following expression returns the hyperbolic tangent for the values in the An gles port: Tip You can perform arithmetic on the values passed to TANH before the function calc ulates the hyperbolic tangent. For example:
Converts a string or numeric value to a bigint value. TO_BIGINT syntax contains an optional argument that you can choose to round the number to the nearest integer or truncate the decima l portion. TO_BIGINT ignores leading blanks. Syntax Return Value Bigint. NULL if the value passed to the function is NULL. 0 if the value passed to the function contains alphanumeric characters.
Examples The following expressions use values from the port IN_TAX:
Converts dates to character strings. TO_CHAR also converts numeric values to str ings. You can convert the date into any format using the TO_CHAR format strings.
Syntax Return Value String. NULL if a value passed to the function is NULL. Examples The following expression converts the dates in the DATE_PROMISED port to text in the format MON DD YYYY: If you omit the format argument, TO_CHAR returns a string in the date format spe cified in the session, by default, MM/DD/YYYY HH24:MI:SS.US: The following expressions return the day of the week for each date in a port:
The following expression returns the day of the month for each date in a port: The following expression returns the day of the year for each date in a port: The following expressions return the hour of the day for each date in a port: TO_CHAR( DATE_PROMISED, 'HH' )
The following expression converts date values to MJD values expressed as strings : The following expression converts dates to strings in the format MM/DD/YY:
You can also use the format string SSSSS in a TO_CHAR expression. For example, t he following expression converts the dates in the SHIP_DATE port to strings representing the total secon ds since midnight: 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: The following expression returns the week of the month for each date in a port: The following expression returns the week of the year for each date in a port: Tip 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:
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 and provides accuracy up t o 15 digits. If you pass a number with more than 15 digits, TO_CHAR rounds the number to the sixteenth digi t. .Returns decimal notation for numbers in the ranges (-1e16,-1e-16] and [1e-16, 1 e16). TO_CHAR returns scientific notation for numbers outside these ranges.
The following figure shows that when TO_CHAR converts numbers to strings, it ret urns scientific notation for all numbers that fall along the bold line. It returns all other numbers in decim al notation. 881e16-1e16 scientific notationscientificnotationscientificnotation0() -1e-161e-16][ -
Note: The Integration Service converts the values 1e-16 and -1e16 to scientific notation, but returns the values 1e-16 and -1e-16 in decimal notation.
Syntax Return Value String. NULL if a value passed to the function is NULL. Example The following expression converts the values in the SALES port to text:
Converts a character string to a Date/Time datatype. You use the TO_DATE format strings to specify the format of the source strings. 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 form at string. Do not use the YYYY format string. Syntax Return Value Date. 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.000000000. You can map the results of this function to any target column with a datetime datatype. If the target column precision is less than nan oseconds, the Integration Service truncates the datetime value to match the precision of the target column when it writes datetime values to the target. NULL if you pass a null value to this function. Warning: The format of the TO_DATE string must match the format string including any date separators. If it does not, the Integration Service might return inaccurate values or skip the rec ord. For more information about the TO_DATE format string, see Rules and Guidelines on page 33.
Examples The following expression returns date values for the strings in the DATE_PROMISE D port. TO_DATE always returns a date and time. If you pass a string that does not have a time value, t he date returned always includes the time 00:00:00.000000000. If you run a session in the twentieth century, the century will be 19. In this example, the current year on the node running the Integration Service is 1998. T he datetime format for the target column is MON DD YY HH24:MI
SS, so the Integration Service truncates the datetime value to seconds when it writes to the target:
The following expression returns date and time values for the strings in the DAT E_PROMISED port. If you pass a string that does not have a time value, the Integration Service returns a n error. If you run a session in the twentieth century, the century will be 19. The current year on the node running the Integration Service is 1998: The following expression converts strings in the SHIP_DATE_MJD_STRING port to da te values: Because the J format string does not include the time portion of a date, the ret urn values have the time set to 00:00:00.000000000. The following expression converts a string to a four-digit year format. The curr ent year is 1998: The following expression converts a string to a four-digit year format. The curr ent year is 1998: Note: For the second row, RR returns the year 2005 and YY returns the year 1905.
The following expression converts a string to a four-digit year format. The curr ent year is 1998:
The following expression converts a string to a four-digit year format. The curr ent year is 1998: The following expression converts strings that includes the seconds since midnig ht to date values: If the target accepts different date formats, use TO_DATE and IS_DATE with the D ECODE function to test for acceptable formats. For example: 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:
Converts a string or numeric value to a decimal value. TO_DECIMAL ignores leadin g blanks. Syntax
Return Value If the string contains a non-numeric character, converts the numeric portion of the string up to the first nonnumeric character. If the first numeric character is non-numeric, returns 0. Decimal of precision and scale between 0 and 28, inclusive. NULL if a value passed to the function is NULL. Note: If the return value is decimal with precision greater than 15, you can ena ble high precision in the session properties to ensure decimal precision up to 28 digits.
Example This expression uses values from the port IN_TAX. The datatype is decimal with p recision of 10 and scale of 3:
Converts a string or numeric value to a double-precision floating point number ( the Double datatype). TO_FLOAT ignores leading blanks. Syntax Return Value Double value. 0 if the value in the port is blank or a non-numeric character. NULL if a value passed to this function is NULL. Example This expression uses values from the port IN_TAX:
Converts a string or numeric value to an integer. TO_INTEGER syntax contains an optional argument that you can choose to round the number to the nearest integer or truncate the decima l portion. TO_INTEGER ignores leading blanks. Syntax Return Value Integer. NULL if the value passed to the function is NULL. 0 if the value passed to the function contains alphanumeric characters. Examples The following expressions use values from the port IN_TAX. The Integration Servi ce displays an error when the conversion causes a numeric overflow:
Truncates dates to a specific year, month, day, hour, minute, second, millisecon d, or microsecond. 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.000000000. For example, the following expression returns 1/1/199 7 00:00:00.000000000: .Month. If you truncate the month portion of a date, the function returns the fi rst day of the month with the time set to 00:00:00.000000000. For example, the following expression returns 4/ 1/1997 00:00:00.000000000: .Day. If you truncate the day portion of a date, the function returns the date w ith the time set to 00:00:00.000000000. For example, the following expression returns 6/13/1997 00:0 0:00.000000000: .Hour. If you truncate the hour portion of a date, the function returns the date with the minutes, seconds, and subseconds set to 0. For example, the following expression returns 4/1/1997 11:00:00.000000000: .Minute. If you truncate the minute portion of a date, the function returns the date with the seconds and subseconds set to 0. For example, the following expression returns 5/22/1997 10: 15:00.000000000:
.Second. If you truncate the second portion of a date, the function returns the date with the milliseconds set to 0. For example, the following expression returns 5/22/1997 10:15:29.000000000 : .Millisecond. If you truncate the millisecond portion of a date, the function re turns the date with the microseconds set to 0. For example, the following expression returns 5/22/1997 1 0:15:30.135000000: .Microsecond. If you truncate the microsecond portion of a date, the function re turns the date with the nanoseconds set to 0. For example, the following expression returns 5/22/1997 10 :15:30.135235000: TRUNC(5/22/1997 10:15:29.135235478, 'US')
Syntax Return Value Date. NULL if a value passed to the function is NULL. Examples The 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' )
The following expressions truncate the month portion of each date in the DATE_SH IPPED port: TRUNC( DATE_SHIPPED, 'MM' ) TRUNC( DATE_SHIPPED, 'MON' )
The following expressions truncate the day portion of each date in the DATE_SHIP PED port: TRUNC( DATE_SHIPPED, 'D' ) TRUNC( DATE_SHIPPED, 'DD' ) TRUNC( DATE_SHIPPED, 'DDD' ) TRUNC( DATE_SHIPPED, 'DY' )
The following expressions truncate the hour portion of each date in the DATE_SHI PPED port: The following expression truncates the minute portion of each date in the DATE_S HIPPED port:
Truncates numbers to a specific digit. You can also use TRUNC to truncate dates .
Syntax 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 digit s to the left of the decimal point to zeros. If you omit the precision argument, TRUNC truncates the decimal portio n of numeric_value and returns an integer. If you pass a decimal precision value, the Integration Service rounds numeric_va lue to the nearest integer before evaluating the expression. Return Value Numeric value. NULL if one of the arguments is NULL. Note: If the return value is decimal with precision greater than 15, you can ena ble high precision in the session properties to ensure decimal precision up to 28 digits.
Examples The following expressions truncate the values in the Price port:
Converts lowercase string characters to uppercase. Syntax Return Value Uppercase string. If the data contains multibyte characters, the return value de pends on the code page and data movement mode of the Integration Service. NULL if a value passed to the function is NULL. Example The following expression changes all names in the FIRST_NAME port to uppercase:
Returns the variance of a value you pass to it. VARIANCE is used to analyze stat istical data. You can nest only one other aggregate function within VARIANCE, and the nested function must retur n a Numeric datatype.
Syntax Formula The function uses the following formula to calculate the variance:
Use the following guidelines for this formula: .xi is one of the numeric values. .n is the number of elements in the set of numeric values. If n is 1, the varian ce is 0.
Return Value Double value. NULL if all values passed to the function are NULL or if no rows are selected (f or example, the filter_condition evaluates to FALSE or NULL for all rows). Nulls If 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. Note: By default, the Integration Service treats null values as NULLs in aggrega te functions. If you pass an entire port or group of null values, the function returns NULL. However, when you confi gure the Integration Service, you can choose how you want to handle null values in aggregate functions. You ca n treat null values as 0 in aggregate functions or as NULL.
Group By VARIANCE 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, VARIANCE treats all rows as one group, returnin g one value. Example The following expression calculates the variance of all rows in the TOTAL_SALES port:
CHAPTER 7 Creating Custom Functions This chapter includes the following topics: .Overview, 177 .Step 1. Get Repository ID Attributes, 178 .Step 2. Create a Header File, 179 .Step 3. Create an Implementation File, 180 .Step 4. Build the Modules, 187 .Step 5. Create the Repository Plug-in File, 189 .Step 6. Test Custom Functions, 191 .Installing Custom Functions, 193 .Creating Expressions with Custom Functions, 193
Overview Custom functions extend the library of PowerCenter functions. They are functions you create to use in transformation and workflow expressions. You create custom functions outside of PowerCenter with the Custom Functions API . The Custom Functions API uses the C programming language. You can share custom functions with others. Users can add the functions to their repository and use them like a PowerCenter transformation lan guage function. This chapter includes a sample function that demonstrates how to create and use a custom function. The steps in this chapter create the ECHO function. This function takes an argument as inp ut and returns the input value to the user. The sample code for the ECHO function is in the server\sample s\exprsdk\echo directory. You can also view a more complex sample custom function. The SampleLoanPayment c ustom function contains functions that are not available using C. SampleLoanPayment is in the server\sam ples\exprsdk\loanpayment directory. Steps to Create Custom Functions Complete the following steps to create custom functions: 1.Get repository ID attributes. Get repository ID attributes to include in the r epository plug-in. For more information, see Step 1. Get Repository ID Attributes on page 178. 2.Create the header file. Define one or more custom functions in the header file . For more information, see
on page
3.Create the implementation file. Define one or more custom functions in the imp lementation file. For more information, see Step 3. Create an Implementation File on page 180. 4.Build the modules. Build modules to create DLLs and shared libraries. For more information, see Step 4. Build the Modules on page 187. 5.Create the repository plug-in file. Define metadata for custom functions. For more information, see Step 5. Create the Repository Plug-in File on page 189. 6.Test the custom functions. Install custom functions and use them in a mapping and workflow for verification. For more information, see Step 6. Test Custom Functions on page 191.
Installing Custom Functions To use custom functions, you must add the functions to the PowerCenter environme nt. . Installing Custom Functions on page 193
Step 1. Get Repository ID Attributes Before you develop a custom function, you must determine the repository ID attri butes for the custom function repository plug-in. Use the repository ID attributes to identify the plug-in whe n you define the plug-in metadata. To get repository ID attributes, perform one of the following tasks: .If you are distributing custom functions outside your organization, contact Inf ormatica. Informatica assigns each plug-in with unique repository ID attributes. Repository ID attribu tes are invalid if they conflict with those of another vendor. To obtain repository ID attributes, email Informatica at [email protected]. .If you only using custom functions within your organization, define repository ID attributes without contacting Informatica. If you develop a plug-in for your organization that will be used with other plug-ins in PowerCenter, assign unique values to the repository ID attributes for each pl ug-in.
The following table shows the XML attributes that require unique values to defin e a plug-in: Repository ID Attribute Description Plugin ID Identifies the ID of the plug-in. This value corresponds to the ID attribute for the PLUGIN element. For more information about the PLUGINID attribute, see The PLUGIN Element on page 189. Vendor ID Identifies the vendor that develops the plug-in. This value corresponds to the VENDORID attribute for the PLUGIN element. For more information about the VENDORID attribute, see The PLUGIN Element on page 189. Function Group ID Identifies the ID for the function group. This value corresponds to the ID attri bute for the FUNCTION_GROUP element. For more information about the FUNCTIONGROUPID attribute, see The FUNCTION_GROUP Element on page 189. Function ID Identifies the ID of the function. This value corresponds to the ID attribute fo r FUNCTION element. For more information about the FUNCTION attribute, see The FUNCTION Element on page 190.
Note: Repository ID attributes are invalid if they conflict with each other.
Step 2. Create a Header File Create a header file using C to declare all functions. Use one header file for o ne or more custom functions. The following example shows the echo.h header file for the ECHO custom function: #ifndef __ECHO_PLUGIN_HPP #define __ECHO_PLUGIN_HPP #if defined(WIN32) #if defined SAMPLE_EXPR_EXPORTS #define SAMPLE_EXPR_SPEC __declspec(dllexport) #else #define SAMPLE_EXPR_SPEC __declspec(dllimport) #endif #else #define SAMPLE_EXPR_SPEC #endif // method to get description of Echo function extern "C" SAMPLE_EXPR_SPEC IUNICHAR * getDescriptionEcho(IUNICHAR* ns, IUNICHAR * sFuncName); // method to get prototype of Echo function extern "C" SAMPLE_EXPR_SPEC IUNICHAR * getPrototypeEcho(IUNICHAR* ns, IUNICHAR* sFuncName); // method to validate usage of Echo function extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS validateFunctionEcho(IUNICHAR* ns, IUNICHAR* sFuncName, IUINT32 numArgs, INFA_EXPR_OPD_METADATA** inputArgList, INFA_EXPR_OPD_METADATA* retValue); // method to process row for Echo function extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_ROWSTATUS processRowEcho(INFA_EXPR_FUNCTIO N_INSTANCE_HANDLE *fnInstance, IUNICHAR **errMsg); // method to do module level initialization for Echo function extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS moduleInitEcho(INFA_EXPR_MODULE_HAN DLE *modHandle); // method to do module level deinitialization for Echo function
extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS moduleDeinitEcho(INFA_EXPR_MODULE_H ANDLE *modHandle); // method to do function level initialization for Echo function extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS functionInitEcho(INFA_EXPR_FUNCTION _HANDLE *funHandle); // method to do function level deinitialization for Echo function extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS functionDeinitEcho(INFA_EXPR_FUNCTI ON_HANDLE *funHandle); // method to do function instance level initialization for Echo function extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS functionInstInitEcho(INFA_EXPR_FUNC TION_INSTANCE_HANDLE *funInstHandle); // method to do function instance level deinitialization for Echo function extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS functionInstDeinitEcho(INFA_EXPR_FU NCTION_INSTANCE_HANDLE *funInstHandle); /** These are all plugin callbacks, which have been implemented to get various modu le, function level interfaces */ // method to get plugin version extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_GetPluginVersion(INFA_VER SION* sdkVersion, INFA_VERSION* pluginVersion); // method to delete the string allocated by this plugin. used for deleting the e rror // messages extern "C" SAMPLE_EXPR_SPEC void INFA_EXPR_DestroyString(IUNICHAR *); // method to get validation interfaces extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_ValidateGetUserInterface( IUNICHAR* ns, IUNICHAR* sFuncName, INFA_EXPR_VALIDATE_METHODS* functions); // method to get module interfaces extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_ModuleGetUserInterface(IN FA_EXPR_LIB_METHODS* functions); // method to get function interfaces
extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_FunctionGetUserInterface( IUNICHAR* nameSpaceName, IUNICHAR* functionName, INFA_EXPR_FUNCTION_METHODS* functions); // method to get function instance interfaces extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_FunctionInstanceGetUserIn terface(IUNICHAR* nameSpaceName, IUNICHAR* functionName, INFA_EXPR_FUNCTION_INSTANCE_METHODS* func tions);
Step 3. Create an Implementation File The implementation file contains the definitions of the functions you use to cre ate a custom function. Create an implementation file using C. You can use one implementation file for one or m ore custom functions. You can also use one implementation file to define both the validation and runtime f unctions of a custom function. The following example shows the echo.c implementation file for the ECHO custom f unction: /*************************************************************************** * * Copyright (c) 2005 Informatica Corporation. This file contains * material proprietary to Informatica Corporation and may not be copied * or distributed in any form without the written permission of Informatica * Corporation. * ***************************************************************************/ /*************************************************************************** * ECHO function Procedure File * * This file contains code that creates the ECHO function, which the * Integration Service calls during a workflow. ***************************************************************************/ /* Informatica ECHO function example developed using the Custom Function * API.
* Filename: Echo.c * An example of a custom function developed using PowerCenter 8.0 * * The purpose of the ECHO function is to return the input value to the user. * */ /*************************************************************************** Includes
***************************************************************************/ #include <stdio.h> #include <string.h> #include "sdkexpr/exprsdk.h" #define SAMPLE_EXPR_EXPORTS #include "SampleExprPlugin.hpp" static IUNICHAR ECHO_STR[80]; /*************************************************************************** Functions ***************************************************************************/ /*************************************************************************** Function: INFA_EXPR_GetPluginVersion Description: Defines the version of the plug-in. It must be the same as the Custom Function API version. Returns ISUCCESS if the plug-in version matches the Custom Function API version. Otherwise, returns IFAILURE. Input: sdkVersion - Current version of the Custom Function API. Output: pluginVersion - Set the version of the plug-in. Remarks: Custom Function API checks for compatibility between itself and the plug-in version. ***************************************************************************/
extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_GetPluginVersion(INFA_VERSION* sdkVersion, INFA_VERS ION* pluginVersion) { pluginVersion->m_major = 1; pluginVersion->m_minor = 0; pluginVersion->m_patch = 0; INFA_EXPR_STATUS retStatus; retStatus.status = ISUCCESS;
Description: Destroys all strings the plug-in returns. For example, it destroys error messages or the return value of other function calls, such as getFunctionDescription. Returns no value. Input: The pointer to the allocated string. Output: N/A Remarks: Frees the memory to avoid issues with multiple heaps. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC void INFA_EXPR_DestroyString(IUNICHAR *strToDelete) { delete [] strToDelete; } /*************************************************************************** Function: INFA_EXPR_ValidateGetUserInterface Description: Returns function pointers to the validation functions. Returns ISUCCESS when the plug-in implemented the function. Returns IFAILURE when the plug-in did not implement the function or another error occurred. Input: Namespace and name of function. Output: Functions. The plug-in needs to set various function pointers. Remarks: Check the namespace and function name for validaity. Set the various function pointers appropriately. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_ValidateGetUserInterface(IUNICHAR* ns, IUNICHAR* sFu ncName, INFA_EXPR_VALIDATE_METHODS* functions) { INFA_EXPR_STATUS retStatus; retStatus.errMsg = NULL; // check function name is not null if (!sFuncName)
{ retStatus.status = IFAILURE; return retStatus; } // set the appropriate function pointers functions->validateFunction = validateFunctionEcho; functions->getFunctionDescription = getDescriptionEcho; functions->getFunctionPrototype = getPrototypeEcho; retStatus.status = ISUCCESS; return retStatus; } /*************************************************************************** Function: INFA_EXPR_ModuleGetUserInterface Description: Sets the function pointers for module-level interaction. Returns ISUCCESS when functions pointers are set appropriately. Otherwise, returns IFAILURE. Input: N/A Output: Functions. The plug-in needs to set various function pointers. Remarks: Set the module init/deinit function pointers. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_ModuleGetUserInterface(INFA_EXPR_LIB_METHODS* functi ons) { functions->module_init = moduleInitEcho; functions->module_deinit = moduleDeinitEcho; INFA_EXPR_STATUS retStatus; retStatus.status = ISUCCESS; retStatus.errMsg = NULL; return retStatus; }
/*************************************************************************** Function: INFA_EXPR_FunctionGetUserInterface Description: Sets the function pointers for function-level interaction. PowerCenter calls this function for every custom function this library implements. Returns ISUCCESS when The plugin implements this function and sets the function pointers correctly. Otherwise, returns IFAILURE. Input: Namespace and name of function. Output: Functions. The plug-in needs to set function pointers for function init/deinit.
Remarks: Set the function init/deinit function pointers. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_FunctionGetUserInterface(IUNICHAR* nameSpaceName, IUNICHAR* functionName, INFA_EXPR_FUNCTION_METHODS* functions) { functions->function_init = functionInitEcho; functions->function_deinit = functionDeinitEcho; INFA_EXPR_STATUS retStatus; retStatus.status = ISUCCESS; retStatus.errMsg = NULL; return retStatus; } /*************************************************************************** Function: INFA_EXPR_FunctionInstanceGetUserInterface Description: Sets the function pointers for function instance-level interaction. PowerCenter calls this function for every custom function this library implements. Returns ISUCCESS when The plugin implements this function and sets the function pointers correctly. Otherwise, returns IFAILURE. Input: Namespace and name of function. Output: Functions. The plug-in needs to set function pointers for instance init/deinit/processrow. Remarks: Set the function instance init/deinit/processrow function pointers. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS INFA_EXPR_FunctionInstanceGetUserInterface(IUNICHAR* nameSpace Name, IUNICHAR* functionName,
INFA_EXPR_FUNCTION_INSTANCE_METHODS* functions) { functions->fnInstance_init = functionInstInitEcho; functions->fnInstance_processRow = processRowEcho; functions->fnInstance_deinit = functionInstDeinitEcho; INFA_EXPR_STATUS retStatus; retStatus.status = ISUCCESS; retStatus.errMsg = NULL; return retStatus; } /*************************************************************************** Function: INFA_EXPR_getDescriptionEcho Description: Gets the description of the ECHO function. It calls destroyString to delete the arguments from memory when usage is complete. The return value must be a null-terminated string.
Input: Namespace and name of function. Output: Description of the function. Remarks: Returns the description of function. The Custom Functions API calls destroy string to free the allocated memory. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC IUNICHAR * getDescriptionEcho(IUNICHAR* ns, IUNICHAR* sFuncName) { static IUNICHAR *uniDesc = NULL; const char *description = "Echoes the input"; if (uniDesc) return uniDesc; int i, len; len = strlen(description);
uniDesc = new IUNICHAR[2*len+2]; for (i=0; i<len; i++) { uniDesc[i] = description[i]; } uniDesc[i] = 0; return uniDesc; } /*************************************************************************** Function: INFA_EXPR_getPrototypeEcho Description: Gets the arguments of the ECHO function in the Expression Editor. It calls destroyString to delete the arguments from memory when usage is complete. The return value must be a null-terminated string. The
function returns NULL if there is no value for the arguments. Input: Namespace and name of the function. Output: Prototype of the function Remarks: Returns the prototype of function. The Custom Functions API calls destroy string to free the allocated memory. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC IUNICHAR * getPrototypeEcho(IUNICHAR* ns, IUNICHAR* sFuncName) { static IUNICHAR *uniProt = NULL; const char *prototype = "Echo(x), where x can be any type, returns x"; if (uniProt) return uniProt; int i, len; len = strlen(prototype); uniProt = new IUNICHAR[2*len+2]; for (i=0; i<len; i++) { uniProt[i] = prototype[i]; } uniProt[i] = 0; return uniProt; } /*************************************************************************** Function: validateFunctionEcho Description: Validates the arguments in the ECHO function. Provides the name, datatype, precision, and scale of the arguments in the ECHO function. Provides the datatype of the return value of the ECHO function. PowerCenter calls this function once for each instance of the ECHO function used in a mapping or workflow. Returns ISUCCESS when function usage is valid as per
the syntax. The ECHO function takes exactly one argument of any datatype. The return datatype is the same as the input datatype, because the function echoes the input. Otherwise, returns IFAILURE. Input: Namespace and name of the function, the number of arguments being passed, and the metadata (datatype, scale, precision) of each argument. Output: retValue. Set the metadata for return type. Remarks: Called by the Custom Functions API to validate the usage of the function and the input argument metadata to be passed. The plug-in needs to verify the number of arguments for this function, the expected metadata for each argument, etc. The plug-in can optionally change the expected datatype of the input arguments. The plug-in needs to set the return type metadata. The plugin can specify if the return value of this function is constant, depending on whether or not all input arguments are constant. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS validateFunctionEcho(IUNICHAR* ns, IUNICHAR* sFuncName, IUINT32 numArgs, INFA_EXPR_OPD_METADATA** inputArgList, INFA_EXPR_OPD_METADATA* retValue) { INFA_EXPR_STATUS exprStatus; // Check number of arguments. if (numArgs != 1) { static const char *err = "Echo function takes one argument."; IUNICHAR *errMsg = NULL; unsigned int len = strlen(err); errMsg = new IUNICHAR[2*len+2]; unsigned int i;
for (i=0; i<len; i++) { errMsg[i] = err[i]; } errMsg[i] = 0; exprStatus.status = IFAILURE; exprStatus.errMsg = errMsg; return exprStatus; } // This is an echo function. // It returns the input value.
retValue->datatype = inputArgList[0]->datatype; retValue->precision = inputArgList[0]->precision; retValue->scale = inputArgList[0]->scale; // If the input value is constant, // the return value is also constant. if (inputArgList[0]->isValueConstant) retValue->isValueConstant = ITRUE; else retValue->isValueConstant = IFALSE; exprStatus.status = ISUCCESS; return exprStatus; } /*************************************************************************** Function: processRowEcho Description: Called when an input row is available to an ECHO function instance. The data for the input arguments of the ECHO function is bound and accessed through fnInstance-inputOPDHandles. Set the data, length, and indicator for the output and return ports in fnInstance->retHandle. PowerCenter calls the function-level initialization function before calling this function. Returns INFA_ROWSUCCESS when the function successfully processes the row of data. Returns INFA_ROWERROR when the function encounters an error for the row of data. The Integration Service increments the internal error count. Only returns this value when the data access mode is row. Returns INFA_FATALERROR when the function encounters a fatal error for the row of data or the block of data. The Integration Service fails the session. Input: Function instance handle, which has the input data. Output: return value Remarks: The plug-in needs to get various input arguments from the function instance handle, perform calculations, and set the return value.
***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_ROWSTATUS processRowEcho(INFA_EXPR_FUNCTION_INSTANCE_HANDLE *fnInstan ce, IUNICHAR **errMsg) { INFA_EXPR_OPD_RUNTIME_HANDLE* arg1 = fnInstance->inputOPDHandles[0]; INFA_EXPR_OPD_RUNTIME_HANDLE* retHandle = fnInstance->retHandle; // Check if the input argument has a null indicator. // If yes, the return value is also null. if (INFA_EXPR_GetIndicator(arg1) == INFA_EXPR_NULL_DATA) { INFA_EXPR_SetIndicator(retHandle, INFA_EXPR_NULL_DATA); return INFA_EXPR_SUCCESS; } short sval; long lval; int ival; char *strval; IUNICHAR *ustrval; void *rawval; float fval; double dval; INFA_EXPR_DATE *infaDate = NULL; int len; // Depending on the datatype, // get the input argument // and set the same value in the return value. // Also, set the same indicator. switch (arg1->pOPDMetadata->datatype) {
case eCTYPE_SHORT: sval = INFA_EXPR_GetShort(arg1); INFA_EXPR_SetShort(retHandle, sval); INFA_EXPR_SetIndicator(retHandle, INFA_EXPR_GetIndicator(arg1)); break; case eCTYPE_LONG: case eCTYPE_LONG64: lval = INFA_EXPR_GetLong(arg1); INFA_EXPR_SetLong(retHandle, lval); INFA_EXPR_SetIndicator(retHandle, INFA_EXPR_GetIndicator(arg1)); break; case eCTYPE_INT32: ival = INFA_EXPR_GetInt(arg1);
case eCTYPE_CHAR: strval = INFA_EXPR_GetString(arg1); len = INFA_EXPR_GetLength(arg1); strcpy((char *)retHandle->pUserDefinedPtr, strval); INFA_EXPR_SetString(retHandle, retHandle->pUserDefinedPtr); INFA_EXPR_SetLength(retHandle, INFA_EXPR_GetLength(arg1)); INFA_EXPR_SetIndicator(retHandle, INFA_EXPR_GetIndicator(arg1)); break; case eCTYPE_RAW: rawval = INFA_EXPR_GetRaw(arg1); len = INFA_EXPR_GetLength(arg1); memcpy(retHandle->pUserDefinedPtr, rawval, len); INFA_EXPR_SetRaw(retHandle, retHandle->pUserDefinedPtr); INFA_EXPR_SetLength(retHandle, len); INFA_EXPR_SetIndicator(retHandle, INFA_EXPR_GetIndicator(arg1)); break; case eCTYPE_UNICHAR: ustrval = INFA_EXPR_GetUniString(arg1); len = INFA_EXPR_GetLength(arg1); memcpy(retHandle->pUserDefinedPtr, ustrval, 2*(len+1)); INFA_EXPR_SetUniString(retHandle, retHandle->pUserDefinedPtr); INFA_EXPR_SetLength(retHandle, len); INFA_EXPR_SetIndicator(retHandle, INFA_EXPR_GetIndicator(arg1)); break; case eCTYPE_TIME: infaDate = INFA_EXPR_GetDate(arg1);
*((INFA_EXPR_DATE *)retHandle->pUserDefinedPtr) = *infaDate; INFA_EXPR_SetDate(retHandle, retHandle->pUserDefinedPtr); INFA_EXPR_SetIndicator(retHandle, INFA_EXPR_GetIndicator(arg1)); break; case eCTYPE_FLOAT: fval = INFA_EXPR_GetFloat(arg1); INFA_EXPR_SetFloat(retHandle, fval); INFA_EXPR_SetIndicator(retHandle, INFA_EXPR_GetIndicator(arg1)); break; case eCTYPE_DOUBLE: dval = INFA_EXPR_GetDouble(arg1); INFA_EXPR_SetDouble(retHandle, dval); INFA_EXPR_SetIndicator(retHandle, INFA_EXPR_GetIndicator(arg1)); break; default: return INFA_EXPR_ROWERROR; break; } return INFA_EXPR_SUCCESS; } /*************************************************************************** Function: moduleInitEcho Description: Called once for each module to initialize any global data structure in the function. Called before calling any function-level functions. Returns ISUCCESS when module initialization is successful. Otherwise, returns IFAILURE. Input: module handle Output: status Remarks: The plug-in can optionally implement this method for one-time initialization.
***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS moduleInitEcho(INFA_EXPR_MODULE_HANDLE *modHandle) { INFA_EXPR_STATUS exprStatus; // initialize the ECHO_STR const char *fnName = "Echo"; int len = strlen(fnName); int i; for (i=0;i<len;i++) ECHO_STR[i] = fnName[i]; exprStatus.status = ISUCCESS; return exprStatus; }
/*************************************************************************** Function: moduleDeinitEcho Description: Called once for each module to deinitialize any data structure in this function. Called after all function-level interactions are complete. Returns ISUCCESS when module deinitialization is successful. Otherwise, returns IFAILURE. Input: module handle Output: status Remarks: The plug-in can optionally implement this method for one-time deinitialization. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS moduleDeinitEcho(INFA_EXPR_MODULE_HANDLE *modHandle) { INFA_EXPR_STATUS exprStatus; exprStatus.status = ISUCCESS; return exprStatus; } /*************************************************************************** Function: functionInitEcho Description: Called once for each custom function to initialize any structure related to the custom function. Module-level initialization function is called before this function. Returns ISUCCESS when function init is successful. Otherwise, returns IFAILURE. Input: function handle Output: status Remarks: The plug-in can optionally implement this method for one-time function initialization. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC
INFA_EXPR_STATUS functionInitEcho(INFA_EXPR_FUNCTION_HANDLE *funHandle) { INFA_EXPR_STATUS exprStatus; exprStatus.status = ISUCCESS; return exprStatus; } /*************************************************************************** Function: functionDeinitEcho Description: Called once for each function level to deinitialize any structure related to the ECHO function. Returns ISUCCESS when function deinit is successful. Otherwise, returns IFAILURE. Input: function handle Output: status Remarks: The plug-in can optionally implement this method for one-time function deinitialization. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS functionDeinitEcho(INFA_EXPR_FUNCTION_HANDLE *funHandle) { INFA_EXPR_STATUS exprStatus; exprStatus.status = ISUCCESS; return exprStatus; } /*************************************************************************** Function: functionInstInitEcho Description: Called once for each custom function instance to initialize any structure related to the an instance of the ECHO function. If there are two instances of ECHO in a mapping or workflow, PowerCenter calls this function twice. PowerCenter calls the module-level initialization function before calling this function. Returns ISUCCESS when function instance
initialization is successful. Otherwise, returns IFAILURE. Input: function instance handle Output: status Remarks: The plug-in can optionally implement this method for one-time function instance initialization. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC
INFA_EXPR_STATUS functionInstInitEcho(INFA_EXPR_FUNCTION_INSTANCE_HANDLE *funIn stHandle) { INFA_EXPR_STATUS exprStatus; exprStatus.status = ISUCCESS; INFA_EXPR_OPD_RUNTIME_HANDLE *retHandle = funInstHandle->retHandle; // Allocate memory depending on the datatype. if (retHandle->pOPDMetadata->datatype == eCTYPE_CHAR) retHandle->pUserDefinedPtr = new char[retHandle->pOPDMetadata->precision+1]; else if (retHandle->pOPDMetadata->datatype == eCTYPE_UNICHAR) retHandle->pUserDefinedPtr = new IUNICHAR[retHandle->pOPDMetadata->precision+1] ; else if (retHandle->pOPDMetadata->datatype == eCTYPE_RAW) retHandle->pUserDefinedPtr = new unsigned char[retHandle->pOPDMetadata->precisi on]; else if (retHandle->pOPDMetadata->datatype == eCTYPE_TIME) retHandle->pUserDefinedPtr = new INFA_EXPR_DATE(); return exprStatus; } /*************************************************************************** Function: functionInstDeinitEcho Description: Called once for each function level during deinitialization. Can deinitialize any structure related to the ECHO function. Returns ISUCCESS when deinitialization is successful. Otherwise, returns IFAILURE. Input: function instance handle Output: status Remarks: The plug-in can optionally implement this method for one-time function instance deinitialization. ***************************************************************************/ extern "C" SAMPLE_EXPR_SPEC INFA_EXPR_STATUS functionInstDeinitEcho(INFA_EXPR_FU NCTION_INSTANCE_HANDLE *funInstHandle)
if (retHandle->pOPDMetadata->datatype == eCTYPE_CHAR) delete [] (char *)retHandle->pUserDefinedPtr; else if (retHandle->pOPDMetadata->datatype == eCTYPE_UNICHAR) delete [] (IUNICHAR *)retHandle->pUserDefinedPtr; else if (retHandle->pOPDMetadata->datatype == eCTYPE_RAW) delete [] (unsigned char *)retHandle->pUserDefinedPtr; else if (retHandle->pOPDMetadata->datatype == eCTYPE_TIME) delete (INFA_EXPR_DATE *)retHandle->pUserDefinedPtr;
Step 4. Build the Modules You can build the modules on Windows or UNIX. Build a module for each platform t hat PowerCenter runs on. You must build a module on Windows, because the PowerCenter Client resides on Wi ndows. You may also need to build modules on UNIX or Linux, depending on the node that hosts the Int egration Service. The following table lists the library file names for each platform when you buil d the module: Platform Module File Name Windows <module_identifier>.dll AIX lib<module_identifier>.a HP-UX lib<module_identifier>.sl Linux lib<module_identifier>.so
Solaris lib<module_identifier>.so
You declare these modules in the repository plug-in XML file. For more informati on, see Step 5. Create the Repository Plug-in File on page 189.
Building the Module on Windows On Windows, you can use Microsoft Visual C++ to build the module. To build the module on Windows: 1.Start Visual C++. 2.Click File > New. 3.In the New dialog box, click the Projects tab and select the Win32 Dynamic-Lin k Library option. 4.Enter its location. In the Echo example, enter server\samples\exprsdk\echo.
5.Enter the name of the project. You must use the module name specified for the custom function as the project na me. In the Echo example, enter EchoDemo.
6.Click OK. Visual C++ creates a wizard to define the project components.
7.In the wizard, select an empty DLL project and click Finish. Click OK in the N ew Project Information dialog box. Visual C++ creates the project files in the directory you specified.
8.Click Project > Add To Project > Files. 9.Navigate up a directory level. This directory contains the procedure files you created. Select all .c files and click OK. In the Echo example, add the Echo.c file.
10.Click Project > Settings. 11.Click the C/C++ tab, and select Preprocessor from the Category field. 12.In the Additional Include Directories field, enter the following path and cli ck OK: 13.Click Build > Build <module_name>.dll or press F7 to build the project. Visual C++ creates the DLL and places it in the debug or release directory under the project directory.
Building the Module on UNIX On UNIX, you can use any C compiler to build the module. To build the module on UNIX: 1.Set the environment variable INFA_HOME to the Integration Service installation directory. Note: If you specify an incorrect directory path for the INFA_HOME environment v ariable, the Integration Service cannot start.
2.Enter a command from the following table to make the project. UNIX Version Command AIX (32-bit) make -f makefile.aix AIX (64-bit) make -f makefile.aix64 HP-UX (32-bit) make -f makefile.hp HP-UX (64-bit) make -f makefile.hp64
HP-UX PA-RISC make -f makefile.hpparisc64 Linux make -f makefile.linux Solaris make -f makefile.sol
Step 5. Create the Repository Plug-in File Create an XML file to define the function metadata of one more custom functions. Use the structure of the plug-in DTD file when you create or modify the plug-in XML file. The plug-in DTD file, plugin.dtd, is stored in the PowerCenter Client directory. Use any tool that can create an XML file. W hen you create the repository plug-in file, provide a new name for the file. The following figure shows the structure of plugin.dtd: LIBRARYPLUGINPOWERMARTREPOSITORYFUNCTIONFUNCTION_GROUP The PLUGIN Element Use the PLUGIN element to define the metadata for the plug-in that you want to c reate. The attributes of the PLUGIN element uniquely identify the plug-in metadata. The following table shows the attributes of the PLUGIN element: Attribute Required/ Optional Description NAME Required Name of the plug-in. The plug-in name displays on the Plugin tab of the Repository Service. ID
Required ID of the plug-in. Use to distinguish plug-ins developed using the same VENDORID. VENDORNAME Required Name of the vendor. The vendor name displays on the Plugin tab of the Repository Service. VENDORID Required Vendor ID. Get a vendor ID from Informatica if you are developing custom functions to distribute outside your organization. For more information, see Step 1. Get Repository ID Attributes on page 178. DESCRIPTION Optional Description of the plug-in. The plug-in description displays on the Plugin tab of the Repository Service. VERSION Required Version of the plug-in. Use to track updates to the plug-in metadata.
The FUNCTION_GROUP Element Use the FUNCTION_GROUP element to define the group the custom function belongs t o.
The following table shows the attributes of the FUNCTION_GROUP element: Attribute Required/ Optional Description NAME Required Name of the custom function group that you want to define. The function group name displays on the Plugin tab of the Repository Service. ID Required ID for the function group. Get a function group ID from Informatica if you are developing custom functions to distribute outside your organization. For more information, see Step 1. Get Repository ID Attributes on page 178. The function group ID displays on the Plugin tab of the Repository Service. COMPONENTVERSION Required Version number of the function group. This tracks updates to the FUNCTION_GROUP element. DESCRIPTION Optional Description of the function group. The function group description displays on the Plugin tab of the Repository Service. NAMESPACE Required Namespace of the function group. The Expression Editor displays custom functions with the namespace in a separate folder on the Functions tab. Namespaces are not case sensitive. You cannot use the namespace infa. It is reserved. Also, the namespace cannot be empty.
Determining a Namespace You can choose one namespace for all functions you create. However, the namespac e cannot conflict with the namespace of custom functions developed by other vendors. Therefore, choose a un ique namespace. For example, you can select a namespace that pertains to your company name, such as its stock symbol.
The FUNCTION Element Use the FUNCTION element to define properties of the custom function. The following table shows the attributes of the FUNCTION element: Attribute Required/ Optional Description NAME Required Name of the third-party function that you want to define. ID Required ID for FUNCTION element. Identifies the function. Get a function ID from Informatica if you are developing custom functions to distribute outside your organization. For more information, see Step 1. Get Repository ID Attributes on page 178. FUNCTION_CATEGORY Optional Category of the function you want to define. Use one of the following categories: - Character - Conversion - Data Cleaning - Date - Numerical - Scientific
- Special - Test
The Expression Editor displays the custom function under this category.
The LIBRARY Element Use the LIBRARY element to specify the compiled shared libraries for the custom function. The following table shows the attributes of the LIBRARY element: Attribute Required/ Optional Description NAME Required Name of the compiled shared library. OSTYPE Required Operating system for which you compiled the shared library. TYPE Required Type of shared library. Specify one of the following types: - VALIDATION. Library the PowerCenter Client uses to retrieve the custom function description and validate the function invocation, such as the return type and number of arguments. - SERVER. Library the Integration Service uses to execute the function call.
Sample Plug-in XML File The following example shows the repository plug-in file that defines the ECHO cu stom function: <?xml version="1.0" encoding="us-ascii"?> <!DOCTYPE POWERMART SYSTEM "plugin.dtd"> <POWERMART> <REPOSITORY CODEPAGE="us-ascii"> <PLUGIN NAME="Echo" ID="506001" VENDORNAME="Informatica" VENDORID="1"
DESCRIPTION="Plugin for Expressions from Informatica" VERSION="8.0.0"> <FUNCTION_GROUP ID="506002" NAME="INFA Function Group1" COMPONENTVERSION="1.0.0" DESCRIPTION="The functions group for my own Echo function" NAMESPACE=""> <FUNCTION ID="506004" NAME="ECHO" FUNCTION_CATEGORY="Data Cleansing"/> <LIBRARY NAME="pmecho.dll" OSTYPE="NT" TYPE="VALIDATION"/> <LIBRARY NAME="llibpmecho.sl" OSTYPE="HPUX" TYPE="VALIDATION"/> <LIBRARY NAME="libpmecho.so" OSTYPE="SOLARIS" TYPE="VALIDATION"/> <LIBRARY NAME="libpmecho.so " OSTYPE="LINUX" TYPE="VALIDATION"/> <LIBRARY NAME="libpmecho.a" OSTYPE="AIX" TYPE="VALIDATION"/> <LIBRARY NAME="pmecho.dll" OSTYPE="NT" TYPE="SERVER"/> <LIBRARY NAME="libpmecho.sl" OSTYPE="HPUX" TYPE="SERVER"/> <LIBRARY NAME="libpmecho.so" OSTYPE="SOLARIS" TYPE="SERVER"/> <LIBRARY NAME="libpmecho.so" OSTYPE="LINUX" TYPE="SERVER"/> <LIBRARY NAME="libpmecho.a" OSTYPE="AIX" TYPE="SERVER"/> </FUNCTION_GROUP> </PLUGIN> </REPOSITORY>
Step 6. Test Custom Functions You can test custom functions during development. Complete the following tasks t o test custom functions in PowerCenter: .Validate the repository plug-in XML file. .Verify that custom functions in an expression produce accurate data.
To test custom functions, you must install the custom functions in a PowerCenter environment.
Validating the Repository Plug-in File You can validate the repository plug-in file by registering it in a PowerCenter repository. When you register a plug-in file, an associated DTD file called plugin.dtd validates the structure o f the file. The file must conform to the structure of the associated plugin.dtd. plugin.dtd is in the PowerCenter Client directory. When you develop custom functions, you can create a repository plug-in file and register it before you finish creating the header and implementation files for the functions. When you registe r the file, you add custom function metadata, such as the plug-in ID, namespace, and function names. This r eserves this information in the repository. After you register the repository plug-in file, you can continue to develop cust om functions. When you finish developing the functions, register the repository plug-in file again to update t he custom function metadata in the repository. After you register the repository plug-in, you can view the plug-in metadata. Viewing Plug-in Metadata Details The following table shows the metadata that the Administration Console displays on the Plug-ins tab: Repository Service Attribute XML Element and Attribute Name PLUGIN NAME Vendor name PLUGIN VENDORNAME Description PLUGIN DESCRIPTION Group name FUNCTION_GROUP NAME Group ID FUNCTION_GROUP ID Group Description FUNCTION_GROUP DESCRIPTION
The following figure shows the Informatica custom function plug-in metadata:
Verifying Function Accuracy To verify the accuracy of a custom function, create an expression with the funct ion and include it in a mapping and workflow. Complete the following steps to verify the accuracy of a custom fu nction: 1.Create test data. 2.Create a mapping. 3.Add the custom function to an expression in the mapping. 4.Create a mapping. 5.Run the Debugger (optional). Or, create a session and workflow for the mapping . 6.Run the workflow. 7.View the results.
Installing Custom Functions Complete the following steps to install custom functions: 1.Copy the custom function libraries to the PowerCenter environment. 2.Register the repository plug-in.
Once you install custom functions, use them in transformation and workflow expre ssions. Step 1. Copy Custom Function Libraries to PowerCenter Copy the custom function libraries and the repository plug-in XML file to the Po werCenter Client and Integration Service directories per the custom function developer instructions. If you have high availability or run sessions on a grid, put the libraries in a single location and define the location as a required resource.
Step 2. Register the Plug-in Register the repository plug-in XML file from the Administration Console.
Creating Expressions with Custom Functions You can add a custom function to an expression. If you enter a custom function w hen you manually create an expression, you must prefix the user-defined function with the namespace the cus tom function developer provides. When you create an expression with the Expression Editor, custom funct ions display in the list of all functions and with their function type. Use custom functions as you would any ot her function. The following figure shows the ECHO custom function in the Expression Editor: Custom Function SyntaxCustom Function When you validate the expression, the Designer or Workflow Manager does not vali date the custom function. They only validate the expression. The plug-in validates the custom function.
CHAPTER 8 Custom Function API Reference This chapter includes the following topics: .Overview, 195 .Common APIs, 195 .Run-time APIs, 198
Overview Use the Custom Function API to develop custom functions that you can include in a transformation or workflow expression. The Custom Function API is a framework to create custom fun ctions. It includes common and run-time APIs. The APIs enable PowerCenter to validate expressions wi th custom functions and use the expressions in workflows. Use the APIs in the header and implementation files to develop custom functions. You must build shared libraries with the header and implementation files. You specify the shared libra ries in a repository plug-in file that you register in PowerCenter. You also copy the shared libraries to the Powe rCenter environment.
Common APIs The PowerCenter Client, Integration Service, and Repository Service call the com mon APIs to validate expressions, delete function returns from memory after use, and delete function descriptions and prototypes from memory after use. The common APIs contain the following structure: INFA_EXPR_DestroyStringvalidateFunctionINFA_EXPR_VALIDATE_METHODSINFA_EXPR_Valid ateGetUserInterface() getFunctionPrototypegetFunctionDescriptionINFA_EXPR_OPD_METADATAINFA_EXPR_GetPlu ginVersion
Validation Handle The INFA_EXPR_VALIDATE_METHODS handle is a validation handle. PowerCenter calls INFA_EXPR_ValidateGetUserInterface to get function pointers in this validation h andle.
User Interface Validation Function When PowerCenter calls INFA_EXPR_ValidateGetUserInterface, the plug-in returns f unction pointers to the validation functions. Use the following syntax: The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return value. When the function returns IFAILURE, the plug-in did not implement the function or another error occurred. INFA_EXPR_ValidateGetUserInterface returns the following functions: .validateFunction. Validates a custom function. .getFunctionDescription. Describes a custom function. .getFunctionPrototype. Provides the prototype for a custom function.
Custom Function Validation Function PowerCenter calls validateFunction to validate the arguments in the custom funct ion. It uses this function to provide the name, datatype, precision, and scale of the arguments in the custom function. It also uses this function to provide the datatype of the return value of the custom function. PowerCenter calls this function once for each instance of the custom function us ed in a mapping or workflow. Use the following syntax:
The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return value. When the function returns IFAILURE, PowerCenter displays an error message. Custom Function Description Function PowerCenter calls getFunctionDescription to get a description of the custom func tion. It calls destroyString to delete the description from memory when usage is complete. Use the following syntax: The return datatype is IUNICHAR. The return value must be a null-terminated stri ng. Custom Function Prototype Function PowerCenter calls getFunctionPrototype to get the arguments of the custom functi on in the Expression Editor. It calls destroyString to delete the arguments from memory when usage is complet e. Use the following syntax: The return datatype is IUNICHAR. The return value must be a null-terminated stri ng. The function returns NULL if there is no value for the arguments.
INFA_EXPR_OPD_METADATA Structure This structure defines the metadata of the expression operands, including argume nts passed to the function and the return type. The structure contains the following metadata: .datatype. Datatype of the argument. .precision. Precision of the argument. .scale. Scale of the argument. .isValueConstant. Indicates if the argument is a constant. If so, the framework evaluates the argument once for each function call. The framework uses isValueConstant to optimize for perfo rmance. For input arguments that are constants, the plug-in can get the argument values during fun ction instance initialization to optimize performance. For output values, the plug-in sets isValueConstant to TRUE.
Get Plug-in Version Function This function defines the version of the plug-in. It must be the same as the Cus tom Function API version, which is 1.0.0.
The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return values. If the function returns IFAILURE, the session or workflow fails. Destroy String Function This function destroys all strings the plug-in returns. For example, it destroys error messages or the return value of other function calls, such as getFunctionDescription. Use the following syntax: The function returns no value.
Run-time APIs The Integration Service calls the run-time APIs during a session to evaluate the expression that contains the custom function. It initializes the plug-in at the module, function, and functio n instance levels. Each level contains a set of functions. These functions are associated with a ha ndle, such as INFA_EXPR_MODULE_HANDLE. The first parameter for these functions is the handle t he function affects. Custom Function API handles have a hierarchical relationship to each other. A pa rent handle has a 1:n relationship to its child handle. The following figure shows the Custom Function API handles: INFA_EXPR_MODULE_HANDLEINFA_EXPR_FUNCTION_HANDLEINFA_EXPR_FUNCTION_INSTANCE_HAND LEcontains 1contains n* contains 1contains nParent handle to INFA_EXPR_FUNCTION_HANDLEChild handle to INFA_EXPR_MODULE_HANDLE
The following table describes the run-time handles: Handle Name Description INFA_EXPR_MODULE_HANDLE Represents the shared library or DLL. The plug-in can only access the module handle in its own shared library or DLL. It cannot access the module handle in any other shared library or DLL. INFA_EXPR_FUNCTION_HANDLE Represents a custom function within the shared library or DLL. INFA_EXPR_FUNCTION_INSTANCE_ HANDLE Represents a specific custom function instance.
Module-Level Functions PowerCenter calls module-level functions once for each shared library or DLL. Get User Interface Module-Level Function This function sets the function pointers for module-level interaction. Use the following syntax: The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return values. If the function returns IFAILURE, the session or workflow fails. This function returns the following functions: .function_init. Initializes the function. .function_deinit. Deinitializes the function.
Module-Level Initialization Function PowerCenter calls this module_init once for each module to initialize any global data structure in the function. It calls this function before calling any function-level functions. Use the following syntax: The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return values. If the function returns IFAILURE, the session or workflow fails. Module-Level Deinitialization Function PowerCenter calls module_deinit once for each module to deinitialize any data st
ructure in this function. It calls this function after all function-level interactions are complete. Use the following syntax:
The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return values. If the function returns IFAILURE, the session or workflow fails.
Function-Level Functions PowerCenter calls the function-level functions once for each custom function and once for each shared library or DLL that provides the parameters for the custom function. Get User Interface Function-Level Function This function sets the function pointers for function-level interaction. PowerCe nter calls this function for every custom function this library implements. Use the following syntax: The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return values. If the function returns IFAILURE, the session or workflow fails. This function returns the following functions: .function_init. Initializes the function. .function_deinit. Deinitializes the function.
Function-Level Initialization Function PowerCenter calls function_init once for each custom function to initialize any structure related to the custom function. It calls the module-level initialization function before calling this function. Use the following syntax:
The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return values. If the function returns IFAILURE, the session or workflow fails. Function-Level Deinitialization Function PowerCenter calls this function once for each function level to deinitialize any structure related to the custom function. Use the following syntax: The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return values. If the function returns IFAILURE, the session or workflow fails.
Function Instance-Level Functions PowerCenter calls these functions each time a custom function is used in a mappi ng or workflow. Get User Interface Function-Level Function This function sets the function pointers for function-level interaction. PowerCe nter calls this function for every custom function this library implements. Use the following syntax: This function returns the following functions: .fnInstance_init. Initializes an instance of a custom function. .fnInstance_processRow. Processes data for an instance of the custom function.
Function Instance-Level Initialization Function PowerCenter calls fnInstance_init once for each custom function instance to init ialize any structure related to the custom function instance. If there are two instances of a custom function in a mapping or workflow, PowerCenter calls this function twice. PowerCenter calls the module-level initia lization function before calling this function. Use the following syntax: The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return values. If the function returns IFAILURE, the session or workflow fails. Function Instance Row Processing Function PowerCenter calls this fnIstance_processRow when an input row is available to a custom function instance. The data for the input arguments of the custom function is bound and accessed throug h fnInstanceinputOPDHandles. Set the data, length, and indicator for the output and return p orts in fnInstance>retHandle. PowerCenter calls the function-level initialization function before calling this function. Use the following syntax: The datatype of the return value is INFA_EXPR_ROWSTATUS. Use the following value s for the return value: .INFA_ROWSUCCESS. Indicates the function successfully processed the row of data. .INFA_ROWERROR. Indicates the function encountered an error for the row of data. The Integration Service increments the internal error count. Only return this value when the dat a access mode is row. .INFA_FATALERROR. Indicates the function encountered a fatal error for the row o f data or the block of data. The Integration Service fails the session.
Function Instance-Level Deinitialization Function PowerCenter calls fnInstance_deinit once for each function level during deinitia lization. It can call this function to deinitialize any structure related to the custom function.
Use the following syntax: The return datatype is INFA_EXPR_STATUS. Use ISUCCESS and IFAILURE as the return values. If the function returns IFAILURE, the session or workflow fails.
A ABORT function description 42 ABS function description 42 absolute values obtaining 42 ADD_TO_DATE function description 43 Advanced Encryption Standard algorithm description 46 AES algorithm See Advanced Encryption Standard algorithm AES_DECRYPT function description 46 AES_ENCRYPT function description 46 aggregate functions AVG 48 COUNT 57 description 35 FIRST 70 LAST 88 MAX (dates) 99 MAX (numbers) 100 MAX (string) 101 MEDIAN 103 MIN (dates) 107 MIN (numbers) 108, 109 null values 10, 37
PERCENTILE 115 STDDEV 151 SUM 154 VARIANCE 173 AND reserved word 5 arithmetic date/time values 34 arithmetic operators description 14 using strings in expressions 14 using to convert data 14 ASCII See also PowerCenter Administrator Guide CHR function 51 converting ASCII values 51 converting characters to ASCII values 47 converting to Unicode values 52 ASCII function description 47 averages aggregate functions for determining 48 returning 111 AVG function description 48 B bigint See also PowerCenter Designer Guide converting values to 158 building
modules for custom functions 187 built-in variables description 17 C calendars date types supported 26 capitalization strings 79, 95, 173 case converting to uppercase 173 CEIL function description 50 character functions ASCII 47 CHR 51 CHRCODE 52 CONCAT function 54 INITCAP 79 INSTR 80 LENGTH 91 list of 37 LOWER 95 LPAD 95 LTRIM 97 METAPHONE 104 REG_EXTRACT 120 REG_MATCH 123 REG_REPLACE 124 REPLACECHR 125 REPLACESTR 127
UPPER 173 character strings converting from dates 159 converting to dates 164 characters adding to strings 95, 135 ASCII characters 47, 51 capitalization 79, 95, 173 counting 152 encoding 104, 149 removing from strings 97, 137 replacing multiple 127 replacing one 125 returning number 91 Unicode characters 47, 51, 52 CHOOSE function description 50 CHR function description 51 inserting single quotes 3, 52 CHRCODE function description 52 COBOL syntax converting to perl syntax 121 comments adding to expressions 4 comparison operators description 15 using strings in expressions 15
compiling modules for custom functions 187 COMPRESS function description 53 compression compressing data 53 decompressing data 67 CONCAT function description 54 inserting single quotes using 55 concatenating strings 14, 54 constants DD_INSERT 7 DD_REJECT 8 DD_UPDATE 9 description 1 FALSE 9 NULL 9 TRUE 11 conversion functions description 38 TO_CHAR (dates) 159 TO_CHAR (numbers) 163 TO_DATE 164 TO_DECIMAL 166 TO_FLOAT 167 TO_INTEGER 168 CONVERT_BASE function description 55
converting date strings 26 COS function description 56 COSH function description 56 cosine calculating 56 calculating hyperbolic cosine 56 COUNT function description 57 CRC32 function description 59 creating custom functions 177 header file for custom functions 179 implementation file for custom functions 180 CUME function description 60 custom functions building modules 187 creating 177 creating a header file 179 creating an implementation file 180 in the Expression Editor 193 installing 178, 193 overview 177 Custom transformation functions 195 D
data cleansing functions description 38 GREATEST 74 IN 77 LEAST 90 data movement mode See PowerCenter Administrator Guide datatypes Date/Time 25 date functions ADD_TO_DATE 43 DATE_COMPARE 61 DATE_DIFF 62 GET_DATE_PART 73 LAST_DAY 89 MAKE_DATE_TIME 98 MAX (dates) 99 MIN (dates) 107 ROUND 130 SET_DATE_PART 139 SYSTIMESTAMP 155 TRUNC (Dates) 169 date/time values adding 43 DATE_COMPARE function description 61 DATE_DIFF function description 62 dates See also date functions
format strings 28 functions 39 Julian 26 Modified Julian 26 overview 25 performing arithmetic 34 relational databases 27 rounding 130 truncating 169 year 2000 26 DD_DELETE constant description 7 reserved word 5 update strategy example 7 DD_INSERT constant description 7 reserved word 5 update strategy example 8 DD_REJECT constant description 8 reserved word 5 update strategy example 8 DD_UPDATE constant description 9 reserved word 5 update strategy example 9 DEC_BASE64 function description 64 decimal arithmetic
See high precision decimal values converting 166 DECODE function description 65 internationalization 2 decoding DEC_BASE64 function 64 DECOMPRESS function description 67 decryption AES_DECRYPT function 46 default datetime format setting 27 default values See also Power Center Transformation Guide See also PowerCenter Designer Guide ERROR function 68 division calculation returning remainder 110 DLL compiling for custom functions 187 double precision values floating point numbers 167 E ECHO sample function description 177 elements FUNCTION 190 FUNCTION_GROUP 189
LIBRARY 191 PLUGIN 189 empty strings testing for 91 ENC_BASE64 function description 68 encoding characters 104, 149 ENC_BASE64 function 68 encoding functions AES_DECRYPT 46 AES_ENCRYPT 46 COMPRESS 53 CRC32 59 DEC_BASE64 64 DECOMPRESS 67 description 39 ENC_BASE64 68 MD5 102 encryption AES_ENCRYPT function 46 using the Advanced Encryption Standard algorithm 46 ERROR function default value 68 description 68 EXP function description 69 exponent values calculating 69 returning 117
Expression Editor using with custom functions 193 expressions See also PowerCenter Transformation Guide adding comments 4 conditional 9 creating with custom functions 193 overview 1 syntax 2 using operators 13 :EXT reference qualifier description 3 reserved word 5 F FALSE constant description 9 reserved word 5 filter conditions aggregate functions 37 null values 10 Filter transformation See also PowerCenter Transformation Guide using ISNULL function 82 financial functions description 39 FV function 72 NPER function 114 PMT function 116 PV function 118 RATE function 119
description 70 flat files dates 27 floating point number See double precision values FLOOR function description 71 format from character string to date 164 from date to character string 159 format strings dates 28 definition 25 IS_DATE function 31 Julian day 29, 32 matching 33 Modified Julian day 29, 32 TO_CHAR function 29 TO_DATE function 31 FUNCTION element description 190 FUNCTION_GROUP element description 189 functions aggregate 35 categories 35 character 37 conversion 38 data cleansing 38 date 39
description 1 encoding 39 financial 39 internationalization 2 numeric 40 scientific 40 special 40 string 41 test 41 variable 41 FV function description 72 G GET_DATE_PART function description 73 GREATEST function description 74 Gregorian calendar in date functions 26 H header file creating 179 high precision See also PowerCenter Advanced Workflow Guide ABS 42 ABS function 43 arithmetic operators 14 AVG 48 AVG function 49 CEIL 50
CUME 60 CUME function 60 EXP 69 LOG 92 MAX (numbers) 100 MAX function 100 MEDIAN 103 MEDIAN function 103 MIN (numbers) 108 MIN function 108 MOD 110 MOVINGAVG 111 MOVINGAVG function 112 MOVINGSUM 113 MOVINGSUM function 113 PERCENTILE 115 PERCENTILE function 115 POWER 117 ROUND (numbers) 133 ROUND function 134 SIGN 146 SIN 147 STDDEV function 151 SUM 154 SUM function 155 TO_DECIMAL function 167 TRUNC function 172 hyperbolic cosine function 56 sine function 148
tangent function 157 I IIF function description 75 internationalization 2 implementation file creating 180 IN function description 77 INDEXOF function description 78 :INFA reference qualifier reserved word 5 INITCAP function description 79 internationalization 2 installing custom functions 178, 193 INSTR function description 80 integers converting values to 168 Integration Service handling nulls in comparison expressions 10 internationalization functions affected 2 invalid expression 2
IS_CHAR function See SQL IS_CHAR function IS_DATE function description 83 format strings 31 IS_NUMBER function description 85 IS_SPACES function description 87 ISNULL function description 82 J J format string using with IS_DATE 33 using with TO_CHAR 30 using with TO_DATE 33 Julian dates in date functions 26 Julian day format string 29, 32 L LAST function description 88 LAST_DAY function description 89 LEAST function description 90 LENGTH function description 91
empty string test 91 LIBRARY element description 191 LIKE function See SQL LIKE function literals single quotes in 52, 55 single quotes requirement 3 :LKP reference qualifier description 3 reserved word 5 LN function description 91 local variables See also PowerCenter Transformation Guide description 2 LOG function description 92 logarithm returning 91, 92 logical operators description 16 LOOKUP function description 93 LOWER function description 95 internationalization 2 LPAD function description 95 LTRIM function
description 97 M MAKE_DATE_TIME function description 98 mapping parameters See also PowerCenter Designer Guide definition 1 mapping variables See also PowerCenter Designer Guide built-in variables 17 description 1 MAX (dates) function description 99 internationalization 2 MAX (numbers) function description 100 internationalization 2 MAX (string) function description 101 :MCR reference qualifier reserved word 5 MD5 function description 102 MEDIAN function description 103 METAPHONE description 104 microseconds See subseconds milliseconds
See subseconds MIN (dates) function description 107 internationalization 2 MIN (numbers) function description 108, 109 internationalization 2 minimum value, returning 107 MOD function description 110 Modified Julian day format string 29, 32 modules building for custom functions 187 month returning last day 89 MOVINGAVG function description 111 MOVINGSUM function description 113 multiple searches example of TRUE constant 11
namespace choosing 190 nanoseconds See subseconds negative values SIGN 146 nested expressions operators 13 NOT reserved word 5 NPER function description 114 NULL constant description 9 reserved word 5 null values See also PowerCenter Administrator Guide aggregate functions 10, 36 checking for 82 filter conditions 10 in comparison expressions 10 ISNULL 82 logical operators 16 operators 11 string operator 15 numbers rounding 133 truncating 171 numeric functions ABS 42
CEIL 50 CONVERT_BASE 55 CUME 60 description 40 EXP 69 FLOOR 71 LN 91 LOG 92 MOD 110 MOVINGAVG 111 MOVINGSUM 113 POWER 117 RAND 119 ROUND (numbers) 133 SIGN 146 SQRT 150 TRUNC (numbers) 171 numeric values converting to text strings 163 returning absolute value 42 returning cosine 56 returning hyperbolic cosine of 56 returning hyperbolic sine 148 returning hyperbolic tangent 157 returning logarithms 91, 92 returning minimum 108 returning sine 147 returning square root 150 returning standard deviation 151 returning tangent 156
SIGN 146 O operator precedence expressions 13 operators arithmetic 14 comparison operators 15 description 1 logical operators 16 null values 11 string operators 14 using strings in arithmetic 14 using strings in comparison 15 OR reserved word 5 P PERCENTILE function description 115 perl compatible regular expression syntax using in a REG_EXTRACT function 121 using in a REG_MATCH function 121 permissions See also PowerCenter Administrator Guide See also PowerCenter Repository Guide PLUGIN element description 189 plug-in XML file FUNCTION element 190 FUNCTION_GROUP element 189 LIBRARY element 191
PLUGIN element 189 $PMFolderName description 19 $PMIntegrationServiceName description 19 $PMMappingName description 19 $PMRepositoryServiceName description 19 $PMRepositoryUserName description 20 $PMSessionName description 20 $PMSessionRunMode description 20 $PMSourceName@TableName description 19 PMT function description 116 $PMTargetName@TableName description 19 $PMWorkflowName description 20 $PMWorkflowRunId description 20 $PMWorkflowRunInstanceName description 20 ports syntax 3
SIGN 146 POWER function description 117 primary key constraint null values 10 privileges See PowerCenter Administrator Guide PROC_RESULT variable reserved word 5 PV function description 118 Q quotation marks inserting single using CHR function 3 R RAND function description 119 RATE function description 119 reference qualifiers description 3 REG_EXTRACT function description 120 using perl syntax 121 REG_MATCH function description 123 using perl syntax 121 REG_REPLACE function description 124 registering
repository plug-ins 193 relational databases dates 27 REPLACECHR function description 125 REPLACESTR function description 127 repository ID attributes getting 178 repository plug-in getting repository ID attributes 178 repository plug-ins See also PowerCenter Administrator Guide registering 193 reserved words list 5 return values description 2 syntax 3 REVERSE function description 129 ROUND (dates) function description 130 processing subseconds 130 ROUND (numbers) function description 133 rounding dates 130 numbers 133 rows
avoiding spaces 87 counting 57 returning average 111 returning first row 70 returning last row 88 returning sum 113 running total 60 skipping 68 RPAD function description 135 RR format string description 26 difference between YY and RR 27 using with IS_DATE 33 using with TO_CHAR 31 using with TO_DATE 33 RTRIM function description 137 running total returning 60 S sample function ECHO 177 SampleLoanPayment 177 SampleLoanPayment sample function description 177 scientific functions COS 56 COSH 56 description 40
SIN 147 SINH 148 TAN 156 TANH 157 :SD reference qualifier description 3 reserved word 5 :SEQ reference qualifier description 3 reserved word 5 sessions stopping 42 $$$SessStartTime description 21 using in expressions 21 See also PowerCenter Transformation Guide SESSSTARTTIME variable description 21 reserved word 5 using in date functions 34 using in expressions 21 SET_DATE_PART function description 139 SETCOUNTVARIABLE function description 138
description 142 SETMINVARIABLE function description 143 SETVARIABLE function description 145 shared libraries compiling for custom functions 187 SIGN function description 146 SIN function description 147 sine returning 147, 148 single quotes in string literals CHR function 52 using CHR and CONCAT functions 55 SINH function description 148 skipping rows 68 sort order internationalization 2 SOUNDEX function description 149 :SP reference qualifier description 3 reserved word 5 spaces avoiding in rows 87 removing with DD_REJECT 8
special functions ABORT 42 DECODE 65 description 40 ERROR 68 IIF 75 LOOKUP 93 SPOUTPUT reserved word 6 SQL IS_CHAR function using REG_MATCH 123 SQL LIKE function using REG_MATCH 123 SQL syntax converting to perl syntax 122 SQRT function description 150 square root returning 150 SSSSS format string using with IS_DATE 34 using with TO_CHAR 31 using with TO_DATE 34 standard deviation returning 151 STDDEV function description 151 stopping sessions 42 string conversion
dates 26 string functions CHOOSE 50 description 41 INDEXOF 78 REVERSE 129 string literals single quotes in 52, 55 single quotes requirement 3 string operators description 14 string values returning maximum 101 returning minimum 109 strings adding blanks 95 adding characters 95 capitalization 79, 95, 173 character set 80 concatenating 14, 54 converting character strings to dates 164 converting dates to characters 159 converting length 135 converting numeric values to text strings 163 number of characters 91 removing blanks 97 removing blanks and characters 137 removing characters 97 replacing multiple characters 127 replacing one character 125
returning portion 152 subseconds processing in ROUND (dates) function 130 processing in TRUNC (dates) function 169 SUBSTR function description 152 sum returning 113, 154 SUM function description 154 syntax expression 2 general rules 4 ports 3 return values 3 SYSDATE variable description 22 reserved word 6 using in expressions 22 system variables See built-in variables SYSTIMESTAMP function description 155 T TAN function description 156 tangent returning 156, 157 TANH function description 157
description 23 TC_COMMIT_BEFORE variable description 22 TC_CONTINUE_TRANSACTION variable description 22 TC_ROLLBACK_BEFORE variable description 23 :TD reference qualifier description 3 reserved word 5 test functions description 41 IS_DATE 83 IS_NUMBER 85 IS_SPACES 87 ISNULL 82 text strings converting numeric values 163 TO_CHAR (dates) function description 159 examples 30 format strings 29 TO_CHAR (numbers) function description 163 TO_DATE function description 164 examples 33 format strings 31 TO_DECIMAL function description 166
TO_FLOAT function description 167 TO_INTEGER function description 168 transaction control See PowerCenter Transformation Guide transaction control variables description 22 transformation expressions null constraints 10 overview 1 transformation language compared to SQL 2 operators 13 reserved words 5 transformation language components overview 1 transformation language updates boolean expressions 10 comparison expressions 10 TRUE constant description 11 reserved word 6 TRUNC (dates) function description 169 processing subseconds 169 TRUNC (numbers) function description 171 truncating dates 169
numbers 171 U Unicode See also PowerCenter Administrator Guide converting characters to Unicode values 47 converting to ASCII values 52 converting Unicode values 51 UNIX compiling shared libraries for custom functions 188 update strategy DD_DELETE example 7 DD_INSERT example 8 DD_REJECT example 8 DD_UPDATE example 9 UPPER function description 173 internationalization 2 V variable functions description 41 SETCOUNTVARIABLE 138 SETMAXVARIABLE 142 SETMINVARIABLE 143 SETVARIABLE 145 with multiple partitions 41 variables $$$SessStartTime 21 $PMFolderName 19 $PMIntegrationServiceName 19 $PMMappingName 19
$PMRepositoryServiceName 19 $PMRepositoryUserName 20 $PMSessionName 20 $PMSessionRunMode 20 $PMSourceName@TableName 19 $PMTargetName@TableName 19 $PMWorkflowName 20 $PMWorkflowRunId 20 $PMWorkflowRunInstanceName 20 built-in variables 17 SESSSTARTTIME 21 SYSDATE 22 TC_COMMIT_AFTER 23 TC_COMMIT_BEFORE 22 TC_CONTINUE_TRANSACTION 22 TC_ROLLBACK_BEFORE 23 transaction control variables 22 WORKFLOWSTARTTIME 22 VARIANCE function description 173 W Windows operating system compiling a DLL for custom functions 188 workflow variables See PowerCenter Advanced Workflow Guide built-in variables 17 description 2
description 22 reserved word 6 using in expressions 22 Y year 2000 dates 26 YY format string difference between RR and YY 27 using with IS_DATE 33 using with TO_CHAR 31 using with TO_DATE 33
NOTICES This Informatica product (the Software ) includes certain drivers (the DataDirect Dr ivers ) from DataDirect Technologies, an operating company of Progress Software Co rporation ( DataDirect ) which are subject to the following terms and conditions: 1. THE DATADIRECT DRIVERS ARE PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 2. IN NO EVENT WILL DATADIRECT OR ITS THIRD PARTY SUPPLIERS BE LIABLE TO THE END -USER CUSTOMER FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR OTHER DAMAGES ARISING OUT OF THE USE OF THE ODBC DRIVERS, WHETH ER OR NOT INFORMED OF THE POSSIBILITIES OF DAMAGES IN ADVANCE. THESE LIMITATIONS APPLY TO ALL CAUSES OF ACTION, INCLUDING, WITHOUT LIM ITATION, BREACH OF CONTRACT, BREACH OF WARRANTY, NEGLIGENCE, STRICT LIABILITY, MISREPRESENTATION AND OTHER TORTS.