Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Parsing an XML file inside a stored procedure

Author  Topic 

irs2k3
Starting Member

22 Posts

Posted - 2007-07-26 : 15:23:57
Hey Guys,

what I am trying to do is to send an xml file to a stored procedure to do multiple inserts or deleted into a specific table.

The XML file schema is as follows :

<DocumentElement>
<Notes>
<DataField> 1,4 </DataField>
<Value> False </Value>
</Notes>
<Notes>
<DataField> 1,34 </DataField>
<Value> True </Value>
</Notes>
<Notes>
<DataField> 4,56 </DataField>
<Value> True </Value>
</Notes>
</DocumentElement>

What I want to do is to iterate through this XML file inside a Stored Procedure and Extract DataField value and the Value value foreach Notes node and then based on the Value value if it is True --> insert into Table (NotesID, ProjectRoleID) Values 1 and 34
if its False delete from Table where ProjectRole = 1 and NotesRole = 34 etc...

The ProjectRoles Table has the following schema : ID, ProjectID, RoleID.

This is the algorithm :

Iterate through the XML file
enter each Notes node
get the Value value --> if value = True --> Insert into ProjectRole the value 1 34
else if Value value = False --> Delete from ProjectRole Where NoteID = 1 and RoleID = 34
....

Plus I want to insert try catch blocks to catch if a record was not successfully deleted or inserted

Any help would be appreciate it

Thanks.

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-26 : 15:35:31
this is basicaly the same request as yours:
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=86922

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page
   

- Advertisement -