wso2wso2-data-services-server

Create Data Service with inner join


I'm trying to create a service with an inner join query but it returns this error:

org.postgresql.util.PSQLException: A result was returned when none was expected.

This is my service:

<data name="consultarPersona" transports="http https local">
   <config enableOData="true" id="mi_datasource">
      <property name="carbon_datasource_name">fuente_datos</property>
   </config>
   <query id="contactos_registrados" useConfig="mi_datasource">
      <sql>select * from t_contacto inner join t_datos_contacto on t_contacto.id = t_datos_contacto.id</sql>
   </query>
   <operation name="obtenerDatosContactos">
      <call-query href="contactos_registrados"/>
   </operation>
</data>

Solution

  • You should specify which columns do you want to return and generate the response, the result is an service like this:

    <data name="consultarPersona" transports="http https local">
       <config enableOData="true" id="mi_datasource">
          <property name="carbon_datasource_name">fuente_datos</property>
       </config>
       <query id="contactos_registrados" useConfig="mi_datasource">
          <sql>select name, age from t_contacto inner join t_datos_contacto on t_contacto.id = t_datos_contacto.id</sql>
          <result element="contactoCollection" rowName="contacto">
             <element column="name" name="name" xsdType="xs:string"/>
             <element column="age" name="age" xsdType="xs:string"/>
          </result>
       </query>
       <operation name="obtenerDatosContactos">
          <call-query href="contactos_registrados"/>
       </operation>
    </data>
    

    I hope this coudl help you.