9. Add a Library Function or Procedure This page last changed on Nov 28, 2008. .stickable, h1, h2, h3, h4, h5 false true Show Sticky notes Hide Sticky notes Save Cancel Oracle Data Service Integrator Documentation > Data Services Developer's Guide # How To Add a Library Function or Procedure This topic describes how to add a library function or procedure to a data service. Overview Add the Function or Procedure Test in Workshop for WebLogic ## Overview Library functions and procedures are utility operations that you can add to any service, physical, logical, or library. Library functions and procedures: Have a kind of library Are not marked as primary or non-primary Have a visibility of public, protected or private A library function can return values, but has no side effects. A library procedure can return values and can have side effects. You can declare a library function or procedure visually in Workshop for WebLogic, but you must still write the function body in the Source tab using XQuery. Alternatively, you can write the entire function or procedure and its pragma statement in XQuery. You can call a library function or procedure from the service, the dataspace project, or from a client application, depending on the visibility level you set. ## Add the Function or Procedure The example in this section is a library function that casts a value from xs:integer to xs:string. Open the service and click the Overview tab. Right-click at the left, right, or top, and choose Add Operation. Select a value at Visibility (public = call from anywhere; protected = from the same dataspace; private = from the same data service). At Kind, choose libraryFunction or libraryProcedure. Give your function or procedure a name. At Return Type, click Edit and choose a simple or complex return type. Click OK. At Parameters, click Edit. Enter a parameter name, and choose a simple or complex return type. Click OK. Click Empty Function Body, then OK. Click the Source tab. Oracle Data Service Integrator has generated a pragma statement and an empty function or procedure body, like this:
       (::pragma  function <f:function kind="library" visibility="public" isPrimary="false" xmlns:f="urn:annotations.ld.bea.com"/>::)

       declare function cus2:integerToString($theInt as xs:positiveInteger) as xs:string* {
           $var-bea:tbd
       };
10. In the function body, delete $var-bea:tbd and add your own XQuery code, for example:
        declare function cus2:integerToString($theInt as xs:positiveInteger) as xs:string* {
        		xs:string($theInt)
        };
## Test in Workshop for WebLogic You can test the library function or procedure directly in Workshop for WebLogic, before you use it from a client application. Open the service, and click the Test tab. At Select Operation, choose the library function or procedure you want to test. Enter a value in the Parameters box. (Optional) Expand Settings and enter new values for results, transactions, and authentication. Click Run. If the function or procedure works, you see valid results. If not, you see an exception message that provides details, so that you can correct the error. ##### How Tos Add a Read Function Add Update Map Procedures ##### Reference Data Service Types and Functions

Document generated by Confluence on Jan 13, 2009 15:57