Synapse
  1. Synapse
  2. SYNAPSE-533

DBLookup extracs only first element from database

    Details

      Description

      I just realized that the DBLookup mediator extracts only the first row... when i try to use statement like select * from mytable; and if my table called as mytable contains 3 values like test1, test2 and test 3, when i try to use the same only first element gets displayed ie like test1 and i dont get output as test1,test2, test3. DBLookup needs to improve this to extract multiple rows if there are multiple rows, in which case the result set will be a list of results which might be a special list that needs to be implement because it can get a XML representation of this list easily.

      Refer discussion at link : http://wso2.org/forum/thread/5181

      1. SYNAPSE-533.patch
        22 kB
        Rajika Kumarasiri

        Activity

        Hide
        Rajika Kumarasiri added a comment -

        I suggest we set the whole result set as a message context property and we provide another XPath extension function for GetPropertyFunction.java class to retrieve the required information form the results set, passing row and the column index to the function.

        Show
        Rajika Kumarasiri added a comment - I suggest we set the whole result set as a message context property and we provide another XPath extension function for GetPropertyFunction.java class to retrieve the required information form the results set, passing row and the column index to the function.
        Hide
        Ruwan Linton added a comment -

        Rajika, I think it is better to register this as a different extension to the SynapseXPathFunctionContext, may be called get-result(), please have a look at the way that the get-property function has been registered on the SynapseXPath and write a new class called GetResultFunction to provide this functionality.

        Show
        Ruwan Linton added a comment - Rajika, I think it is better to register this as a different extension to the SynapseXPathFunctionContext, may be called get-result(), please have a look at the way that the get-property function has been registered on the SynapseXPath and write a new class called GetResultFunction to provide this functionality.
        Hide
        Rajika Kumarasiri added a comment -

        hi,
        I think we have an alternative for this. Setting the whole result set as the msg_ctx property would be problematic if the result set is huge. So i suggest adding a new attribute row index for the result element if we have multiple entries.

        -Rajika

        Show
        Rajika Kumarasiri added a comment - hi, I think we have an alternative for this. Setting the whole result set as the msg_ctx property would be problematic if the result set is huge. So i suggest adding a new attribute row index for the result element if we have multiple entries. -Rajika
        Hide
        Rajika Kumarasiri added a comment -

        hi,
        I think we have an alternative for this. Setting the whole result set as the msg_ctx property would be problematic if the result set is huge. So i suggest adding a new attribute row index for the result element if we have multiple entries.

        -Rajika

        Show
        Rajika Kumarasiri added a comment - hi, I think we have an alternative for this. Setting the whole result set as the msg_ctx property would be problematic if the result set is huge. So i suggest adding a new attribute row index for the result element if we have multiple entries. -Rajika
        Hide
        Rajika Kumarasiri added a comment -

        Here is a patch which fix the problem.
        Now the result element has an optional rowIndex attribute which you can specify the row of the result set to get the required result when there are more than one entry.
        ex:
        <result name="company_id" column="id" />
        <result name="company_price_0" column="price" rowIndex="2"/>
        <result name="company_price_1" column="price" rowIndex="4"/>

        Rajika

        Show
        Rajika Kumarasiri added a comment - Here is a patch which fix the problem. Now the result element has an optional rowIndex attribute which you can specify the row of the result set to get the required result when there are more than one entry. ex: <result name="company_id" column="id" /> <result name="company_price_0" column="price" rowIndex="2"/> <result name="company_price_1" column="price" rowIndex="4"/> Rajika
        Hide
        Shibu Gope added a comment -

        Is this bugfix released in version 1.2?

        Show
        Shibu Gope added a comment - Is this bugfix released in version 1.2?
        Hide
        Hiranya Jayathilaka added a comment -

        Rajika,

        I don't think this is a very good solution to the problem at hand. For instance how can one find out the number of records returned by the query at the configuration development time? I think we need to look for a different solution. May be an option to publish the result set as an XML is a more elegant solution.

        Thanks,
        Hiranya

        Show
        Hiranya Jayathilaka added a comment - Rajika, I don't think this is a very good solution to the problem at hand. For instance how can one find out the number of records returned by the query at the configuration development time? I think we need to look for a different solution. May be an option to publish the result set as an XML is a more elegant solution. Thanks, Hiranya
        Hide
        Rajika Kumarasiri added a comment -

        Hiranya,
        Yeah it seems wrapping the result set in a XML seems like a good solution.

        Rajika

        Show
        Rajika Kumarasiri added a comment - Hiranya, Yeah it seems wrapping the result set in a XML seems like a good solution. Rajika
        Hide
        Nirmal Fernando added a comment -

        Hi,

        I am a newbie to Apache Synapse! Would this bug suitable for a newbie?

        Thanks.

        Show
        Nirmal Fernando added a comment - Hi, I am a newbie to Apache Synapse! Would this bug suitable for a newbie? Thanks.

          People

          • Assignee:
            Hiranya Jayathilaka
            Reporter:
            minal sontakke
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:

              Time Tracking

              Estimated:
              Original Estimate - 96h
              96h
              Remaining:
              Remaining Estimate - 96h
              96h
              Logged:
              Time Spent - Not Specified
              Not Specified

                Development