regex - i'd like to create from a simple XML text SQL using RegExp -


Just simple, I have such data, thousands of & lt; MigratedData & gt; Elements, in general, we use them in the XMLLoader application, but this is a special case, I have to update the database using mapping:

& lt; Migrated data & gt; & Lt; MigrationNr & gt; 12123456 & lt; / MigrationNr & gt; & Lt; IdOldSystem & gt; 33398088801 & lt; / IdOldSystem & gt; & Lt; / Migrated data & gt;

& lt; Migrated data & gt; & Lt; MigrationNr & gt; 6767 & lt; / MigrationNr & gt; & Lt; IdOldSystem & gt; 21100077878 & lt; / IdOldSystem & gt; & Lt; / MigratedData & gt;

& lt; Migrated data & gt; & Lt; MigrationNr & gt; 767,066 & lt; / MigrationNr & gt; & Lt; IdOldSystem & gt; 4545566767676 & lt; / IdOldSystem & gt; & Lt; / MigratedData & gt;

I will create such SQL statements:

Update Table_1 T1 Set T.CountNR = IDOLS SYSTEM__ Value__from_XML
Where T.ID = MigrationRG From__ XML;

Is there an easy way to get this regxp, which is better in ultrared regular expression engine?

Why not use simple xslt changes on your xml and as you have specified, update script Make it?

In this way your XML

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Root & gt; & Lt; MigratedData & gt; & Lt; MigrationNr & gt; 12123456 & lt; / MigrationNr & gt; & Lt; IdOldSystem & gt; 33398088801 & lt; / IdOldSystem & gt; & Lt; / MigratedData & gt; & Lt; MigratedData & gt; & Lt; MigrationNr & gt; 6767 & lt; / MigrationNr & gt; & Lt; IdOldSystem & gt; 21100077878 & lt; / IdOldSystem & gt; & Lt; / MigratedData & gt; & Lt; MigratedData & gt; & Lt; MigrationNr & gt; 767,066 & lt; / MigrationNr & gt; & Lt; IdOldSystem & gt; 4545566767676 & lt; / IdOldSystem & gt; & Lt; / MigratedData & gt; & Lt; / Root & gt;  

And implement XSLT in this way:

   & Lt; Xsl: template match = "migrated data" & gt; Table_1 t1 set t1.accountNr = & lt; Xsl: Select Value = "./ idOldSystem" /> Where t1.id = & lt; Xsl: Select the value = "./migration_nar" /> ; & Lt; / XSL: Templates & gt; & Lt; / XSL: stylesheet & gt;  

Your result will be

  update table_1 t1 set t1.accountNr = 33398088801 where t1.id = 12123456; Update table_1 T1 set t1.accountNr = 21100077878 where t1.id = 6767; Table_1 T1 set t1.accountNr update = 4545566767676 where t1.id = 767066;  

Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -