Problem with xs:integer (I think)

Hi,
Firstly, I'm using Oracle database version 11.2.0.1.0
The overall task is to absorb data from an XML file and create records in a single destination table.
I've studied the excellent thread at Load xml data in Oracle table
and copied and hacked Odie's examples.
I've got something to work, but there's just that one final problem, explained so.
To test out my code, I wrapped the "select" that gets the data from the XML file into a cursor For loop, and inside
the loop body I just use dbms_output so I can see that the values are being processed okay. This works a treat, so my
final task was to abandon the cursor For loop and instead make the select statement the source of data for an Insert
statement. This is where my plans become unstuck.
In order to cater for duplicate rows, I'm using the "at" bit of the "for" loop as so: "for $i at $bibnum in /collection/record".
That bit of data (available through the variable "$bibnum") when printed out via the older dbms_output code did show
a pleasing consecutive sequence of digits. But try and insert this into a plain database table and all I get is nulls. Yuk.
Trying to read around this, I've managed through dubious means to glean that the variable is of type "xs:integer". It seems converting
this to a oracle "number" type is problematic. There is mention on the web page http://docs.oracle.com/cd/E14571_01/doc.1111/e15867/app_xquery_sql_reference.htm
about conversion from "number" to "xs:integer", hence I am presuming that the converse also holds.
But the blooming thing still doesn't work.
Other numbers from the select statement populate into my destination table fine. It's just the xs:integer that's the issue.
I've tried changing the "columns" part of the xmltable call and used "number", "number(8)", "number(8,0)" and other variants. No joy.
I've also tried changing the column type of the target table. Still no joy.
I've tried converting the xs:integer to a xs:decimal, and then use that. Still nothing.
Time to throw myself on the mercy of the forum. Any easy way to convert the xs:integer into a plain string?
If there is no obvious answer, I will throw together a small self-contained piece of example code and come back here.
Any help appreciated; thanks in advance.
Mungo (newbie with xmltables - probably going round the "long" way on this task :-)

That's a funny one, SELECT is working but INSERT is not...
I guess it's an issue with the CBO and XQuery optimization.
If you're always using a variable as your XML source, you can disable it by adding the NO_XML_QUERY_REWRITE hint. It should solve the problem :
SQL> create table raw_bib (
  2    recordID    number
  3  , datafieldID number
  4  , tag         number
  5  , subfield    varchar2(10)
  6  , val         varchar2(4000)
  7  )
  8  ;
Table created
SQL> var xml_data varchar2(4000)
SQL>
SQL> begin
  2   :xml_data := '<collection>
  3   <record>
  4    <datafield tag="1">
  5     <subfield code="1d1s1">ABC</subfield>
  6     <subfield code="1d1s2">DEF</subfield>
  7     <subfield code="1d1s3">GHI</subfield>
  8    </datafield>
  9    <datafield tag="2">
10     <subfield code="1d2s1">ABC</subfield>
11     <subfield code="1d2s2">DEF</subfield>
12     <subfield code="1d2s3">GHI</subfield>
13    </datafield>
14   </record>
15   <record>
16    <datafield tag="1">
17     <subfield code="2d1s1">ABC</subfield>
18     <subfield code="2d1s2">DEF</subfield>
19     <subfield code="2d1s3">GHI</subfield>
20    </datafield>
21   </record>
22  </collection>';
23  end;
24  /
PL/SQL procedure successfully completed
SQL>
SQL> insert into raw_bib(recordID, datafieldID, tag, subfield, val)
  2  select /*+ no_xml_query_rewrite */
  3         recordID, datafieldID, tag, subfield, val
  4  from xmltable(
  5   'for $i at $bibnum in /collection/record
  6   return
  7   for $j at $dfnum in  $i/datafield
  8   return
  9   for $k in $j/subfield
10     return element r {
11      element finalData {data($k)}
12      , element datafieldtag {data($j/@tag) }
13      , element subfieldcode { data($k/@code) }
14      , element whichdatafield {data($dfnum)}
15      , element bibnumber { $bibnum }
16      }
17    '
18  passing xmltype(:xml_data)
19  columns recordID    number         path 'bibnumber'
20        , datafieldID number         path 'whichdatafield'
21        , tag         number         path 'datafieldtag'
22        , subfield    varchar2(10)   path 'subfieldcode'
23        , val         varchar2(4000) path 'finalData'
24  )
25  ;
9 rows inserted
SQL> select * from raw_bib;
  RECORDID DATAFIELDID        TAG SUBFIELD   VAL
         1           1          1 1d1s1      ABC
         1           1          1 1d1s2      DEF
         1           1          1 1d1s3      GHI
         1           2          2 1d2s1      ABC
         1           2          2 1d2s2      DEF
         1           2          2 1d2s3      GHI
         2           1          1 2d1s1      ABC
         2           1          1 2d1s2      DEF
         2           1          1 2d1s3      GHI
9 rows selected

Similar Messages

  • Problems with syncing, recognising iPod, thinking it's corrupted...

    Hi, I've had this 30GB iPod photo of mine for a number of years now but for a long time it's been having problems with syncing. I've gotten an exciting variety of error messages when trying to sync with my iTunes, from my iPod software is out of date, by iPod is corrupted, to simply that my iPod will not sync for no adequately explained reason. Occasionally also Windows fails to recognise it. This was never too big of a problem because a few songs would transfer usually before it errored out on me, or I'd just unplug it, restart it and plug it in again and the few songs I wanted would go on. (I don't add giant chunks of new music to it that often) However just recently I discovered that about 300 songs were missing from it and I can't for the life of me get it to sync up again to put them back on. iTunes has been saying that An iPod has been plugged in but that it doesn't recognise it, or it'll start syncing and then say "Attempting to copy to disk "CASSIE'S IPOD" failed. The disk could not be read from or written to." Any help or advice? is my iPod just horribly corrupted in some way and beyond help except for expensive repairs and replacement? Or is this a software thing I can actually fix somehow?

    I eventually called an Apple Repair person about my Ipod, who advised me that "it sounded quite serious" and all he would do if I brought it in for repair would be to replace it with another reconditioned unit which would cost me $195! This was a newly "reconditioned" unit that I had just bought, so unfortunately it ended up going back. I've just requested a refund this time because this is the 2nd time this has happened to me in a month! I'm starting to think I was never destined to own an operating Ipod! I think I'll look at a Sony or Creative MP3 Player as an alternate. They seem to have good reviews and they'll probably work first time round! I'm a bit tired of Apple now! There just seems to be too many things that can - and DO - go wrong!

  • Satellite A500-1GH problem with video card (I think...)

    Hello,
    I am having a problem with my A500-1GH. Randomly the monitor goes black and then recovers by showing a message "display driver stopped responding and has successfully recovered". My graphics card is the Nvidia GeForce 330. I read a lot, but all the opinions were old - from the beginning if the year, and no one seems to had solved this problem then. Do you know if now there is a solution for this?
    The laptop is brand new (respectively the windows is brand new) and the drivers and bios are up to date.
    Thank you in advance :)

    hi,
    Yeah, it is known problem with vga driver in this forum. As you already said yourself no one seems to had solved this problem :( I can just recommend you to try to install a vga driver from nvidia.com. In my case, i have nvida Gt 230 M, driver update solved it.

  • Problem with  JFrame (I'm thinking) from enother java program

    Hi,
    I'm using jasperReport and running viewReport from my java application.
    JasperPrint jasperPrint = JasperFillManager.fillReport(
                             jasperReport, parameters, conn);
                   JasperViewer.viewReport(jasperPrint, true);
    My problem is when I'm closing the view report, my java aplication closing twe!
    I think it's because the view frame sel exit(0)?
    and one more question, if I run this viewReport from JButton in a JDIalog, the view location is under my dialog, how can I set this view to be allways on top??
    Thanks alot :)

    The following code is running without problems (SQLSERVER),and you can compared with yours.
    public static Connection con;
         public  Statement sta;
         public ResultSet rst;
         public CallableStatement  cas = null;
         public int OutPut;
    public void doProcedures(String str,Vector vec){
                   try {
         String s=null;
                        con=null;
                        rst=null;
                        Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
                                            con = DriverManager.getConnection(getConnectionString(), "sa","");               
                                         s=str;
                        s="{call"+" "+s+"(?,?,?)}";
                    cas=con.prepareCall(s);
                       cas.registerOutParameter(1, java.sql.Types.INTEGER ); 
                       for(int i =0;i<vec.size();i++){                   
                      cas.setInt(i+2,Integer.parseInt ((String)vec.elementAt(i)));  
                       cas.execute() ;
                       OutPut =cas.getInt(1);
                       rst = cas.executeQuery();
                      // while(rst.next()){
                           // String output=rst.getString(1);
                       //rst.close() ;
                   } catch (Exception e) {
                        e.printStackTrace();
    Good Luck,baby!!!

  • Problem with entering integer numbers from keyboard

    I have written this simple code:
    import java.io.*;
    public class Simple{
         public static void main(String[] args)throws Exception{
              System.out.println("Enter two integer numbers: ");
              BufferedReader enter=new BufferedReader(new InputStreamReader(System.in));
                   int first=Integer.parseInt(enter.readLine());
                   int second=Integer.parseInt(enter.readLine());
              System.out.println("Result is: "+(first+second));
    and it works fine if I type first number, press Enter, then type
    second number and press Enter.
    But if I type in one line: 2 3 (with space between) I get run-time error:
    Exception in thread "main"...bla...bla at java.lang.Integer.parseInt(Integer.java)...
    I know that error is coming from Integer.parseInt(string) in my code, but I
    don't know how can I avoid it.
    In C that is rather simple scanf("%d %d",&first,&second), but in Java it's much more
    complicated.
    Do you have any suggestions how to solve this problem?

    store the user input in a string
    use a StringTokenizer st
    then
    while(st.hasNext())
    int first=Integer.parseInt(st.nextToken());
    but you should really catch a NumberFormatException
    walker

  • Problem with multiple same emails - thinking of clean reinstall

    Hi. My OS is windows vista home edition and I am using Thunderbird version 31.0. My email provider is MSN.
    When thunderbird checks mail, Instead of receiving one copy of an email, I am sometimes getting two and even three copies of the same email. They all have the same date and time. I have tried some suggestions including deleting .msf and popstate.dat files and also making sure that the server is not set to keep emails there. This fixes things for a day and then I am back to getting multiple emails. It's annoying.
    I am thinking about doing a clean reinstall of TB. I have the mozbackup utiility and I am going to back up emails and contacts. As far as uninstalling thunderbird completely goes, is there an instruction page for that? Does anyone think this will help?
    Thanks!

    A note for the future....
    Files:- Are rebuilt by right clicking a folder, selecting properties and then repair. It is easier that digging into the file system. The other "index" you refered to with no extension is not an index, it is the actual mail. Inadvertently deleting local copies of mail not on the server can be something of a disaster. Right clicking the folder and selecting compact will clear corruption there. But it may well get rid of corrupt mail as the MSF files are what is used to display lists in Thunderbird.
    This add-on make managing duplicate messages much easier. https://nic-nac-project.org/~kaosmos/index-en.html#recDelMsg

  • How do I fix a problem with Facebook. They think I have a virus or malware

    I have been having trouble with facebook thinking that I have a virus or malware as I am posting on the games I play. I have an antivurus on my computer and it does not detect anything.

    Do a malware check with some malware scanning programs on the Windows computer.<br />
    You need to scan with all programs because each program detects different malware.<br />
    Make sure that you update each program to get the latest version of their databases before doing a scan.<br /><br />
    *http://www.malwarebytes.org/mbam.php - Malwarebytes' Anti-Malware
    *http://www.superantispyware.com/ - SuperAntispyware
    *http://www.microsoft.com/windows/products/winfamily/defender/default.mspx - Windows Defender: Home Page
    *http://www.safer-networking.org/en/index.html - Spybot Search & Destroy
    *http://www.lavasoft.com/products/ad_aware_free.php - Ad-Aware Free
    See also:
    *"Spyware on Windows": http://kb.mozillazine.org/Popups_not_blocked

  • Using .mac with mail.app and iphone...problems with mailbox folders i think

    Is it normal in mail.app for my folders to be as follows: Under the heading Mailboxes, I have Inbox folder and Sent folder and trash folder. Then, instead of a junk folder under that, it is below all of that under the heading Chris's Email (obviously my account). Why is this?

    Who is your ISP used for connecting to the internet?
    Are you also accessing an email account and SMTP server that is provided by your ISP with the Mail.app and if so, are you able to send messages with your ISP's email account?
    Most if not all ISPs used for connecting to the internet now block the use of SMTP servers that are outside of their network (or not provided by the ISP) on Port 25 which is the default port for SMTP servers.
    Some ISPs allow the use of an authenticated SMTP server only (such as the .Mac SMTP server) on Port 25 but some block its use regardless.
    These restructions are in place as part of an overall effort to prevent spam emanating from the ISP's domain.
    First thing to try.
    Go to Mail > Preferences > Accounts and under the Account Information tab for your .Mac account preferences at the SMTP server selection, select the Server Settings button below the the .Mac SMTP server.
    Enter 587 in place of 25 in the Server Port field and when finished, select OK to save the changed setting.
    If this doesn't work, you need to contact your ISP. If you are accessing an email account and SMTP server that is provided by your ISP used for connecting to the internet with the Mail.app, in the interim select/use your ISP's SMTP server to send messages with your .Mac account which is invisible to all recipients.

  • HUGE problem with the updater (i think)

    Ok, So last month my computer crashed and i lost all of my songs. The songs are still on the i-pod though, so is there any way to stop i-tunes from erasing all of my songs when i plug it in again.

    Welcome to Apple Discussions.
    iTunes always allows you to opt out of connecting to the blank library -- just say "no".
    Then you can use any number of ways to transfer your songs back to the computer:
    http://www.kelleytown.com/ikelleytown.htm#CopySongs

  • Problem with my driver i think

    Well my iPod does not show up in itunes and I followed dome guides on here and other places and most of them said up date your driver. This is what happened
    [IMG]http://i45.photobucket.com/albums/f71/Avenger_0/IPOD1.jpg[/IMG]
    [IMG]http://i45.photobucket.com/albums/f71/Avenger_0/Ipod2.jpg[/IMG]

    Hello there,
    And welcome to Apple Discussions!
    Take a look at this Apple support document related to this issue. You may need to completely uninstall and re-install your system's USB drivers.
    http://support.apple.com/kb/ts1538
    B-rock

  • Memory problems with my a215?

    Hi, for more than a year  i bought (unfortunately) an a215-4817, and since that day i am having anything else but problems. Now i am having problems with the memory i think. At first my laptop freezed, keyboard was not responding or came out those famous blue screens. In all cases i must shutdown the computer pressing down the power button for a few secs, after that when i tried to start it again didnt do anything, i could only hear the fan working, some disk reading noise but the screen was off and never went on and show me at least the toshiba logo.  The only way i had to fix this was first taking the battery out and pressing the power button for more than 10 secs. Later, i had to take both memory modules out besides the battery. At that moment i came to the windows event viewer and see some "WHEA-logger" warnings that talk about "TLB erros", "bus or interconection error" and ''Hierarchy memory error". Today the only way i can boot up my computer is using only one memory module placed on the first slot. That is the reason i am using it with only 1GB. I am really lost with this, run a lot memory tests ( microsoft Vista has one and Memtest+86 that comes in Ubuntu CD) and any of them trow me some error. 
    Might have broken the memory controller of slot 2?or maybe something with the dual channel controller? can be a problem with the bios? i have version 2.0, never gave me problem but could it be corrupt? I have tried to reinstall it but the installer hasnt the option to reinstall, where can i download the old version and install it again so i can reinstall de versiin 2.0?. And my last question is if somebody knows where to toshiba should i write to tell them how mad i am with them, this laptop was the worst thing i have ever bought, and their customer service in latin america (i am from argentina) is terrible.
    So if somebody have any idea of what the problem could be, i will be grateful. Sorry about my english.
    Thanks, and greetings from argentina! 
    Solved!
    Go to Solution.

    YOUR SPECS:AMD Turion™ 64 X2 Dual-Core Mobile Technology TL58• AMD M690VMemory4  • Configured with 2048MB DDR2 SDRAM 
    You have a really good unit mobo wise to utilize.  With those initial problems you should have taken it to an authorized service provider and have unit checked out. Be that as it may-why you took out the memory modules is beyond me, and yes it is feasible that damage to the board housing or module may have occurred.  Look at the module(s) and see if you observe cracks in the gold thread or board crack, especially where the split notch is. Suggest that you recheck the seating of the memory module until you hear a click noise. Check within the housing area for a small sinle cable and ensure if there it is connected.
     WHEA-Logger situation..... response is as follows.
    A corrected hardware error occurred.
    Error Source: Corrected Machine Check
    Error Type: Memory Hierarchy Error
    TLB = translation lookaside buffer, part of the MMU used to perform virtual mapping).  Machine check errors are hardware errors - this error is telling you that the CPU detected a hardware error but was able to correct it.  This is not a good sign - check temperatures and voltages.   Disabling windows reporting of machine check errors will simply ignore the problem - it will still exist! (and its highly likely that if you are getting correctable errors you are also getting uncorrectable errors sometimes).
    Too resolve: Locate the Recovery disc and reset to factory specs, with a backup of all items you wish to save before attempting.

  • Problem with NEO2 and sata controller card

    1.Product Type: MSI K8N Neo2 Platinum (MS-7025)
    and the controller card is a InnoVision DM-8301 and the hard drive is a Seagate ST3320620AS
    2.BIOS version: The newest one, 1C0 or something.
    3.External VGA Type: Geforce 6800 GT
    4.CPU Type: AMD 64 3500+
    5.Memory Type: G Skill ZX 2048mb.
    6.Power Supply Type:
    7.Operating System: Xp Pro
    8.Problem Description:
    Hello. I have a strange problem with my controllercard. I wrote this text to InnoVision suport and they send me files and bios updates for a whole week and it was still the same problem. And then i tried the card in an older computer and everything worked fine.
    I wrote
    "Hello. I got some problems with my new controller card. I can find my new harddrive ,that's conected to the controller card, when iam inside windows and it's seems to be no problem. I can look on every seting on it and everywhere i look i can read "No problem". I Also did some test with the seatools programe and everything was fine. But when i schould copy files to it the coumputer start lagging after a few seconds and i cant do anything. After a while i can move the mouse around but the it laggs again. My computer is overclocked at the time but i have tried to use the harddrive when it's not clocked also. Also when im goin in to teh controlpanel and starts the setings for Sillicon Images sata controll and have music on my computer, the music laggs for a very very short moment. Something must be wrong and i can not find it."
    It's still the same problem in my computer. The older computer had a MSI moderboard with a VIA chip and i have a nForce 3. InnoVison said i should talk to you about this problem. I have 3 harddrives but i use this controllercard because i want to have my computer overclocked and then i can't use 2 of the sata ports as i think you know.
    I would be very thankful if you could help me with this problem.
    //Martin

    I've used a noname SATA pci card (non raid) with SIL3112 on my neo2 without problems with 1C bios.
    Think you may try with a disk lower than 48bitLBA need (137GB barrier), eg a 120GB disk
    Quote:
     have the InnoVision EIO DM-8301 and had alot of problems using it with WD 160MB SATA drive.
    I am using Intel 865 based MB with 2 original SATA channels. The original SATA channels are bootable.
    I could not used the EIO card with 160G HDD. The whole setup is working only after I connected oine of my 120G Segate SATA HDD to the EIO Sata card.
    I think this card do not properly support HDD above 120G.
    Please respond to: [email protected]
    http://www.devhardware.com/forums/storage-devices-80/sata-as-boot-20080-2.html
    Btw: you have xp sp2 ?
    48bitLBA is not enabled in the first version.
    http://www.48bitlba.com/winxp.htm
    Edit:
    Here's another with complete different setup and same problems
    http://forum.tweakxp.com/forum/Topic212148-4-1.aspx
    I doubt it has anything to do with your motherboard and/or bios.
    Btw: I looked at innovision and their drivers in download area are very old.
    Get the latest SIL3112 drivers for XP here:
    http://www.siliconimage.com/support/supportsearchresults.aspx?pid=63&cid=3&ctid=2&osid=4&
    And remember 3112 is sata150 only , so it's not sure it will work with your drive at all .
    Anyway it should be set to fixed sata1.5G with jumper - not certain the controller can autonegotiate
    without trouble. You cannot have command queing enabled either , disk support only NCQ and controller TCQ
    so having command queing set ON will cause major conflicts in data transfers.

  • Weird problems with Leopard on iMac G5

    I've started having some weird problems—I think they may have started after running iDefrag, please no discussions about whether to defrag or not, but I'd done it before since upgrading to Leopard and nothing like this ever happened—sometimes while looking at a picture in Preview I'll click outside the frame onto the desktop, but it won't switch to the Finder, no matter how many times I click, also sometimes the computer will go to sleep *while I'm using it* (i.e. moving the mouse); I have set to put the display to sleep after five minutes of inactivity, and the computer never (I donate my CPU cycles).
    Also sometimes when I click on the Firefox icon in the Dock it appears as well in another section (so I have two FF icons at once)--I've been having some problems with FF and I think it's a bad profile but would this be related?
    All this started within the past week or so, but there wasn't a clear-cut before-and-after with the defragging (I did run OWC Media Scanner for the very first time, but it didn't find any errors, so presumably it didn't change anything), so I'm a little stumped. I ran Disk Utility and DiskWarrior, but the former didn't find anything and the latter only found a custom flag icon error.

    Check out the following links:
    http://support.apple.com/kb/TS1541 Mac OS X 10.5: Troubleshooting installation, startup, and login issues
    Mac OS X v10.5 Leopard Troubleshooting/Support
    Leopard Forums
    Keep calling Apple while you still its 90 days of free phone tech support.

  • Problem with ear speaker

    hello. when i make a call i hear some shshshsh in ear speaker . is that normal too it not very high sound but its still there ..but when i use my headset i didnt hear shshsh sound . its new phone i just bought it yesterday .. is that normal or i go back to store to fix it .. its not very high sound but when i focus i hear shshshshsh in ear speaker 

     the problem at number 2 look at picture when i speak i hear some shshsh..the sim card new and its very good too problem with ear speaker i think i want to know its normal or not becouse when i use headset i didnt hear that shssh sound .. 

  • Problem with BPC 10 REST SERVICE. (Write-Back  BAdI)

    Hello!
    We have implemented a Write-Back BAdI order to write values ​​to a parent and copy those values ​​to their children in the hierarchy. Proper operation.
    Then through the Default Logic we are making various calculations (many to be honest), based on the data recorded with the Write-Back BADI.
    The problem arises when we try to write in a parent hierarchy with many children.
    We receive the following message in Excel.
    We have configured the service as follows
    The transaction st22 says nothing about our problem.
    If I go to log the EPM Add-in for Excel see the following. A problem with REST service (I think that is the PROBLEM)
    Write-Back BAdI writes values properly.
    Thank you!

    Thanks for answering.
    Yes, if I try to write in a parent without Default.lgf there is no problem. I performed the test to the parent node of all hierachy.
    I send the Default.lgf and the others scripts .
    I think the problem is that the communication between BPC and Netweaver is lost, which is done through the REST service??
    thank you very much.

Maybe you are looking for

  • Can't motion tween in mask CS4

    I'm building a drop down menu in flash CS4. I have followed the directions meticulously...3 times... and still I can't get a mask to accept a motion tween. Thanks for you help Sb! Little Rock

  • I feel stupid asking this but here goes...

    I upgraded to the new Numbers and when you save your spreadsheet and say your cursor is on row 500 column 10 and next time you open that spreadsheet how do you get back to that position without scrolling or paging down a million times?  In an Excel s

  • Internet explorer wont open.

    When I try to open IE it just flashes for a breif secon and closes. There are no error messages.

  • Query on Delivers!!

    Hi All, Is it possible to split a report on the basis of a key and then deliver it to different users on a delivery device using OBIEE(Oracle Delivers). For example, say I m generating a report by placing region column in the sections portion of a pi

  • Register and unregister locations using ombplus script

    hi how to register and unregister the locations using ombplus scripts. any help would be appreciated. thanks, Keka