Home Page › Forums › BizTalk 2004 – BizTalk 2010 › Help – Entering multiple child records using sql adapter
- This topic has 3 replies, 1 voice, and was last updated 6 years, 10 months ago by
community-content.
-
AuthorPosts
-
-
July 24, 2006 at 9:12 PM #15102
promote the foreign key value in your schema for table 2. you will then need to loop each time for that message and insert the foreign key so that SQL knows who the parent is.
now, as i am not 100% sure of your situation let me give you a broad heads up on what i am saying.
each sql adapter schema is bound to one table (typically) so in other words, think of it as an insert statement in sql. Insert into foo (boo,bla) values (a,b) scope_identity;
you would then take the resulting primary key and insert that into the children tables as many times as they occur
insert into foochild (blah,blah,foo_fk) values (a,b,oldkey);you are either not looping on the children (hence only the top child gets inserted) or you are feeding this schema in to insert to two tables (sort of like appending the insert statements) and hence will only insert the parent and first child.
solution:
create a map that breaks out the children. basically loop on that child structure (<OutputValues>) and creates a whole new message for that data. of course, add the foreign key and feed it to the sql adapter. That will get all the children into the db….
translating that into C# methodology :
nodelist A = xdoc.selectnodes(‘\\\\outputvalues);
foreach(node x in A)
//extract node data, create sql statement and shoot to your db…return;
now this can be put in an expression shape straight away, or into an external C# dll that is called from an expression (my preference for the power of a C# class file compared to an expression) or doing it using biztalk orchestration shapes (also a great solution, but sql adapters in biztalk are still weak in my opinion).
hope this helps and feel free to ask me again if it doesnt
-
July 21, 2006 at 3:35 PM #15103
Hi,
I have two tables Table1 and Table2 in SQL 2000 db instance. I need to enter following data(parent-child) in these two tables.
— sample file start——
<?xml version=\”1.0\” encoding=\”utf-8\” ?>
– <ns0:SampInst xmlns:ns0=\”http://TestFFSchemaProj1.SampInstSchema1\”>
– <OutputHeader>
<StrVariable1 />
<ID>EXP-4</ID>
<Initials>Bc</Initials>
<Title>manager</Title>
<Date>01.01.2002</Date>
– <OutputValues>
<Time>10:15:29</Time>
<var1>107.0 1</var1>
<var2>06.9</var2>
<var3>75.0</var3>
<var4>80.6</var4>
</OutputValues>
– <OutputValues>
<Time>10:15:34</Time>
<Lref>107.0 1</Lref>
<var2>07.6</var2>
<var3>75.0</var3>
<var4>81.3</var4>
</OutputValues>
– <OutputValues>
<Time>10:15:44</Time>
<Lref>100.0 1</Lref>
<var2>07.6</var2>
<var3>85.0</var3>
<var4>83.3</var4>
</OutputValues>
– <ReferenceNumber>
<ReferenceID>12884566</ReferenceID>
<ReferenceDate>2006-07-21T10:14:56</ReferenceDate>
</ReferenceNumber>
</ns0:SampInst>— sample file end——
I am able to enter the data specified whithin <outputheader> into Table1 successfully. But I am only able to enter one child record from from the element <OutputValues> whithin Table2. I need to enter all rest of the child records whithin Table2.
Need help..
-
July 28, 2006 at 4:34 PM #15104
Thanks for your meaningful feedback.. I also looked at the example available at,
[url]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/biztalkserver.asp?frame=true [/url]
and then I updated the schema and the mapper in my project to solve my issue.
Great help from you and from that example.
Thanks.
-
-
-
July 31, 2006 at 3:35 PM #15101
See also my blog: How to update many records from Biztalk using a Stored Proc.
http://nealwalters.blogspot.com/2005_12_01_nealwalters_archive.html
-
-
AuthorPosts
- The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.