Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Sample UDFs for Migration

Summary:  Ready to port your app from Oracle or Sybase to DB2? This handy set of SQL UDFs can help make that move a little bit easier by providing the same or similar functionality in DB2 for certain functions available in Oracle or Sybase. Updated for DB2 UDB V8.

Date:  11 Jul 2005 (Published 01 Jun 2004)
Level:  Introductory

Activity:  6941 views
Comments:  

Ready to port your app from Oracle or Sybase to DB2? This handy set of SQL UDFs can help make that move a little bit easier by providing the same or similar functionality in DB2 for certain functions available in Oracle or Sybase. Updated for DB2 UDB V8.

Introduction

Ready to port your app from Oracle or Sybase to DB2? This handy set of SQL UDFs can help make that move a little bit easier by providing the same or similar functionality in DB2 for certain functions available in Oracle or Sybase. These sample files work to help analyze information gathered from snapshot monitoring sample code files.

Many of the UDFs have been rewritten for DB2 UDB V8 by using SQL CONTROL statements. You'll see over 30 functions including ADD_MONTHS, BITAND, FORMAT, GREATEST, and many more. These samples are useful in learning design and coding techniques for DB2 SQL.

These UDFs are provided "as is" and were written and tested only in a DB2 for Linux, Unix® and Windows® environment by the author. Because your environment may be different, you are responsible for testing in your own environment.

About the sample code

The sample code is delivered in a zip (Windows) file approximately 40 KB in size.

The UDF samples for migration include:

  • FnOrAddM.txt (ADD_MONTHS) -- Add month to date.
  • FnBitAnd.txt (BITAND) -- Bit by bit AND.
  • FncTrign.txt (COSH, SINH, TANH, PI) -- Mathematical trigonometric functions.
  • FnGratst.txt (GREATEST) -- Greatest value of list of data.
  • FnLeastN.txt (LEAST) -- Least value of list of data.
  • FncHeX2I.txt (HEXTOINT) -- Convert hexadecimal to integer.
  • FnHx2Raw.txt (HEXTORAW) -- Convert hexadecimal to character string.
  • FncOrIcp.txt (INITCAP) -- Convert first character to upper case and other characters to lower case.
  • FncInStr.txt (INSTRB) -- Return the position of char2 in char1. Same function as DB2 LOCATE function with more functions.
  • FnLastDy.txt (LAST_DAY) -- Last day of month.
  • FnLengtO.txt (LENGTH_O) -- Count number of characters in a string. Each characters can be SBCS or DBCS, like Oracle length function.
  • FncOrPad.txt (LPAD) -- Pad to left with specified string.
  • (RPAD) -- Pad to right with specified string.
  • FnMBetwn.txt (MONTHS_BETWEEN) -- Months between D1 and D2. Fractionals are calculated considering as 31 days in a month.
  • FnNewTme.txt (NEW_TIME) -- Convert time of timezone Z1 to timezone Z2.
  • FnNextDy.txt (NEXT_DAY) -- Next day name of a week.
  • FnRevers.txt (REVERSE) -- Reverse order of character string.
  • FncStrip.txt (STRIP) -- Strip leading, trailing or both side characters.
  • FnSubstO.txt (SUBSTR_O) -- Substring of a string. Each characters can be SBCS or DBCS, like Oracle length function.
  • FncSysDt.txt (SYSDATE) -- Get current timestamp.
  • FncToChr.txt (TO_CHAR) -- Convert date, time or timestamp to character string according to specified format.
  • FncToDt2.txt (TO_DATE) -- Convert character string to timestamp according to specified format.
  • trunc.sql (TRUNC) -- Return truncated timestamp value according to specified format. (Author: Amyris V. Rada)
  • FncDUMPC.txt -- DUMP(char), DUMP(varchar)
  • FncDUMPn.txt -- DUMP(integer), DUMP(double), etc.
  • FncDUMPT.txt -- DUMP(date), DUMP(time), DUMP(timestsmp)
  • FncHEX2C.txt -- X2C (Used in DUMP UDF)
  • FncHEX2D.txt -- X2D (Used in DUMP UDF)
  • FncHEX2O.txt -- X2O (Used in DUMP UDF)

Related information


Download

DescriptionNameSizeDownload method
Code sampleUDF4Migration.ZIP51 KBFTP|HTTP

Information about download methods


Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Information Management
ArticleID=197323
SummaryTitle=Sample UDFs for Migration
publish-date=07112005