When the IncludeAllColumns parameter is not specified, the default behavior is that the query returns only explicitly specified columns. If no columns are specified, the query returns all defined columns in the table.
The design of your XML data model and SQL table columns is key for ease of use. When XML node and table column names are identical, this method maps them automatically.
Map function A map function can be used to transform values before saving, for example, encrypting a password before saving it to the database. See $Database.ImportFromXml for more details.
$Database.ExportToXml({TargetSchema:'MySchema',TargetTable:'Accounts',XPath:'Accounts/Account',// map values whose names are not identical to SQL column namesMap:function(accountXml){accountXml.SetValue('Password',this.Password);accountXml.SetValue('Type/Code',this.AccountType);}});
// Export corporations with the subcorporations$Database.ExportToXml({Parameters:{TargetSchema:'Evrak',TargetTable:'Kurum'},XPath:'Corporations/Corporation',SubQueries:[{Name:'SubCorporations'}]});
Info
Assume you have two SQL tables, Corporations and SubCorporations, and a one-to-many relation from the Corporations table to the SubCorporations table, also named SubCorporations. Also, do not forget to set this relation's update rule to Cascade.
Having defined the table columns with identical names to the XML fields, this code lets you export each corporation from SQL table into XML fields, exporting also its related SubCorporations into the SubCorporations XML nodes and resulting in the following XML data.