XML having many parents and many children but all unrelated!***URGENT***

This is very urgent..Please HELP!!!
Iam in a project which is planning to store the entire XML file in the database in a XML datatype column. The XML has multiple parents AND multiple children for each of those parents. My problem is how to read/store the data for each of the parent and associate the parent to the child elements. The child elements does not have a parentID in its column. Here is an example- Parent table - SHIPMENT. Child Table - SHIPMENTUNITS. ShipmentNBr is the business key in both these tables. This column comes in the SHIPMENT node but does not come in the SHIPMENTUNITS node. When I try the OPENXML, all the data just gets stored..how do I link the child to the parent?
<SHIPMENT xmlns="">
<SHIPMENTNBR>US1011<SHIPMENTNBR />
<SHIPMENTTYPE_CD>BK</SHIPMENTTYPE_CD>
<LINESCAC>ACLH</LINESCAC>
<TERMINAL_CD>USJAX</TERMINAL_CD>
<ISSUE_DT>2006-08-17T14:23:09</ISSUE_DT>
<VESSEL_CD>VES</VESSEL_CD>
<VOYAGE_CD>VOYA</VOYAGE_CD>
<POL />
<POD>POD_0</POD>
<SHIPMENTUNITS>
<UNITNBR>1234</UNITNBR>
<UNITTYPE_CD>CAR</UNITTYPE_CD>
<MAKE>HON</MAKE>
<MODEL>ACCO</MODEL>
<COLOR>RED</COLOR>
<FULLEMPTY_CD>F</FULLEMPTY_CD>
<LENGTH>0011</LENGTH>
<WIDTH>0022</WIDTH>
<HEIGHT>0033</HEIGHT>
<DIMENSIONUOM>C</DIMENSIONUOM>
<WEIGHT>000010</WEIGHT>
<WGTUOM>K</WGTUOM>
</SHIPMENTUNITS>
</SHIPMENT>
<SHIPMENT xmlns="">
<SHIPMENTNBR>IN2052<SHIPMENTNBR />
<SHIPMENTTYPE_CD>BK</SHIPMENTTYPE_CD>
<LINESCAC>ACLH</LINESCAC>
<TERMINAL_CD>USJAX</TERMINAL_CD>
<ISSUE_DT>2006-08-17T14:23:09</ISSUE_DT>
<VESSEL_CD>VES</VESSEL_CD>
<VOYAGE_CD>VOYA</VOYAGE_CD>
<POL />
<POD>POD_0</POD>
<SHIPMENTUNITS>
<UNITNBR>1234</UNITNBR>
<UNITTYPE_CD>CAR</UNITTYPE_CD>
<MAKE>HON</MAKE>
<MODEL>ACCO</MODEL>
<COLOR>RED</COLOR>
<FULLEMPTY_CD>F</FULLEMPTY_CD>
<LENGTH>0011</LENGTH>
<WIDTH>0022</WIDTH>
<HEIGHT>0033</HEIGHT>
<DIMENSIONUOM>C</DIMENSIONUOM>
<WEIGHT>000010</WEIGHT>
<WGTUOM>K</WGTUOM>
</SHIPMENTUNITS>
</SHIPMENT>

I don't quite understand what you want to achieve.
If you store the data in an XML data type then you get the XML as is and all the children are associated with their parents.
If you want to decompose them into relational tables using OpenXML, then you either use the id values provided in the data and use the parent axis, or if no such id values are present look at the so called meta properties @mp:id and @mp:parentid. In your case you have the shipment number and unit number that you could use. The first approach you can do with the nodes() method too (but the meta properties are OpenXML only).
In the following example I show you both. In your case you don't need the @mp: parts. Also, since OpenXML needs a complete document I added a single root node.
declare @i int;
exec sp_xml_preparedocument @i output,
N'<doc><SHIPMENT xmlns="">
  <SHIPMENTNBR>US1011</SHIPMENTNBR>
  <SHIPMENTTYPE_CD>BK</SHIPMENTTYPE_CD>
  <LINESCAC>ACLH</LINESCAC>
  <TERMINAL_CD>USJAX</TERMINAL_CD>
  <ISSUE_DT>2006-08-17T14:23:09</ISSUE_DT>
  <VESSEL_CD>VES</VESSEL_CD>
  <VOYAGE_CD>VOYA</VOYAGE_CD>
  <POL />
  <POD>POD_0</POD>
  <SHIPMENTUNITS>
    <UNITNBR>1234</UNITNBR>
    <UNITTYPE_CD>CAR</UNITTYPE_CD>
    <MAKE>HON</MAKE>
    <MODEL>ACCO</MODEL>
    <COLOR>RED</COLOR>
    <FULLEMPTY_CD>F</FULLEMPTY_CD>
    <LENGTH>0011</LENGTH>
    <WIDTH>0022</WIDTH>
    <HEIGHT>0033</HEIGHT>
    <DIMENSIONUOM>C</DIMENSIONUOM>
    <WEIGHT>000010</WEIGHT>
    <WGTUOM>K</WGTUOM>
  </SHIPMENTUNITS>
</SHIPMENT>
<SHIPMENT xmlns="">
  <SHIPMENTNBR>IN2052</SHIPMENTNBR>
  <SHIPMENTTYPE_CD>BK</SHIPMENTTYPE_CD>
  <LINESCAC>ACLH</LINESCAC>
  <TERMINAL_CD>USJAX</TERMINAL_CD>
  <ISSUE_DT>2006-08-17T14:23:09</ISSUE_DT>
  <VESSEL_CD>VES</VESSEL_CD>
  <VOYAGE_CD>VOYA</VOYAGE_CD>
  <POL />
  <POD>POD_0</POD>
  <SHIPMENTUNITS>
    <UNITNBR>1234</UNITNBR>
    <UNITTYPE_CD>CAR</UNITTYPE_CD>
    <MAKE>HON</MAKE>
    <MODEL>ACCO</MODEL>
    <COLOR>RED</COLOR>
    <FULLEMPTY_CD>F</FULLEMPTY_CD>
    <LENGTH>0011</LENGTH>
    <WIDTH>0022</WIDTH>
    <HEIGHT>0033</HEIGHT>
    <DIMENSIONUOM>C</DIMENSIONUOM>
    <WEIGHT>000010</WEIGHT>
    <WGTUOM>K</WGTUOM>
  </SHIPMENTUNITS>
</SHIPMENT></doc>'
select *
from OpenXML(@i, '/doc/SHIPMENT')
        with (
                 id int '@mp:id'
               , nbr varchar(40) 'SHIPMENTNBR'
select *
from OpenXML(@i, '/doc/SHIPMENT/SHIPMENTUNITS')
        with (
                 id int '@mp:id'
               , ship_id int '@mp:parentid'
               , ship_nbr varchar(40) '../SHIPMENTNBR'
               , nbr varchar(40) 'UNITNBR'
exec sp_xml_removedocument @i
Best regards
Michael

Similar Messages

  • I'm a school tech coordinator. Many computers and many iPads. How many Apple IDs can I have per device, and how many devices can have the same Apple ID? To make my life easier, I'd like 200 devices to all use the same Apple ID.

    I'm a school tech coordinator. I have many computers and many iPads. I apologize if there is a some place that has all the rules governing the use of Apple IDs. I looked, and I even tried to get the answers from multiple Apple rep's. I couldn't find the answers.
    How many Apple IDs can I have per device?
    I want to use the same computer to sync and backup many iOS devices. The iOS devices would be associated with different Apple IDs.
    I may load apps under a school Apple ID and have users load their own apps under thier own ID.
    How many devices can have the same Apple ID?
    Can I use the same Apple ID on all the computers in a lab?
    Can I use the same Apple ID on all iPads for a particular grade level?
    Are the rules different for iOS devices and computers?
    I know that there are limits on "authorize" and "de-authorize" and how frequently those things can be done.
    Recently I heard that for the life of an iOS device, it can only be associated with five Apple IDs. That is not good for a school giving iPads to students in a 1:1
    To make my life easier, I'd like 200 devices to all use the same Apple ID.

    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html
    It would be best to address your questions there, especially since this is a public forum, and over there you could post more private issues with this set-up. Not to mention, getting more official answers.

  • How can I filter to find photos NOT pinned to a map? I have 28,000 phots with many mapped and many not. The Search function does not include GPS data. I haven't found  way to search metadata inside or out of Elements.

    How can I filter to find photos NOT pinned to a map? I have 28,000 phots with many mapped and many not. The Search function does not include GPS data. I haven't found  way to search metadata inside or out of Elements.

    How can I filter to find photos NOT pinned to a map? I have 28,000 phots with many mapped and many not. The Search function does not include GPS data. I haven't found  way to search metadata inside or out of Elements.

  • JDS and Gnome start, but all applications become fixed in upper left hand

    Problem:
    Java Desktop and Gnome start, but all applications are fixed in the upper left hand corner and become stacked on top of each other.
    Multi-panel JDS does not start up, and I am forced into one window, which makes the above problem critical.
    Conditions: New installation (not an upgrade) I experienced this problem. Attempted to connect from SGD. Using the following command
    /usr/dt/config/Xsession.jds
    Environment Variable: LD_LIBRARY_PATH=/usr/openwin/lib:/usr/dt/lib
    ERROR MESSAGE:
    There was an error starting the GNOME Settings Daemon.
    Some things, such as themes, sounds, or background settings may not work correctly.
    The Settings Daemon restarted too many times.
    The last error message was:
    Child process did not give an error message, unknown failure occurred
    GNOME will still try to restart the Settings Daemon next time you log in.
    SOLARIS Version:
    SunOS ITK-EDS1-IS 5.10 Generic_137137-09 sun4u sparc SUNW,Sun-Fire-V210
    Window Manager:
    Sun Java Desktop System, Release 3
    Build Date: 12/15/04
    After Problem Encountered I did the following:
    Insured all X, DT, and OPENWIN bins were in my path.
    Cleaned out the /var/tmp directory
    Cleared out the user directory except for the .dtprofile with the Sessionlog commented out, and the .profile.
    Rebooted the united and tried again.
    All .dt and JDS .directories are rebuilt, and the welcome to JDS comes up.
    The following is from the log files located in the .dt directory.
    Results of .dt/startlog (Note: only anomaly reported for brevity)
    --- starting /usr/dt/bin/dsdm &
    dsdm: another DSDM is already running
    Results of .dt/sessionlogs
    GNOME Desktop Environment
    using xinitrc file: /usr/dt/config/Xinitrc.jds
    Cleaned 0 files 0 still live
    Starting GNOME
    X_mkdir: Not owner
    (Message REPEATS)
    SESSION_MANAGER=local/ITK-EDS1-IS:/tmp/.ICE-unix/12329,inet6/ITK-EDS1-IS:34993,inet/ITK-EDS1-IS:34994
    Window manager warning: Log level 32: could not find XKB extension.
    Window manager warning: Screen 0 on display "10.70.10.21:11.0" already has a window manager; try using the --replace option to replace the current window manager.
    (Message REPEATS)
    (nautilus:12375): libgnomevfs-CRITICAL **: file gnome-vfs-volume.c: line 261: assertion `home_volume != NULL' failed
    (Message REPEATS 13 more times)
    Anyone have any idea of what this problem could be,

    Your main problem is that the JDS window manager (metacity) isn't starting up, because it thinks there is already another window manager running on that display:
    >
    Window manager warning: Screen 0 on display "10.70.10.21:11.0" already has a window manager; try using the --replace option to replace the current window manager.
    >
    I obviously don't know if there really is or not (I'm guessing not, if all the windows are stuck in the top left of the screen), but running "metacity --replace &" in a terminal should force it to start up.
    The gnome-settings-daemon warning is annoying, but non-fatal. It will usually just cause some icons and fonts to look incorrect. You can try running "/usr/lib/gnome-settings-daemon" again manually in a terminal, which will sometimes clear it up straight away. If not, I see you attempted to clean up some things in the home directory manually, but running "/usr/bin/gnome-cleanup" in a terminal (while not logged into JDS) might be a better thing to try.

  • I updated my ipod on my computer to the ios 5 and it updated but all of the music, movies, and apps were cleared off. I cannot put any of it back on please help! :(

    I updated my ipod on my computer to the ios 5.1.1 and it updated but all of the music, movies, and apps were cleared off. I cannot put any of it back on please help!

    Go to iTunea>Preferences>Devices and see if there is a backupright at the time you did the update. Then try restoring from that backup. If the apps are in your iTunes library, any app data will be restored to the iPod.
    When restoring from an iOS 4 (or later) backup, if the device had a passcode set, iTunes will ask if you want to set a passcode (and remind you that you had protected your device with a passcode). iTunes will not ask you to set a passcode when restoring from iOS 3.x and prior backups.
    Therefore, remembe the passcode that you enter this time.
    It appears that if you restore from a backup, that backup is not subseqyently overwritten by the next backup.

  • I Have Creative Cloud Student and Teacher edition, but all trial version shown in creative cloud.

    I Have Creative Cloud Student and Teacher edition, but all trial version shown in creative cloud.

    Does your Cloud subscription properly show on your account page?
    If you have more than one email, are you sure you are using the correct Adobe ID?
    https://www.adobe.com/account.html for subscriptions on your Adobe page
    If yes
    Some general information for a Cloud subscription
    Cloud programs do not use serial numbers... you log in to your paid Cloud account to download & install & activate... you MAY need to log out of the Cloud and restart your computer and log back in to the Cloud for things to work
    Log out of your Cloud account... Restart your computer... Log in to your paid Cloud account
    -Sign in help http://helpx.adobe.com/x-productkb/policy-pricing/account-password-sign-faq.html
    -http://helpx.adobe.com/creative-cloud/kb/sign-in-out-creative-cloud-desktop-app.html
    -http://helpx.adobe.com/x-productkb/policy-pricing/activation-network-issues.html
    -http://helpx.adobe.com/creative-suite/kb/trial--1-launch.html
    -ID help https://helpx.adobe.com/contact.html?step=ZNA_id-signing_stillNeedHelp
    If no
    This is an open forum, not Adobe support... you need Adobe staff to help
    Adobe contact information - http://helpx.adobe.com/contact.html
    -Select your product and what you need help with
    -Click on the blue box "Still need help? Contact us"

  • Hi my name is Jeanette cantwell , I'm having problem with my iPhone 4 my Facebook app wont work for me I re installed it many times and delete. But still won't open   Can u help me pls

    Hi I'm Jeanette , I'm having with my Facebook app, I deleted it many times and reinstalled many times but still my Facebook app won't work for me, everytime I press fb app it will just go back to fb icon or window on my phone, I have iPhone 4 , hope u can help me

    Holding down the center/select button and the menu button will reboot your ipod. See if that helps. Also, I'd recommend something else- I had nothing but trouble with my ipod classic until I spent $20 to get Mac OS Mountain Lion. It did what you said and sometimes wouldnt play, or wouldnt power on...
    Try rebooting your ipod and let me know what happens and maybe in the future obtain Mountain Lion to aide your ipod in functionality.
    Good luck!

  • 2 Iphones - 1 iTunes - many Apps and many songs.  How can we share ?

    I have an iPhone 3G and an iPhone 3Gs and many apps as well as music. Can I share the apps on both iPhones? The Music? How does this work... I know iTunes will recognize both phones as different... will it allow me to load the same apps on both phones? Music?
    Thanks,
    Rich

    Hi,
    You can sync apps but you have to select apps for each device. When you plug you device in it will remember your apps that you selected for that device. I have an iPhone and an iTouch with a different app set synced to the same iTunes library. Just go through the list when the device is connected and choose the apps/ songs ect. then sync. When you connect the other device repeat the process. Make sure to not let iTunes automatically sync when connected. iTunes will remember the settings for each device. Works for me.

  • Copy Parent and its children records

    Hello:
    I have a requirement to implement the "deep copy" functionality i.e. copy Opportunity and its children records including Contact, Opportunity Product Revenue etc. Can this be accomplished with the weblink, web services or any other options? I have went over the Oracle web services Guide doc, but I am still not sure what steps need to take in order to implement this "deep copy" functionality. Could you direct me to any reference docs to implement this?
    Thanks in advance!
    -AJ

    Briefly, it looks like this.
    "Deep copy", as you describe it, can be just a programmatic manipulation of data via WebServices. So your program would go through these steps:
    - login to WS (or use stateless sessions)
    - use Query method on Opportunity object Web Service to retrieve all fields from the record, and all child records
    - create new Opportunity record, by calling Insert method
    - create child records of all types you need, also by calling Insert method (in WS 1.0 you will use InsertChild)
    Exact details depend on your programming language.
    You may need to use both 1.0 and 2.0, or select which version to use, because these two interface support different child objects.
    In any case, there is no way to create both parent and children in one call - you create Opportunity record, and then reference its ID in new child objects.
    Hope it helps.

  • How to update my photoshop cs5 for nikon d4s ? I have been try to download camera raw 8.4  8.5 and 8.6 but all did not working.

    I just trying to search app for my nikon d4s for photoshop cs5. And I trying to download the camera raw 8.4, 8.5 and 8.6 but no one was success. Any body can help ? I am use window 7 on my desktop.

    there is no such thing. Camera Raw is specific to certain versions of PS. 8.x will never work in CS5. you need to update your software or settle on using the DNG converter.
    Camera Raw plug-in | Supported cameras
    Camera Raw-compatible Adobe applications
    Mylenium

  • We are a family of 6 - 2 parents and 4 children.. We have an iMac, 3 macbooks, a Macbook Pro and an iPad. We all want to be able to share the itunes library, but it keeps telling us that it can't authorize more than 5 computers.  What can we do???

    How can we home share with more than 5 computers?? We are a family of 6 and each has his/her own computer.

    You can't. But iDevices don't count. So you should be able to share the 5 computers.

  • Changing scaleX/scaleY on parent scales the children but doesn't update  height/width property ?

    have created a custom component - MyImage - that has two children including a Bitmap as well as a Sprite.
    My display object hierarchy is as follows -
    mx:Canvas
      view:MyImage
         mx:Bitmap
         my:Sprite
    If I change the MyImage.scaleX, scaleY property, the children scale as I would expect them to.
    However when I try to place the children in the center using placeAgain() on getting a resize event:
        public function placeAgain():void
            if (image==null) return;
            var pCanvas:Canvas = this.parent as Canvas;
            if (image.width <= pCanvas.width)
                pCanvas.horizontalScrollPolicy="off";
                image.x = (pCanvas.width -image.width)/2;
            else
                pCanvas.horizontalScrollPolicy="on";
                image.x=0;
            if (image.height <= pCanvas.height)
                pCanvas.verticalScrollPolicy="off";
                image.y = (pCanvas.height -image.height)/2;
            else
                pCanvas.verticalScrollPolicy="on";
                image.y=0;
            alignKids();
    I find the image.height & width have not changed despite the image getting scaled!
    Isn't the child supposed to have its bounds changed after scaling its
    parent ? Especially after the child has actually been scaled correctly ?
    Why are bounds of the child stuck at the same value as before scaling? I
    am not caching the Bitmap, have not turned on caching of bitmaps.

    If I'm not mistaken, the bounds are updated with the scale. You rare not referencing the bounds, your referencing the width and height properties, which is a bit different. What happens if you use the getBounds function to get your dimensions?

  • Today (Oct.14), FF won't display clickable icons on many sites and the backround is all white. Reinstalled... same problem. Any ideas?

    FF version = 3.6.10
    Running Windows 7 (64)
    Have not had this problem before... was working last night. Didn't shut computer off. Wasn't working this morning.

    Try the following:
    System Preferences>Quicktime>Advanced
    Click on the MIME Settings button.
    In the next window that opens up make sure that click on the triangle next to Images - Still image files.
    Make all items are enabled (checked) except for PDF Image.
    Click the OK button.
    Restart your computer.
    ==============
    Take a look in your Home/Library/Internet Plug-Ins folder - if you see any QT plugins or webplugins file there, remove them to the desktop or trash.
    Restart your computer.
    ===============
    Are you trying to view JPG files from a browser or from your HD? Asking because most browsers have a +"file helper"+ preference. For Firefox, it's under the Applications Preferences. There, you can select which type of files you can map to the QT browser plug-in.

  • I have multiple devices (imacs, lap tops and ipads) all connected to a NAS server.  Can I create a user for myself and one for my wife, and each have our own apple ID, and Itunes accounts, but all share the same media on NAS drives?

    I have multiple devices (iMacs, Lap tops, Ipads) all connected to a Nas Drive.  Can I create a user for myself and one for my wife and we each have our own apple ID's, Itunes etc, but share the same data on the hard drives?  So when she logs in, and sync's her ipads, they will sync with her stuff and when I do the same under my user account, on the same device, my ipads will sync with my stuff?

    You can share the same Apple ID for purchasng form the iTunes and app stores without any problems, but you should all used separate iCloud accounts with separate Apple IDs.  (You are not required to use the same ID for iCloud and other services as you do for the iTunes store.)  This will prevent you from ending up with merged data.  You should also use separate Apple IDs for iMessage and FaceTime or you will end up getting each other's text messages and FaceTime calls.
    This article may be of interest: http://www.macstories.net/stories/ios-5-icloud-tips-sharing-an-apple-id-with-you r-family/, as well as this video: http://macmost.com/setting-up-multiple-ios-devices-for-messages-and-facetime.htm l.

  • TS3988 I have two apple id's and when I upgraded from 4.2.1 to 6.0 I lost all the songs I downloaded from on of the ID''s I tried going on that ID and IClouding them but all I got was this how(what it said  Down bellow  can I get half my music back

    This devise is already associated with a apple ID you can download past purchase with just one apple ID every 90 days .you can out associate this device with a different ID for 2 days

    Prita wrote:
    I want to update my current iOS from 4.2.1 to 5.0.1 for the Assistive Touch feature that allows you to have an on screen home button
    I tried downloading the file myself (not through iTunes), making sure I got the iPod 4G file. Go into iTunes and install it and it says it cannot upgrade because the firmware is not compatible
    iOS 4.2.1 - there's a clue. It begs the question about which model of iPod you have. Yes, I know you said:  (and yes, I have a 4G) by which I assume you're saying that you have a 4th generation Touch, but are you sure? This has been claimed before by people who then discover that they do not have a 4th gen Touch. Which size Touch do you have and what is the model number on the back of your iPod? If it says model A1288, that's a 2nd generation iPod Touch. Check this page  http://support.apple.com/kb/HT1353 for help in identifying your model of iPod.
    The second clue - and the reason I've mentioned all this, is that you then say you have downloaded the file yourself but "it cannot upgrade because the firmware is not compatible." In other words, iOS 5.0 cannot be used with your iPod. That also suggests that you have 2nd gen Touch.
    Persumbaly, you have tried connecting the Touch to iTunes and selecting "check for updates?" What does it say?

Maybe you are looking for