Type | Read/write | Author | Availability |
---|---|---|---|
Write | FINBOURNE | Provided with LUSID |
Providing you have sufficient access control permissions, the Lusid.ReferenceList.Writer
provider enables you to write a Luminesce SQL query that either upserts or deletes reference lists in LUSID.
Note:
PropertyList
is not currently supported. You can use the LUSID API or LUSID web app instead, see how.
You must construct a valid table of data to write, one reference list per record. Lusid.ReferenceList.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 reference list; that is, create a reference list if it does not exist, and update it if it does. This is the default operation if you omit
WriteAction
.Delete a reference list.
See also: Lusid.ReferenceList
Basic usage
@table_of_data = <select-statement>;
select * from Lusid.ReferenceList.Writer where toWrite = @table_of_data;
Query parameters
Lusid.ReferenceList.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.ReferenceList.Writer' and FieldType = 'Parameter';
Data fields
Lusid.ReferenceList.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 |
---|---|---|
Upsert |
|
|
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.ReferenceList.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.ReferenceList.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 decimal reference list
Upsert is the default operation if you omit the WriteAction
field.
@refListValues = values
(1),
(2),
(3);
@data_to_write = select 'Finbourne-Examples' as Scope, 'My-Decimal-List' as Code, 'My decimal list' as Name,
'List containing three decimal values' as Description, 'decimal,anotherTag,myOtherTag' as Tags, 'DecimalList' as ListType,
column1 as Value from @refListValues;
select * from Lusid.ReferenceList.Writer where ToWrite = @data_to_write;
Example 2: Create a portfolio reference list
@refListValues = values
('Finbourne-Examples/Portfolio'),
('Finbourne-Examples/EU'),
('oms/valuation');
@data_to_write = select 'Finbourne-Examples' as Scope, 'My-Portfolio-List' as Code, 'My portfolio list' as Name,
'List containing three portfolio IDs' as Description, 'portfolio,anotherTag,myOtherTag' as Tags, 'PortfolioIdList' as ListType,
column1 as Value from @refListValues;
select * from Lusid.ReferenceList.Writer where ToWrite = @data_to_write;
Example 3: Create or update multiple reference lists in the same scope
@@scope = select 'Finbourne-Examples';
@refListValues = values
('Currency-List', 'Currency Instrument List', 'Instrument Reference List containing currencies', 'InstrumentList', 'CCY_GBP', 'instrument,currencies,acceptedCurrencies'),
('Currency-List', 'Currency Instrument List', 'Instrument Reference List containing currencies', 'InstrumentList', 'CCY_EUR', 'instrument,currencies,acceptedCurrencies'),
('Currency-List', 'Currency Instrument List', 'Instrument Reference List containing currencies', 'InstrumentList', 'CCY_USD', 'instrument,currencies,acceptedCurrencies'),
('My-Decimal-List', 'My decimal list', 'List containing two decimal values', 'DecimalList', 5, 'decimal,anotherTag,myOtherTag'),
('My-Decimal-List', 'My decimal list', 'List containing two decimal values', 'DecimalList', 6, 'decimal,anotherTag,myOtherTag');
@refLists = select @@scope as Scope, column1 as Code, column2 as Name, column3 as Description,
column4 as ListType, column5 as Value, column6 as Tags, 'Upsert' as WriteAction from @refListValues;
select * from Lusid.ReferenceList.Writer where ToWrite=@refLists;
Example 4: Delete a reference list
@data_to_write = select 'Finbourne-Examples' as Scope, 'My-Decimal-List' as Code, 'Delete' as WriteAction;
select * from Lusid.ReferenceList.Writer where ToWrite = @data_to_write;