Add a Read Function
This page last changed on Nov 28, 2008.
Oracle Data Service Integrator Documentation > Data Services Developer's Guide How To Add a Read FunctionThis topic describes how to add a read function to a logical entity service. OverviewA read function in a logical entity service retrieves data from underlying data sources, either physical or logical, and returns XML elements in the shape of the service's return type. You can build a logical service without a read function. However, the service must have at least one read function, marked primary, to have an update map. Only one read function in a service can be primary. A read function is associated with exactly one XML schema, which is the service's return type. The read function must return the return type, but cannot take any other actions or have any side effects. When you create a primary read function visually in Workshop for WebLogic, Oracle Data Service Integrator generates a pragma annotation and XQuery source. The pragma looks something like this: (::pragma function <f:function kind="read" visibility="public" isPrimary="true" xmlns:f="urn:annotations.ld.bea.com"/>::) The initial XQuery source, before you map data types in Query Map view, shows that the read function returns an instance of the service's return type: declare function tns:read() as element(tns:CustomerAndAddress)*{ <tns:CustomerAndAddress> <CUSTOMER> <CUSTOMER_ID></CUSTOMER_ID> <FIRST_NAME></FIRST_NAME> <LAST_NAME></LAST_NAME> <SSN?></SSN> { <ADDRESS> <ADDR_ID></ADDR_ID> <CUSTOMER_ID></CUSTOMER_ID> <FIRST_NAME></FIRST_NAME> <ZIPCODE></ZIPCODE> <COUNTRY></COUNTRY> </ADDRESS> } </CUSTOMER> </tns:CustomerAndAddress> }; At this point, the return type has no values. The values are added after you map data sources to the return type in Query Map view:
declare function tns:read() as element(tns:CustomerAndAddress)*{ for $CUSTOMER in cus1:CUSTOMER() return <tns:CustomerAndAddress> <CUSTOMER> <CUSTOMER_ID>{fn:data($CUSTOMER/CUSTOMER_ID)}</CUSTOMER_ID> <FIRST_NAME>{fn:data($CUSTOMER/FIRST_NAME)}</FIRST_NAME> <LAST_NAME>{fn:data($CUSTOMER/LAST_NAME)}</LAST_NAME> <SSN?>{fn:data($CUSTOMER/SSN)}</SSN> { for $ADDRESS in add:ADDRESS() return <ADDRESS> <ADDR_ID>{fn:data($ADDRESS/ADDR_ID)}</ADDR_ID> <CUSTOMER_ID>{fn:data($ADDRESS/CUSTOMER_ID)}</CUSTOMER_ID> <FIRST_NAME>{fn:data($ADDRESS/FIRST_NAME)}</FIRST_NAME> <ZIPCODE>{fn:data($ADDRESS/ZIPCODE)}</ZIPCODE> <COUNTRY>{fn:data($ADDRESS/COUNTRY)}</COUNTRY> </ADDRESS> } </CUSTOMER> </tns:CustomerAndAddress> }; Create the Function in Workshop for WebLogic
See AlsoHow TosConcepts |
Document generated by Confluence on Jan 13, 2009 15:57 |