Lusid.ReferenceList.Writer

Prev Next

Type

Read/write

Author

Availability

Data provider

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.

NotePropertyList 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

@table_of_data = <select-statement>;
select * from Lusid.ReferenceList.Writer where toWrite = @table_of_data;
SQL

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';
SQL

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

'Upsert' as WriteAction (or omit)

Scope

Code

ListType

Name

Value

Delete

'Delete' as WriteAction

Scope
Code

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';
SQL

We recommend examining the results of every write query using one or more of the WriteErrorWriteErrorCode 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.

Note: For more example Luminesce SQL queries, visit our Github repo.

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;
SQL
@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;
SQL
@@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;
SQL
@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;
SQL