{"id":1204,"date":"2008-10-20T03:45:51","date_gmt":"2008-10-20T08:45:51","guid":{"rendered":"http:\/\/www.mrc-productivity.com\/legacy\/?page_id=1204"},"modified":"2011-12-27T15:20:19","modified_gmt":"2011-12-27T21:20:19","slug":"introduction-to-user-defined-functions","status":"publish","type":"page","link":"https:\/\/www.mrc-productivity.com\/legacy\/external-objects-udf\/introduction-to-user-defined-functions","title":{"rendered":"Introduction to User Defined Functions (UDF)"},"content":{"rendered":"<p><!-- Begin Content --><\/p>\n<h1>UDF Introduction<\/h1>\n<p>&nbsp;<\/p>\n<p>All applications created with m-Power employ SQL to access the database.  SQL, by itself, is a very powerful language.  A database User Defined Function (UDF) allows users to extend the power of SQL.  UDF&#39;s are a powerful yet simple way to perform routine data transformations, calculations, and complex SQL logic.  Database vendors (IBM, Oracle, Microsoft, Sun, etc.) have specific requirements for creating UDFs; most allow the UDF to be written in SQL or another programming language such as C or RPG.<\/p>\n<p>m-Power makes it easy to employ this new feature.  A UDF can be defined at a global level to m-Power.  An m-Power logical field can be defined at a table level to return a value from a UDF call.  m-Power users then can select this logical UDF field as if it were any other database field and use it to display, sort, and select data in any m-Power application.<\/p>\n<p>The uses for such a powerful feature are endless.  A short list of examples:<\/p>\n<p>Dates: Convert a numeric date field into a true date field for use in selecting or sequencing records.  Or extract the year and month to perform on-the-fly period subtotaling in reports.<\/p>\n<p>Order Totals: Access other DB tables and calculate an order total value by summing the order line price times the line quantity over many Order Detail records, making it available as a selectable field from the order header table.<\/p>\n<p>On Hand Quantity: Calculate a product&#39;s current on hand valuation by combining several fields, if your database requires some logic to calculate such a value.<\/p>\n<p>The use of UDF&#39;s in m-Power is well-documented in the following articles.  Please see these documents for further details:<\/p>\n<p>Register your UDF:<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/legacy\/external-objects-udf\/how-to-create-and-register-a-udf\">https:\/\/www.mrc-productivity.com\/legacy\/data-dictionary\/user-defined-functions\/how-to-create-and-register-a-udf\/<\/a><\/p>\n<p>Create Logical Fields with UDF&#39;s:<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/legacy\/general\/create-a-logical-field-via-the-data-dictionary\">https:\/\/www.mrc-productivity.com\/legacy\/data-dictionary\/create-a-logical-field-via-the-data-dictionary\/<\/a><\/p>\n<p>mrc Date Conversion UDF&#39;s:<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/legacy\/external-objects-udf\/mrc-date-conversion-udfs\">https:\/\/www.mrc-productivity.com\/legacy\/data-dictionary\/mrc-date-conversion-udfs\/<\/a><\/p>\n<p>Sample UDF Source Code:<\/p>\n<p><a href=\"https:\/\/www.mrc-productivity.com\/legacy\/external-objects-udf\/sample-udf-code\">https:\/\/www.mrc-productivity.com\/legacy\/data-dictionary\/sample-udf-code\/<\/a><\/p>\n<p><!-- End Content --><\/p>\n","protected":false},"excerpt":{"rendered":"<p>UDF Introduction &nbsp; All applications created with m-Power employ SQL to access the database. SQL, by itself, is a very powerful language. A database User Defined Function (UDF) allows users to extend the power of SQL. UDF&#39;s are a powerful yet simple way to perform routine data transformations, calculations, and complex SQL logic. Database vendors [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1652,"menu_order":6,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-1204","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1204","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/comments?post=1204"}],"version-history":[{"count":7,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1204\/revisions"}],"predecessor-version":[{"id":4254,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1204\/revisions\/4254"}],"up":[{"embeddable":true,"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/pages\/1652"}],"wp:attachment":[{"href":"https:\/\/www.mrc-productivity.com\/legacy\/wp-json\/wp\/v2\/media?parent=1204"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}