Type | Read/write | Author | Availability |
Data provider | Write | FINBOURNE | Provided with LUSID |
Providing you have sufficient access control permissions, the Lusid.GeneralLedgerProfile.Mapping.Writer
provider enables you to write a Luminesce SQL query that sets mappings for an existing general ledger profile. See how to create a general ledger profile.
You must construct a valid table of data to write, one mapping per record. Lusid.GeneralLedgerProfile.Mapping.Writer
lists the fields (columns) available to populate with values for each record, and has a set of parameters to help you construct a valid table.
Note the following:
- Your query replaces any existing mappings in the general ledger profile. To retain existing mappings, include them in your query.
- The order in which mappings are specified in a general ledger profile is significant; LUSID uses the first matching mapping found. You can use the
MappingPriority
field to set the order of mappings.
See also: Lusid.GeneralLedgerProfile.Mapping
Basic usage
@table_of_data = <select-statement>; select * from Lusid.GeneralLedgerProfile.Mapping.Writer where ToWrite = @table_of_data;
Query parameters
Lusid.GeneralLedgerProfile.Mapping.Writer
has parameters that help you construct a valid table of data to write.
Note: The ToWrite
parameter is mandatory and used to actually write the table of data into LUSID.
To list available parameters, their data types, default values, and an explanation for each, run the following query using a suitable tool:
select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Lusid.GeneralLedgerProfile.Mapping.Writer' and FieldType = 'Parameter';
Data fields
Lusid.GeneralLedgerProfile.Mapping.Writer
lists the fields you can populate in your table of data to write.
The following fields are mandatory to include in the table of data:
Mandatory fields | Notes |
| For information on the syntax of You can optionally populate the
|
To list all available fields, their data types, whether fields are considered 'main', and an explanation for each, run the following query using a suitable tool:
select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.GeneralLedgerProfile.Mapping.Writer' and FieldType = 'Column';
Write errors
We recommend examining the results of every write query using one or more of the WriteError
, WriteErrorCode
and WriteErrorDetail
fields.
For each record in the table of data to write, Lusid.GeneralLedgerProfile.Mapping.Writer
returns an error code. If the operation is successful, the error code is 0
. If unsuccessful, a positive error code and explanation help you discover why LUSID considers the operation invalid.
Examples
Note: For more example Luminesce SQL queries, visit our Github repo.
Example 1: Add a single mapping
Any existing mappings in the general ledger profile are replaced.
@data_to_write = select 'STEM' as GeneralLedgerProfileCode, 'Abor' as ChartOfAccountsScope, 'Standard' as ChartOfAccountsCode, 'GeneralLedgerAccountCode eq ''1-Investments''' as MappingFilter, 'EconomicBucket' as Level1; select * from Lusid.GeneralLedgerProfile.Mapping.Writer where ToWrite = @data_to_write;
Example 2: Add multiple mappings in a particular order
The MappingPriority
field determines the order in which mappings are evaluated; LUSID uses the first matching mapping found. Lower numbers take precedence and are evaluated earlier.
@mappings = values ('GeneralLedgerAccountCode eq ''1-Investments''', 'Instrument.AssetClass', 'DefaultCurrency', 'EconomicBucket', 1), ('GeneralLedgerAccountCode neq ''1-Investments'' and EconomicBucket startswith ''PL''', 'Instrument.AssetClass', 'EconomicBucket', null, 2), ('True', 'Instrument.AssetClass', null, null, 3) ; @data_to_write = select 'STEM' as GeneralLedgerProfileCode, 'Abor' as ChartOfAccountsScope, 'Standard' as ChartOfAccountsCode, column1 as MappingFilter, column2 as Level1, column3 as Level2, column4 as Level3, column5 as MappingPriority from @mappings; select * from Lusid.GeneralLedgerProfile.Mapping.Writer where ToWrite = @data_to_write;