Hey everyone,
I am looking for a way that I can query a database with multiple SQL Queries and then, once I have the results of the queries (in XML), merge the separate XML together into one XML document, using reverse paths. My reason for doing this is related to the concept of Parallel Details (same data, with different manipulations applied).
For example, 3 Queries:
SELECT * FROM Customer;
SELECT * FROM Purchase_order;
SELECT * FROM Line_Item;
Query 1 Results:
<customer>
<cust_id>2</cust_id>
<fname>John</fname>
<lname>Doe</lname>
</customer>
Query 2 Results:
<purchase_order>
<order_id>2</order_id>
<cust_id>2</cust_id>
<shipped>7/7/2009</shipped>
</purchase_order>
Query 3 Results:
<line_item>
<line_id>2</line_id>
<order_id>2</order_id>
<quantity>7</quantity>
</line_item>
Desired Output:
<collection>
<customer>
<cust_id>2</cust_id>
<fname>John</fname>
<lname>Doe</lname>
</customer>
<purchase_order>
<order_id>2</order_id>
<cust_id>2</cust_id>
<shipped>7/7/2009</shipped>
</purchase_order>
<line_item>
<line_id>2</line_id>
<order_id>2</order_id>
<quantity>7</quantity>
</line_item>
</collection>
This looks like it would be easy, but my SQL queries can return a lot of customers, and a lot of purchase orders and line items, and I need to be able to match them all up.
I cannot use one SQL Query with Joins that will collect all of this information at once.
Has anyone ever seen anything like this done? Any ideas?
Thanks.