Type | Read/write | Author | Availability |
Write | FINBOURNE | Provided with LUSID |
Providing you have sufficient access control permissions, the Lusid.AborConfiguration.Writer
provider enables you to write a Luminesce SQL query that either creates or deletes ABOR configuration modules in LUSID.
Note: By default,
Lusid.AborConfiguration.Writer
cannot add properties to modules. To do this, you must first configureLusid.AborConfiguration.Writer
to 'inline' properties. See how to do this.
You must construct a valid table of data to write, one module per record. Lusid.AborConfiguration.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.
Your query can use the WriteAction
field to perform one of the following operations:
Upsert a module; that is, create a module if it does not already exist, and update just inlined properties if it does. Note it is not currently possible to update the core data fields of an existing module. This is the default operation if you omit
WriteAction
.Delete a module.
See also: Lusid.AborConfiguration
Basic usage
@table_of_data = <select-statement>;
select * from Lusid.AborConfiguration.Writer where toWrite = @table_of_data;
Query parameters
Lusid.AborConfiguration.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.AborConfiguration.Writer' and FieldType = 'Parameter';
Data fields
Lusid.AborConfiguration.Writer
lists the fields you can populate in your table of data to write.
Depending on the operation you want to perform, the following fields are mandatory to include in the table of data:
Operation | Specify using... | Mandatory fields | Notes |
Upsert |
|
| When creating a new module:
When updating an existing module, core data fields are ignored. You can only update inlined properties. |
Insert |
|
| |
Update |
| You can only update inlined properties of an existing module, not any of the core data fields. | |
Delete |
|
|
|
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.AborConfiguration.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.AborConfiguration.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: Create a module
Upsert is the default operation if you omit the WriteAction
field. Note multiple codes can be specified in the PostingModuleCodes
field as a comma-and-space separated list; these must exist in the CoA, and are evaluated in the order specified, so in this example posting rules in the DailyNAV
posting module are evaluated before posting rules in the EoYNAV
posting module:
@data_to_write = select 'Abor' as AborConfigurationScope, 'DailyNAV' as AborConfigurationCode, 'Abor' as ChartOfAccountsScope,
'Standard' as ChartOfAccountsCode, 'Recipes' as RecipeScope, 'Equities' as RecipeCode, 'Daily NAV' as DisplayName, 'Daily NAV module' as Description,
'DailyNAV, EoYNAV' as PostingModuleCodes;
select * from Lusid.AborConfiguration.Writer where ToWrite = @data_to_write;
Example 2: Create multiple modules in the same scope
@@scope = select 'Abor';
@modules = values
('DailyNAV', 'Daily NAV', 'ABOR configuration module for daily NAV', 'DailyPostingModule'),
('EoYNAV', 'End of year NAV', 'ABOR configuration module for end of year NAV', 'EOYPostingModule'),
('QNav', 'Quarterly NAV', 'ABOR configuration module for quarterly NAV', 'QPostingModule')
;
@data_to_write = select @@scope as AborConfigurationScope, column1 as AborConfigurationCode, @@scope as ChartOfAccountsScope,
'Standard' as ChartOfAccountsCode, 'Recipes' as RecipeScope, 'Equities' as RecipeCode,
column2 as DisplayName, column3 as Description, column4 as PostingModuleCodes from @modules;
select * from Lusid.AborConfiguration.Writer where ToWrite = @data_to_write;
Example 3: Delete a module
@data_to_write = select 'Abor' as AborConfigurationScope, 'DailyNAV' as AborConfigurationCode, 'Delete' as WriteAction;
select * from Lusid.AborConfiguration.Writer where ToWrite = @data_to_write;