MySQL Forums
Forum List  »  Microsoft SQL Server

Looping through a table to select one column from each row and then performing XML transformation ExtractValue for each value
Posted by: Rahul Kumar
Date: July 06, 2010 08:14AM

I have to lookup a table "tasks" for distinct process id. schema is attached.

For each process id I have to perform the below action:

select input_xml from tasks where process_id = 212943 INTO @xml;

SET @a= ExtractValue(@xml, '//*[8]');
SET @b= ExtractValue(@xml, '//*[1]');
SET @d= ExtractValue(@xml,'//*[14]');
SET @f= ExtractValue(@xml, '//*[16]');
SET @g= ExtractValue(@xml, '//*[3]');
SET @h= ExtractValue(@xml, '//*[4]');
SET @i= ExtractValue(@xml, '//*[6]');
SET @j= ExtractValue(@xml, '//*[7]');

INSERT INTO `complaints1`(`ComplaintSub_Category`,`ComplaintID`,`Complaint_Raise_Date`,`Complaint_Description`,
`Assigned_to`,`Complaint_Status`,`Complaint_Close_Date`,`Division`,`Sub_Division`,`Service_Station`,`ComplaintType`)
VALUES(@a,@b,(SELECT creation_date from tasks where process_id = 212943),@d,
(SELECT tuo.user_id from task_user_owners tuo, tasks t where t.process_id= 212943 and t.id=tuo.task_id),@f,NULL,@g,@h,@i,@j);

How do I achieve this?
Please help ASAP.

Options: ReplyQuote


Subject
Written By
Posted
Looping through a table to select one column from each row and then performing XML transformation ExtractValue for each value
July 06, 2010 08:14AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.