Loading ...
Sorry, an error occurred while loading the content.
 

Re: [xml-dbms] How to implement Order by Cluase

Expand Messages
  • Ronald Bourret
    Hello, Sorry about the late reply. I was busy with other work. I looked at the code and it might not be too difficult to modify the code to do this. Here s
    Message 1 of 3 , Nov 29, 2006
      Hello,

      Sorry about the late reply. I was busy with other work.

      I looked at the code and it might not be too difficult to modify the
      code to do this. Here's what appears to be necessary:

      a) Modify the filter DTD:

      i) Add the OrderColumn element from the XML-DBMS 2.0 (mapping) DTD.
      ii) Modify RootFilter to accept an optional OrderColumn element:
      <!ELEMENT %p;RootFilter (%p;Table, %p;Where+, %p;OrderColumn?)>

      b) Modify RootFilter to include an orderInfo property of class
      org.xmlmiddleware.xmldbms.maps.OrderInfo. Initialize this to null. Add
      getOrderInfo and setOrderInfo methods.

      c) Modify FilterCompiler to look for the OrderColumn element and call
      RootFilter.setOrderInfo if it is found.

      d) Modify the DBMSToDOM.retrieveRootTableData property to call
      RootFilter.getOrderInfo:

      ...
      // Get the root table and the map for it.

      rootConditions = rootFilter.getRootFilterConditions();
      rootTable = rootConditions.getTable();
      rootTableMap = map.getClassTableMap(rootTable);

      // NEW CODE
      OrderInfo orderInfo = rootFilter.getOrderInfo();

      e) Use the orderInfo variable in the call to DataHandler.select:

      // Construct a result set based on the filter conditions and
      process it.

      // OLD CODE
      // rs = dataHandler.select(rootTable, null, null, where, columns,
      params, null);
      // Construct a result set based on the filter conditions and
      process it.
      // NEW CODE
      rs = dataHandler.select(rootTable, null, null, where, columns,
      params, orderInfo);

      This code is not compiled or tested, but it looks like it should work.
      Let me know if you have problems.

      -- Ron

      Ronald Bourret wrote:

      > The quick answer to this is that I don't think it's currently supported
      > at the top level. (It is possible to support ordering for nested
      > elements, such as ordering line items inside a sales order like in the
      > sample.)
      >
      > I'll need to look at the code more deeply to verify that (a) this isn't
      > currently supported and (b) how difficult it would be to add support.
      >
      > -- Ron
      >
      > Sami Ather wrote:
      >
      >
      >>I have a filter like
      >><FilterSet Version="2.0"
      >>xmlns="http://www.xmlmiddleware.org/xmldbms/filters/v2">
      >> <Options>
      >> <Namespace Prefix="tes" URI = "http://www.tes.com/" />
      >> <Wrapper Name="tes:Transactions" />
      >> </Options>
      >> <Filters>
      >> <Filter>
      >> <RootFilter>
      >> <Table Name="Transaction"/>
      >> <Where Condition="fundID=1"/>
      >> </RootFilter>
      >> </Filter>
      >> </Filters>
      >></FilterSet>
      >>
      >>This filter issues an sql statement like
      >>SELECT * from transaction where fundID=1
      >>how should I go about creating a filter which issues a statement like
      >>SELECT * from transaction where fundID=1 ORDER BY transactionDate DESC
      >>
      >>Currently my map file looks like
      >><XMLToDBMS Version="2.0" xmlns="http://www.xmlmiddleware.org/xmldbms/v2">
      >>
      >> <Databases>
      >> <Database Name="Default">
      >> <Catalog>
      >> <Schema>
      >> <Table Name="Transaction">
      >> <Column Name="transactionID" DataType="INTEGER" Nullable="No"/>
      >> <Column Name="transactionAmount" DataType="INTEGER" Nullable="No"/>
      >> <Column Name="transactionDate" DataType="TIMESTAMP" Length="50"
      >>Nullable="No"/>
      >> <Column Name="transactionTypeID" DataType="INTEGER" Nullable="No"/>
      >> <Column Name="fundID" DataType="INTEGER" Nullable="No"/>
      >> <PrimaryKey KeyGenerator="Database">
      >> <UseColumn Name="transactionID"/>
      >> </PrimaryKey>
      >> </Table>
      >> </Schema>
      >> </Catalog>
      >> </Database>
      >> </Databases>
      >> <Maps>
      >> <ClassMap>
      >> <ElementType Name="Transaction"/>
      >> <ToClassTable Name="Transaction"/>
      >> <PropertyMap>
      >> <Attribute Name="transactionID"/>
      >> <ToColumn Name="transactionID"/>
      >> </PropertyMap>
      >> <PropertyMap>
      >> <ElementType Name="transactionAmount"/>
      >> <ToColumn Name="transactionAmount"/>
      >> </PropertyMap>
      >> <PropertyMap>
      >> <ElementType Name="transactionDate"/>
      >> <ToColumn Name="transactionDate"/>
      >> </PropertyMap>
      >> <PropertyMap>
      >> <ElementType Name="transactionTypeID"/>
      >> <ToColumn Name="transactionTypeID"/>
      >> </PropertyMap>
      >> <PropertyMap>
      >> <ElementType Name="fundID"/>
      >> <ToColumn Name="fundID"/>
      >> </PropertyMap>
      >> </ClassMap>
      >> </Maps>
      >></XMLToDBMS>
      >>
      >>I will appeciate your answer
      >
      >
      >
      >
      > To post a message, send it to: xml-dbms@yahoogroups.com
      > To unsubscribe, send a blank message to: xml-dbms-unsubscribe@yahoogroups.com
      > Yahoo! Groups Links
      >
      >
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.