[Download] | [Documentation Home] | [Release Note]

UDT Support

Introduction

Apart from the standard data types such as Varchar, Integer, etc, WSO2 Data Services also supports the querying of custom objects which are usually called User Defined Types(UDT). This paticular feature, further enables users to query UDTs with ordinary SQl queries as well as OUT parameters of stored procedures.

Query UDTs with ordinary SQL queries

In this option, it is only required to define an output mapping corresponding to the UDT to be queried. Here, one important thing to notice is that, the attributes of a particular UDT is queried depending on the order they are specified in the UDT. For example, if the UDT carries the structure "SampleUDT{Id Integer, Name Varchar(100)}", then the attribute index "0" maps to the attribute "Id". Similarly, attribute "Name" can be retrieved via the index "1". The following image depicts how it is done in the Data Services Wizard.

Define the necessary output mapping
Figure 01: Define the necessary output mapping

Query UDTs via OUT parameters of a stored procedure

Not only with usual SQL queries but, it is also possible to retrieve the values of UDTs via the OUT parameters defined in stored procedures. This requires the user to define an input mapping as an OUT parameters as well as to define an output mappings to actually retrieve the values of the UDT attributes.

Let's first see how we can define the Input mapping in order to register an OUT parameter to be able to retrieve the value of a sample UDT called "PERSON_T".

Register an OUT parameter as an Input mapping
Figure 02: Register an OUT parameter as an Input mapping

The next required step is to define ouput parameters to actually retrieve UDT attribute values similarly to what's described under the topic "Query UDTs via OUT parameters of a stored procedure".