How to load data from XML file into database
Hi,
I am a beginner to Biztalk 2006.
Can anyone please explain
How I can load data from an Input XML file into Database using the Biztalk server?
What all Input ports/messages , Output Ports/messages & orchestration required?.
Thanks in Advance
Hi,
You can do this using either an updategram, or a stored procedure. Updategrams are best when working with inserting multiple records. The basic way to insert data using an update gram is:
Create an xSD schema that represents the structure in the XML file.
Create an XSD schema that matches the SQL database table using the SQL adapter schema wizard.
Create a map that transforms the inbound file to the updategram schema
Deploy the project artifacts to BizTalk server
Create a message channel to receive the inbound file, transform the message, and insert the data using the SQL adapter.
There's a walkthrough for using both updategrams and stored procedures in the following links:
http://msdn2.microsoft.com/en-us/library/aa577899.aspx
http://msdn2.microsoft.com/en-us/library/aa560708.aspx
Regards,
Alan Smith
Hi,
Thanks for the above help.
I could load the XML file using File adapter and move to MSSQL database through the SQL Adapter, using simple orcestrations & map.
BUT, only one record from the XML file is loaded into the database table.
How can I load all the records in XML to database table?..
Do i need to use some functiod in Orchestration ? or Do i need to modify the MAP ?
Thanks in Advance
Loading the XML rows into the Database Table through UPDATEGRAM is one good way.
How about Inserting(multiple rows) through Store Procedure Calls?
The reason being - for every stored procedure calls I want to do some processing before Insert/Delete/Update.
Can somebody kindly throw some lights on this please!
-Alex
One way to insert multiple rows into a table using SQL Adapter is using Updategrams. If this does not work for you then you have to use SQL Adapter with Stored Procedures. You either send one row at a time and this will cause the Stored Proc to be called multiple times or group multiple rows in one XML message and let the stored proc to insert all the rows in that “envelope”. Something like this:
<envelope>
<row … />
<row … />
…
</envelope>
[Please mark the response as "Answer" if it solves your problem.]
Hi
Nicolae!
Very much encouraged reading your post!
I was stucked at the implementation level. Could you possibly share some online resource/projects/articles corresponding to this scenario more precisely?
Thanks once again!
-Alex
Unfortunatelly I don't know about any similar online project, but i still can help you by answering you questions. What solution did you pick up? Updategrams or one XML "envelope" message? What are the problems you are facing?
Nicu
Hi Nicolae,Thanks once again.
I tried using XML envelope and it worked fine. However, the following XML structure is also working :<ns0
chedule xmlns:ns0="http://MyDomain.Schemas.Schedule">
<Table>
<PKCode>A1234</PKCode>
<SDate>2005-12-01</SDate>
<ShiftId>112</ShiftId>
<StartTime>700</StartTime>
<EndTime>1700</EndTime>
<SCode>G</SCode>
<TimeStamp>2006-10-09</TimeStamp>
<ModifiedBy></ModifiedBy>
</Table>
<Table>
<PKCode>B1234</PKCode>
<SDate>2005-12-01</SDate>
<ShiftId>112</ShiftId>
<StartTime>700</StartTime>
<EndTime>1700</EndTime>
<SCode>G</SCode>
<TimeStamp>2006-10-09</TimeStamp>
<ModifiedBy></ModifiedBy>
</Table>
</ns0
chedule>
I am able to insert all the rows into the table with Stored Procedure(SP) after setting the Max Occurs/Min Occurs criteria to unbounded and 1 respectively.
However, these are the following problems now:
- I have generated schema file SQLServiceExec.xsd to work with SP. In my situation I dont require SP to return any output (would be inserting many records).
Q. How do i create a Send only port for SP insert, is that possible?
- The kind of Orchestration I have created is similar to this : http://msdn2.microsoft.com/en-us/library/aa560708.aspx
or (image)
http://msdn2.microsoft.com/en-us/library/Aa560708.34a746e9-b95f-4b75-b2fd-479ff0cc4418(en-us,MSDN.10).gifBased on some condition in the XML node, I want to split the XML file(respective rows) into different folders. Say Pass and Fail.
Well, if I get to this level clear, it would be very helpful.
Can I hear from you again Nicolae?Thanks
Alex
Let me try to understand your problem: you have an orchestration scenario, the orchestration gets the XML message from a FILE receive location (for example), sends the message to SQL, gets a response from SQL (you do not want this response any more) and then sends something to a FILE send port (for example). Is that right?
If this is the case, inside the orchestration you should use a one way send port instead of a two ways send port and of course bind it to a one way send port. This way the message will be sent to SQL and no answer will be sent back.
Regarding the split of message send to the FILE send port in PASS or FAIL, you should use an IF shape inside the orchestration and one send shape on each IF branches. Accordingly you will have two FILE send ports sending messages to two folders.
Please let me know if this is your scenario and if it works. If your scenario is different please describe it as detailed as possible, send over the SP, etc.
[Please mark the response as "Answer" if it solves your problem.]
Nicu
Thanks Nicu, i managed to resolve my issues with your valuable inputs!