Skip to Content mrc logo mrc logo
  • What is m-Power?
    Overview Demos Build Process Case Studies Specs Pricing Trial
    m-Power Resources
    Overview How-To Videos Webinars & Podcasts White Papers Fact Sheets
  • What does m-Power build?
    Solutions by Industry
    Overview Database Front-Ends AI Reporting CRM Systems Business Intelligence Dashboards Inventory Management Mobile Apps ERP Enhancements Modernization
    Spreadsheets to the Web MS Access to the Web B2B/Web Portals Scheduling Embedded Analytics Web Forms Workflow Data Exploration Budgeting & Forecasting APIs & Web Services Db2 Web Query Alternative
    Solutions by Industry
    Overview Manufacturing Government Foodservice Software Vendors Logistics & Supply Chain Software Consultants Healthcare
  • Development Services Training Mentoring
  • Overview Partners Press Releases Careers Events Contact Blog
  • Support Home FAQ Documentation Customer Portal Enhancements Updates Roadmap Techblog
Try m-Power

m-Power Manual

Browse:

  • Home
  • External Objects & UDFs
  • Create and Register a UDF
Back to Manual

Create and Register a User Defined Function (UDF)

 

A user defined function (UDF) allows users to extend the power of SQL. Like built-in database functions, UDFs are invoked from SQL statements. They can be a powerful yet simple way to perform routine data transformations, calculations, and complex SQL logic. Database vendors have specific requirements for creating UDFs; most allow the UDF to be written in SQL or another programming language such as C or RPG. Please see your database documentation for more information. To see sample code for a UDF written for DB2/400, click here.

After the UDF has been written for your database, it must be registered within m-Power. This is done by accessing the "Admin Menu", then click the "Custom Code" button. Finally click "User Defined Functions"

A listing of all registered UDFs is displayed. Click the "Create UDF" button to register a new UDF to m-Power.

Enter a Name and Description for the new UDF. The Description will be seen in dropdowns on the logical field screen, allowing users to choose this UDF for a new logical field.

Enter the Return Length and Return Decimal.

Note: If the Return Type is Alpha or Date, Return Decimal should be left blank.

Enter UDF / Program Name; this should correspond to the function name in the database. Enter UDF Schema/Library; this should correspond to the function's database location.

Enter UDF Type; this is the programming language used to create the new UDF.

Click "Accept". The new UDF should appear in Manage User Defined Functions screen.

The next step is to specify the UDF parameters. Click the "Parameters" link. The "Manage UDF Parameters" screen will open. Click the "Create" button.

Enter parameter information as shown above. If the parameter type is Alpha or Date, leave the Decimal field blank. Click "Accept" and repeat for each UDF parameter. When finished, the Manage UDF Parameters screen should display the list of parameters in the order entered. Note that parameters must be entered in the order they are defined in the UDF.

Click the "Manage User Defined Functions" link to return to the main UDF screen.

UDFs written with SQL language must be created directly on the database; this can be done by running a CREATE FUNCTION statement within an SQL editor provided by your database vendor. This can be done either before or after registering your UDF to m-Power.

For non-SQL created UDFs, use the "Create" link on the Manage User Defined Functions screen to automatically create the function on your database with the proper syntax. The function can also be created directly on your database using a CREATE FUNCTION command described in your database vendor's documentation.

Note: When creating your own SQL UDFs, you do not need to click the "Create" link.

Note: Click here to learn how to create your own UDFs.

After the UDF has successfully been created on the database and registered within m-Power, it is ready for use in calculated and logical fields. Note that any subsequent changes to the UDF definition or its parameters will affect applications already using those functions. For this reason, use caution when modifying already existing UDFs.

Note: If you utilize dual databases for development and production purposes, UDFs will need to be created on both databases. For assistance on copying over mrc shipped UDFs, please contact us at 630.916.0662 or at support@mrc-productivity.com.

For more information on using UDFs within logical fields, see How to Create a Logical Field via the Data Dictionary.

Created: October 20, 2008 | Modified: December 3, 2013

Search


Browse By Category

Build Process (13)
Starting with m-Power (8)
Retrievals (10)
Reports (15)
Summaries (4)
Maintainers (17)
Graphs (8)
m-Power Data Explorer (4)
General (24)
Calculations (5)
Utilities (9)
m-Power Administration (23)
Security (11)
Freemarker (6)
m-Painter (29)
Form Validation (5)
External Objects & UDFs (12)
Deprecated Documentation (23)
Bootstrap Templates (7)

Popular Tags

Security RPG Freemarker Calculations Bar Graphs Data Dictionary Maintainer Production Summaries Video DB2 Build Process Maintainers Record Selections Graphs Reports Graph Properties Application Properties Retrieval Getting Started Form Validation Email Administration Report Popular mrc-Productivity Series Prompt Screens Advanced Database Parameters SQL Tomcat Dropdowns Admin Bootstrap Templates Excel External Objects Performance App Properties Graphing Java m-Painter Dates Retrievals Compiling

See all tags »

mrc

Build the custom apps and AI tools your business needs with m-Power, or have our Chicago-based team build them with you. One platform, one team that makes sure you succeed.

Since 1981 · 1,500+ customers · 4.7/5 on G2

m-Power
Overview Demos Build Process Licensing Specs Get a Demo
Solutions
Database Front-Ends Reporting AI Tools Dashboards ERP Enhancements Modernization See all solutions
Company
Case Studies Services About Blog Careers Contact Support

Privacy Policy Cookie Policy Cookie Settings

michaels, ross & cole, ltd. (mrc)
US: 2001 Midwest Road, Suite 310, Oak Brook, IL 60523 · 630-916-0662
UK: Mortlake Business Centre, 20 Mortlake High Street, London, SW14 8JN · +44-20-335-59566
© mrc. All rights reserved.