When I use %Header:my-header-id% in the Btach Merge connector, I just get files called “.xml”

Does this work?
When I use %Header:my-header-id% in the Btach Merge connector, I just get files called “.xml”

Does this work?
Best answer by James B
I think you might be able to manage this in the SQL Server connector right off the bat.
Do I understand that you’re selecting from some find of view that has records that represent multiple groups with a shared key column? Say I’ve got a simple table like this:
| ID (key) | OrderNumber | Customer | ItemName | Quantity |
|---|---|---|---|---|
| 1 | PO001 | James Blasingame | Keyboard | 1 |
| 2 | PO001 | James Blasingame | Mouse | 1 |
| 3 | PO002 | Teddy Blasingame | Vehicle Trucks Book | 2 |
| 4 | PO002 | Teddy Blasingame | Toy Truck | 3 |
| 5 | PO003 | Tommy Blasingame | Fuzzy Fox | 2 |
| 6 | PO003 | Tommy Blasingame | Ball | 1 |
Ordinarily, if these orders are contained in another table, I can query that table for unique records, and then use a foreign key to select from child tables, but in a given output mapping I can also call the same table more than once to achieve the same effect.
If I configure an output mapping against this table like:
<Items>
<OrderLines table="`OrderLines`" allColumns="true" selectQuery="SELECT DISTINCT `OrderNumber` FROM `OrderLines`">
<OrderNumber key="true" />
<OrderLines table="`OrderLines`" selectQuery="SELECT * FROM `OrderLines` WHERE `OrderNumber` = ${OrderNumber}">
<ID type="int" key="true" />
<Customer />
<ItemName />
<OrderNumber />
<Quantity type="int" />
</OrderLines>
</OrderLines>
</Items>
Then I can configure an output mapping where the first query just selects the distinct keys from the table, and uses it as a WHERE clause to select unique records. If I leave the database connectors Max Records setting at 0, this will output one file per group, like so:
<?xml version="1.0" encoding="UTF-8"?>
<Items xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<OrderLines>
<OrderNumber>PO002</OrderNumber>
<OrderLines>
<ID>3</ID>
<Customer>Teddy Blasingame</Customer>
<ItemName>Vehicle Trucks Book</ItemName>
<OrderNumber>PO002</OrderNumber>
<Quantity>2</Quantity>
</OrderLines>
<OrderLines>
<ID>4</ID>
<Customer>Teddy Blasingame</Customer>
<ItemName>Toy Truck</ItemName>
<OrderNumber>PO002</OrderNumber>
<Quantity>3</Quantity>
</OrderLines>
</OrderLines>
</Items>
In addition, there’s another feature that you can take advantage of - if you notice the parent query, I edited the first query to define “OrderNumber” as the key column. That isn’t really the case, but if I instruct the connector that it is on that query, I can set the Local File Scheme on the connector to:
%PK%.xml
The net effect of this is that the output files are renamed with the value in that column:

I’ve zipped up the connector and sample SQLite company file used for this example here. Are you able to use this to group your records into named files at the first step?
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.