Data Services Developer's Guide : How To Create Physical Data Services from Stored Procedures
This page last changed on Jan 09, 2008 by tkatz.
eDocs Home > BEA AquaLogic Data Services Platform 3.0 Documentation > Data Services Developer's Guide
|
![]() | References
|
The following topics cover the actions necessary to create physical data services from relational stored procedures.
Physical data services are created using a wizard.
To start the physical data service creation wizard:
When importing a relational object available options include the ability to:
Relational Type | Description |
---|---|
Tables and Views |
Displays all public tables and views in the selected data source. |
Stored Procedures |
Displays all public stored procedures in the selected data source. |
SQL Statement |
Allows creation of a SQL statement for extracting relational data from the data source. |
Database Function |
Allows creation of an XQuery function in a library data service based on build-in or custom database functions. |
To create physical data services based on stored procedures:
A list of available stored procedures appears.
Objects are grouped based on the relational data sources catalog and/or schema.
You can use wildcards to support importing metadata on internal stored procedures. For example, entering the following string as a stored procedure filter:
%TRIM%
STANDARD.TRIM
In such a situation you may want to make a "nonsense" entry in the Table/View field in order to avoid retrieving all tables and views in the database.
![]() | Database-specific Catalog and Schema Considerations |
Simply check the desired objects or their container, which will select all enclosed stored procedures.
When ALDSP introspects a stored procedure, the process may not be complete. For example, a required item of information such as a schema file or type cannot be determined. When such introspection problems occur, the stored procedure in question is highlighted in red. This setting means that additional information about the procedure must be provided by the user before the data service can be created.
Your goal in correcting an "<unknown>" condition associated with a stored procedure is to bring the metadata obtained by the import wizard into conformance with the actual metadata of the stored procedure. In some cases this will be by correcting the location of the return type. In others you will need to adjust the type associated with an element of the procedure or add elements that were not found during the initial introspection of the stored procedure.
When several stored procedures are selected at the same time for physical data service creation, all the selected procedures must be adequately configured before any data services based on the procedures can be created.
![]() | An alternative to configuring a incomplete stored procedure before proceeding is to use the wizard Back button to de-select the procedure in question. |
Here are the steps involved in editing a set of stored procedures that will be imported as data services:
![]() | If a stored procedure has only one return value and the value is either simple type or a RowSet which is mapping to an existing schema, no schema file is created. This stored procedure by definition become a library data service. |
Stored procedure configuration can be complicated. An understanding of the characteristics of the stored procedure in your database is an essential prerequisite. This section describes stored procedure options in detail.
Once in stored procedure configuration edit mode, options are available in three general areas:
Category | Option | Settings |
Discussion |
---|---|---|---|
Parameters |
Name |
Parameter name |
Editable. |
|
Mode |
on/out/inout | |
Type |
XQuery type |
May be derived from the stored procedure. Primative XQuery type settings are also available. |
|
Schema location |
XSD file |
Schema file must be in the project. |
|
Return type |
Type |
XQuery type or global type from selected schema |
|
|
Schema location |
XSD file |
Schema file must be in the project. |
Row set |
Type |
Data service |
Derived from selected schema. |
|
Schema location |
XSD file |
Schema file must be in the project. |
eDocs Home > BEA AquaLogic Data Services Platform 3.0 Documentation > Data Services Developer's Guide
The following topics provide detailed information regarding various configuration options associated with creating data services based on stored procedures.
In, Out, and Inout mode settings determine how a parameter passed to a stored procedure is handled.
Parameter Mode | Effect |
---|---|
In |
Parameter is passed by reference or value. |
Inout |
Parameter is passed by reference. |
Out |
Parameter is passed by reference. However the parameter being passed is first initialized to a default value. If your stored procedure has an OUT parameter requiring a complex element, you may need to provide a schema. |
Each element in a stored procedure is associated with a type. If the item is a simple type, you can simply choose from the pop-up list of types. If the type is complex, you may need to supply an appropriate schema. Click on the schema location button and either enter a schema pathname or browse to a schema. The schema must reside in your application.
After selecting a schema, both the path to the schema file and the URI appear.
Complex parameter types are supported under only three conditions:
A rowset type is a complex type.
The rowset type contains a sequence of a repeatable elements (for example called CUSTOMER) with the fields of the rowset.
In some cases the wizard can automatically detect the structure of a rowset and create an element structure. However, if the structure is unknown, you will need to provide it.
![]() | All rowset-type definitions must conform to this structure. |
The name of the rowset type can be:
Not all databases support rowsets. In addition, JDBC does not report information related to defined rowsets.
In order to create data services from stored procedures that use rowset information, you need to supply the correct ordinal (matching number) and a schema. If the schema has multiple global elements, select the one you want from the Type column. Otherwise the type used match the first global element in your schema file.
The order of rowset information is significant; it must match the order in your data source. Use the Move Up / Move Down commands to adjust the ordinal number assigned to the rowset.
![]() | XML types in data services generated from stored procedures do not display native types. However, you can view the native type in the Source editor; it is located in the pragma section. |
Only the most recent version of a particular stored procedure can be imported into ALDSP. For this reason you cannot identify a stored procedure version number when creating a physical data service based on a stored procedure. Similarly, adding a version number for your stored procedure in the Source editor will result in a query exception.
If you know that an input parameter of a stored procedure is nullable (can accept null values), you can change the signature of the function in Source View to make such parameters optional by adding a question mark at end of the parameter.
For example (question-mark (?) shown in bold):
function myProc($arg1 as xs:string) ...
would become:
function myProc($arg1 as xs:string?) ...
Contact BEA | Feedback | Privacy | (c) 2008 BEA Systems
Each new entity data service is created with a Read function that contains all the metadata elements identified during data service creation. It can be thought of as comparable to the following construct in the relational world:
select * from <table>
Use the Properties dialog to:
![]() | In some cases this option may not be available. |
The root element, which is read-only, is also displayed.
![]() | Initially the root element name matches the name of the data service. |
There are several default naming conventions associated with new data services:
![]() | XML Name Conversion Considerations |
On the Review New Data Service(s) page you can set, confirm or, optionally, change suggested data service names depending on the type of physical data service you are creating.
The nominated name for a new data service is, wherever possible, the same as the source object name. In some cases, however, names are adjusted to conform with XML naming conventions.
![]() | XML Name Conversion Considerations |
Name conflicts occur when there is a data service of the same name present in the target directory. Name conflicts are highlighted in red.
There are several situations where you will need to change the name of your data service:
Data services always have the file extension:
.ds
You can add SQL statement or stored procedure operations based on the same data source to an existing physical data service based a stored procedure.
![]() | Add an External Function to an Existing Physical Data Service |
Each database vendor approaches stored procedures differently. ALDSP support limitations generally reflect JDBC driver limitations.
There are several restrictions that apply to stored procedures generally:
![]() | For a list of database types supported by ALDSP XQuery-SQL Mapping Reference |
The following table describes data service creation support for Oracle stored procedures.
Term | Usage | ||
---|---|---|---|
Procedure types |
|
||
Parameter modes |
|
||
Parameter data types | Any Oracle PL/SQL data type except:
|
||
Data returned from a function | Oracle supports returning PL/SQL data types such as NUMBER, VARCHAR, %TYPE, and %ROWTYPE as parameters. | ||
Comments | The following identifies limitations associated with importing Oracle database procedure metadata.
|
The following table describes data service creation support for Sybase stored procedures.
Term | Usage |
---|---|
Procedure types |
|
Parameter modes |
|
Parameter data types | For a list of database types supported by ALDSP see the XQuery-SQL Mapping Reference. |
Data returned from a function | Sybase functions supports returning a single value or a table. Procedures return data in the following ways:
|
Comments | The following identifies limitations associated with importing Sybase database procedure metadata:
|
The following table describes data service creation support for IBM DB2 stored procedures.
Term | Usage |
---|---|
Procedure types |
|
Parameter modes |
|
Parameter data types | For a list of database types supported by ALDSP see the XQuery-SQL Mapping Reference. For a list of database types supported by ALDSP see the XQuery-SQL Mapping Reference. |
Data returned from a function | DB2 supports returning a single value, a row of values, or a table. |
Comments | The following identifies limitations associated with creating physical data services based on DB2 stored procedures:
|
The following table describes data service creation support for Microsoft stored procedures.
Term | Usage |
---|---|
Procedure types | SQL Server supports procedures, grouped procedures, and functions. Each function is also categorized as a scalar or inline table-valued and multi-statement table-valued function. Inline table-valued and multi-statement table-valued functions return rowsets. |
Parameter modes | SQL Server supports input only and output only parameters. |
Parameter data types | SQL Server procedures/functions support any SQL Server data type as a parameter. For a list of database types supported by ALDSP see the XQuery-SQL Mapping Reference. |
Data returned from a function | SQL Server functions supports returning a single value or a table. Data can be returned in the following ways:
|
Comments | The following identifies limitations associated with importing SQL Server procedure metadata.
|
![]() |
Document generated by Confluence on Jan 15, 2008 11:02 |