Xquery string for taking out repeated data

I receive an xml like this from a service:
<mov>
<id>123</id>
<timestamp>2009-06-15-13.38.50.148244</timestamp>
<data>some data for id 123</data>
</mov>
<mov>
<id>456</id>
<timestamp>2009-06-15-15.00.50.148244</timestamp>
<data>some data</data>
</mov>
<mov>
<id>123</id>
<timestamp>2009-06-15-21.30.50.123240</timestamp>
<data>updated data for id 123</data>
</mov>
(well, there are around 100 movs in a 300kb xml file)
I have to update a database table (whose primary key is id) with the received data.
They aren't suposed to send me repeated <id> values in one xml .. but it is happening once and again, as in the sample above with id=123 , so my merge obviously fails with an oracle error as it is unable to get a consistent set of records for the update.
Is there any XQuery expression to eliminate in the xmltable the <mov> with the repeated id value?
Specifically, I want to get rid of the first mov (the oldest one based on timestamp).
If the timestamp comparison is hard to achieve, getting rid of the prior movs for the same id would do.
Thanks.

Hi,
You could do it in SQL :
WITH t AS (
SELECT xmltype('<root>
<mov>
<id>123</id>
<timestamp>2009-06-15-13.38.50.148244</timestamp>
<data>some data for id 123</data>
</mov>
<mov>
<id>456</id>
<timestamp>2009-06-15-15.00.50.148244</timestamp>
<data>some data</data>
</mov>
<mov>
<id>123</id>
<timestamp>2009-06-15-21.30.50.123240</timestamp>
<data>updated data for id 123</data>
</mov>
</root>') doc
FROM dual
SELECT id, tstamp, data
FROM (
  SELECT id,
         to_timestamp(tstamp,'YYYY-MM-DD-HH24.MI.SS.FF') tstamp,
         data,
         row_number() over( partition by id
                            order by to_timestamp(tstamp,'YYYY-MM-DD-HH24.MI.SS.FF') desc ) rn
  FROM t, XMLTable(
   '/root/mov'
   passing t.doc
   columns
    id         number path 'id',
    tstamp     varchar2(30) path 'timestamp',
    data       varchar2(4000) path 'data'
  ) x
WHERE rn = 1;With XQuery only, as you've foreseen, it's not easy to deal with timestamps (at least in the format you get them).
Below, an example retrieving only the last occurrence of each id (your 2nd option) :
WITH t AS (
SELECT xmltype('<root>
<mov>
<id>123</id>
<timestamp>2009-06-15-13.38.50.148244</timestamp>
<data>some data for id 123</data>
</mov>
<mov>
<id>456</id>
<timestamp>2009-06-15-15.00.50.148244</timestamp>
<data>some data</data>
</mov>
<mov>
<id>123</id>
<timestamp>2009-06-15-21.30.50.123240</timestamp>
<data>updated data for id 123</data>
</mov>
</root>') doc
FROM dual
SELECT x.id,
       to_timestamp(x.tstamp,'YYYY-MM-DD-HH24.MI.SS.FF') tstamp,
       x.data
FROM t, XMLTable(
'for $i in distinct-values($d//mov/id)
  return $d//mov[id=$i][last()]'
passing t.doc as "d"
columns
  id      number         path 'id',
  tstamp  varchar2(30)   path 'timestamp',
  data    varchar2(4000) path 'data'
) x;Edited by: odie_63 on 27 avr. 2010 12:51

Similar Messages

  • Please Help!! How to get the width of the String for print out?

    Hi there,
    I need to do some printing in my application. I just want to know how can I get the width of the string when it is printed on the paper.
    I have tried to use the following code to get the width
    Rectangle2D rec = font.getStringBounds(str, new FontRenderContext(null, true, true));
    double width = rec.getWidth();
    however, the width I got from that function is not correct (the returned width is longer than the printed one)
    Does anyone know how to solve this problem?
    Thank you and Happy New Year !

    hi,
    The getFontMetrics(Font) is also defined in the Component class and therefore you can retrieve it even if you dont override the paint method.
    try the following (provided ur code extends some class that extends Component indirectly)
    FontMetrics f = this.getFontMetrics(this.getFont());
    int width = f.stringWidth(str); //str is the String for which u need to check the width.
    hope this was useful
    happy holidayz

  • SQL string for blank or populated date

    I need to build an Oracle sql string where I need to check that if a datetime column is not blank its value must be greater than current_date and I am failing.
    SELECT ColumnData FROM MyTable WHERE STARTDATE > current_date AND (ENDDATE !="" and ENDATE > current_date) Please tell me how I should do this.
    Edited by: StrayGrey on May 15, 2009 1:09 PM

    SELECT ColumnData FROM MyTable WHERE STARTDATE > current_date AND ENDATE > current_date

  • I want to take a series of hex characters in a string control and produce an HDLC string indicator for example if the data string control is 3F27 then the HDLC string indicator is 7E003F2700B57E

    I want to take a series of hex characters in a string control and produce an HDLC string indicator for example if the data string control is 3F27 then the HDLC string indicator is 7E003F2700B57E

    "thanks for your help "
    Does that mean you figured it out already?
    If not, see this thread for some HDLC related code.
    http://forums.ni.com/ni/board/message?board.id=170&message.id=146859&query.id=3388#M146859
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Repeating headers for tablix having nongrouped data.

    Hi All,
    I have one table that contains detail data and header data.
    But for detail data I need not require the grouped data so I have deleted the row group from by using advanced mode.
    When ever I am generating report it gives me 4 pages of report.
    I have used "RepeatOnNewPage"property to show the header data in each page but it is not working.
    This "RepeatOnNewPage" property is working for table having grouped data.
    Also I found one issue in Line report item is that same thing is not working for Line report item when I have select the "repeathWith" property for tablix.
    Both the above issues are working for Tablix having grouped data. But in my report requirement I want the same for Non Grouped data.
    Please help me how to sort out this issue.
    Thanks and Regards,
    Aswini Rout

    Hi Aswini,
    According to your description, you have a report with only detail rows. Now you have some issues on setting repeat header for your detail rows. Right?
    In Reporting Service, even you don’t have any group, you will still have detail rows. If you delete this Details, the detail rows will become a single static row so that your report will show you only show you a single record when rendering. If you still
    keep this group, your just need go to Advanced Mode of your Row and Column Groups, select the static member (this is the header row), then go to Properties pane, set RepeatOnNewPage true. Now it supposed to show you repeated header on each page.
    Also in Line report, if you set the line repeat with a tablix, the line will always repeat that tablix until all records in this tablix are rendered. So we are still finding out the reason that makes your repeat unavailable. If possible could you post the records
    in your tablix or any other detail information which can help us tested your case in our local environment. Thank you.
    Reference:
    Display Row and Column Headers on Multiple Pages (Report Builder and SSRS)
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou (Pactera)
     

  • My iMac PowerPC G4 will not connect to my Belkin N  router. I have not been able to connect for so long that I actually gave up on this computer until today, so it is a little out of date software wise. It is running OS 10.3.9.

    First off i apoligize for the title length, a bit new to help forums and didnt realize thats what that was .
    Anyways;
    My iMac PowerPC has been having this issue for quite a few years, prompting me to flat out replace it. I recently had a friend come to need a computer, and told them they could have it once i got it working.
    The unfortunate problem that i luckily discovered: my friend and i use the same brand / model of Router, the Belkin N+ (N plus incase it removes the plus sign like it did in the title).
    Ive tried everything i know, which isnt much. I've verified the password is correct, ive restarted the computer, and ive restarted my modem and router. Nothing works.
    I should mention also that the computer is out of date program wise (obviously) since i havent been able to connect with it in so long. I am still using Internet Connect, and the computer still gives me the option to try .Mac.
    Any help would be greatly appreciated.
    Dean

    The router is much, much newer than the computer, perhaps some characteristic of the WiFi network as it's currently setup is preventing the computer from connecting.
    Try to go back to the basics: set your WiFi network to "b" mode only (i.e., turn off "g") and termporarily remove the password from it. See if the computer will at least establish a connection at that point. Then start turning on one thing at a time ("g" mode, then security, etc).
    Not sure what format your WEP key is, but if it's not 10 characters (the minimum for the standard, which constitutes a 64-bit key), you can try making it that long. If it's 13 or 26 characters, it might be a higher encryption than the computer can support.
    If all else fails, you could try looking on ebay/craigslist for a copy of Tiger to install on the iMac, which would have software support for more WiFi encryption schemes. Also, it would provide software support for USB WiFi adapters that would also be able to connect to more modern networks.

  • Report for pulling out data of Pricing Ref. Material

    Hi All,
    I want to know the transaction or report which can pull out the data of pricing ref. material used for any material in Sales Org .2 view. I mean to say that, if there are 100 materials created and 50 of them have a pricing material field populated by some xyz material then how can I pull out those 50 material numbers for which the pricing ref. material is populated along with the pricing ref. material number?
    Await your quick response.
    Hrishikesh

    Hi
    These are  the standard reports for the material related.
    Material Analysis-Incoming orders - MC(E
    Material Analysis- Invoiced Sales - MC+Q
    Material Returns-Analysis - MC+M
    But i think you need to go for LIS , by creating a user defined report where in you need to take the character sics as pricing reference material (MATNR) as one of them
    Regards
    Srinath

  • My Mac refuses to open certain pages e.g. google/facebook for a weird reason "Your flash player may be out of date and you need to update it", but my flash player is up to date.

    My Mac refuses to open certain pages e.g. google/facebook for a weird reason "Your flash player may be out of date and you need to update it", but my flash player is up to date. I tried to install a new flash player version "setup.exe" but it said the file cannot be opened because the application is not supported on MAC OS X, does anyone have same problem? please help.
    Thanks

    i dont use google chrome,

  • How can I find out my data usage for the past 3 months?

    Greetings all, I have been a long time Verizon customer, and as such I, along with my husband, was grandfathered into the unlimited data plan. When I last spoke to a representative, they informed me that the only way we were going to be able to keep our unlimited data was by paying the full retail price ($600+) to get a new phone. So we were considering upgrading and changing to one of the newer data plans so we could still get the discounted price on the new phone, but I would like to make sure I choose one with enough data, without paying for a bunch of data that I don't use, however MyVerizon only shows me the amount I have used since the start of the billing cycle. Is there a way to find out the data usage for both my husband and myself for the last 3 months so I can choose the right option?
    Thanks in advance for your help!

        Hello sweetpea1221! How exciting that you're considering upgrading with us. mrhelper is helpful, indeed. You can view your data usage for each line under the View Bill option via your My Verizon account. You can also view your 3 month average  data usage with our Account Analysis feature. Here's a link that will be helpful in doing so http://bit.ly/vnLjqO. I'm confident that we have a great plan to match your data needs. Please let us know if you have further questions.
    TanishaS1_VZW
    Follow us on Twitter @VZWSupport

  • I bought the Garmin USA app for $50.. it is useless as out of date for my area. The apple store said go to Garmin. Garmin said fgo to the app store.. I clicked not satisfied on my receipt and it sent me to Garmin!!! They said it was apple to deal with

    I bought the Garmin app for $50 as the maps on my garmin in my car are not current. I thought this would avoid the need to travel with 2 devices. However, the maps are hopelessly out of date for where I live with roads and roundabouts that have been there for more than a year not on the maps. I went to the apple store to ask them what to do. they said contact Garmin. I did and they said it was only apple who could give me the refund. So I found the receipt and clicked on "do you have a problem with this app" and was redirected to Garmin. I called them( I was on hold a long time) and they said I would need to get the refund from apple.... but I can't find a way to do this. If the app had been 99 cents that would have been OK.. I've bought a few duds , but $49.99!!!
    How can I get to contact apple store/ App store directly to get the refund.. this has been going on for weeks with me getting the run around from Garmin and apple. PS don't buy this app!!!!

    Garmin is sending you to Apple because it is Apple that would have to give you a refund as the actual point of sale.  However, Apple states all sales are final.
    Apple is sending you to Garmin because it is Garmin's fault their maps are out of date and Apple doesn't write the software.  They may not even be looking that deeply and simply perceiving it as a programming "bug" it is up to Garmin to solve.
    Who know whose fault it is that Garmin isn't getting up to date data to put in their maps.
    Ultimately I think you stand the best chance in getting a refund from Apple though it isn't guaranteed.  Apple is the cashier.  You just have to convince them this isn't just a line of code omitted from an application and isn't something that will be soon corrected by Garmin.  Make it clear it isn't a problem with the application running on your device, it is a problem with the data it contains.  Either that or you have to hope Garmin will feel so bad about it they will delve down into their slush fund and send you a refund.

  • My MacKeeper says iPhoto is out of date.  When I try to update the App Store says I need IOS 10.9 or later.  I have 10.7.5 and when I check for updates my Mac says the software is up to date.  How do I solve this problem??

    My MacKeeper says iPhoto is out of date.  When I try to update it, the App Store says I need IOS 10.9 or later.  I have 10.7.5 and when I check for updates my Mac says the OS software is up to date.  How do I solve this problem??

    1. First step to solving the Problem: Trash MacKeeper. It's a pile of trash that does far more harm to your computer than good.
    https://discussions.apple.com/docs/DOC-3691
    2. What version of iPhoto do you have? (iPhoto Menu -> About iPhoto)

  • Repeated notification that "Adobe Acrobat Reader plug-in" in Firefox is "out of date" after the upgrade is downloaded and installed.

    I have tried to update the Adobe Acrobat Reader DC, along with the plug-in in Firefox v37.0.1. Repeatedly, after the download/installation is "complete", upon opening Firefox I'm met with the message that the "Adobe Acrobat plug-in" is "out of date". I tried rebooting my machine, uninstalling Acrobat Reader DC (which works as a stand-alone), and still the plug-in is never updated (the one listed is from early December 2014) and the reminder always reappears with opening Firefox. Can anyone help with this?

    Sorry about the issue which you are facing. It would be helpful if you could share the firefox notification message screenshot.
    Also, please check that the firefox plugins show the correct Adobe Acrobat Reader DC plugin. If possible, please share the firefox plug in screenshot as well.

  • How to Search for a Date in a string having both characters and date

    Hi ,
      I have a requirement to search DATE in the String having Both Characters and DATE . Please kindly let me know as early as possible.
    Regards
    Anil Kumar K

    Try to use SEARCH command with the pattern, making the pattern as fine as it can, like if you have your date in the format 02/23/2007, you can give
    SEARCH STRING FOR ' //'. (assuming the date has at least a single blank before it)
    WRITE:  SY-SUBRC UNDER 'SY-SUBRC',
    SY-FDPOS UNDER 'SY-FDPOS'.
    SY-FDPOS is set to offset of the string from which you can get the date value
    Refer here
    http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb33cc358411d1829f0000e829fbfe/frameset.htm
    It would have been better if there is something like UNIX "regular expression" matching in ABAP

  • Report Designer odbc connection string for data source using a parameter

    I am using stand alone report designer 3 for the present and have a question/problem regarding the odbc connection string for MySQL when setting up the data-source
    I need to be able to enter a parameter which is the database name i.e. BOE-201401 or say BOE-201312 etc  from a list of databases the user can choose from.
    at present the odbc connection string points to BOE-201402
    the connection string is at present  Dsn=Development Server for MYsql;description=MYSQL;server=ldndw01;database=BOE-201402;port=3306
    my parameter has the name BOE_DATABASE
    and in an expression it is  as such
    =Parameters!BOE_DATABASE.Value
    I want to point the datasource for the report to the parameter value before the user sees the report.

    Hi Leslie,
    Based on your description, we want to design a report with a dynamic DataSource connection string. There are the basic steps below for your reference:
    Create report with static database.
    Change data source to report parameter.
    Send new database connection string as a report parameter. 
    More detail information, please refer to the following blog: Dynamic Database in SSRS 2008.
    http://haseebmukhtar.wordpress.com/2011/11/09/dynamic-database-in-ssrs-2008/
    Regards,
    Alisa Tang
    Alisa Tang
    TechNet Community Support

  • Where is "Reserve space for disk use" in iTunes? Docs are out of date

    Hello,
    Where did "Resereve space for disk use" go in iTunes? I can't find it any more.
    This is major problem because if I want to auto-fill my phone (I don't have time to constantly set up playlists) I then get constantly get errors that my phone is full and that I can't take photos. This is really frustrating.
    If I got to iTunes Help, the documentation is wrong and out of date. I have iTunes 11.1.5 and if I go to Help -> iTunes Help and look at this section, it's completely wrong. See attached screenshot.
    The whole iTunes UX has become a confusing mess, I hope you're looking for a new product manager for it.
    Thank you,
    Geoff

    I am having the same issue. It even tells you that you can reserve space on your phone in the iTunes help, but I can not figure out how to open the Autofill Settings window in iTunes. Here is what it says in help of iTunes 12.0.1.26:
    Autofill settings
    You can use Autofill to add songs to your iPod, iPhone, or iPad with a single click. You can set Autofill to select songs at random, or you can customize your settings.
    You can select these options in the Autofill Settings window:
    Other options are available at the bottom of the iTunes window when you're viewing music on your device:

Maybe you are looking for

  • What is a thumbnail and how do you create it?

    I use Photoshop to edit an image to the normal size I use and "Save to Web" to compress it.  How do I then create a thumbnail.  Is a thumbnail just a smaller size image cropped from the normal size or does it take some further revising?  I am convert

  • How can I use / on my website's url?

    For instance, i am trying to make one of my website's page show a domain like this: www.imagemgama.com.br/more/dentistry/doctorA... (pages), but the software is changing to this: www.imagemgama.com.br/more-dentistry-doctorA. It is using - instead of

  • Close a Tab

    Is there a way to close a tab with a link or a button similar to the ColdFusion.createTab? I have looked through for the last couple of hours but don't seem to find a way ISM

  • IPad chargers, International??

    I am buying an iPad from the USA. We have 230V ports in Norway. Will my iPod charger(bought in Norway) work on the iPad that i am buying from the USA? I know for certain that the piece that goes into the iPod and to the iPad is the same... Any idea?

  • DPS analytics access for client only

    Hello My internal clients want to access the DPS analytics, but the thing is I am not confortable to give this password and access to several people and also, afraid some would access the Folio Producer and delete or unpublish/publish some content (c