Views:
TypeRead/writeAuthorAvailability
Data providerWriteFinbourneProvided with LUSID

Providing you have access control permissions, you can use the Lusid.Portfolio.Txn.Property.Writer provider to write a Luminesce SQL query that either upserts or deletes properties to or from transactions in LUSID.

Note: For portfolios, portfolio groups, instruments, people and legal entities, use the Lusid.Property.Writer property provider. For other entities, configure its entity provider to 'inline' properties into the Luminesce catalog first.

You must construct a valid table of data to write, one property per record. Lusid.Portfolio.Txn.Property.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 transaction property; that is, create a property if it does not exist, and update it if it does. This is the default operation if you omit WriteAction.
  • Delete a transaction property.

See also: Lusid.Portfolio.Txn.Property

Basic usage

@table_of_data = <select-statement>;
select * from Lusid.Portfolio.Txn.Property.Writer where toWrite = @table_of_data;

Query parameters

Lusid.Portfolio.Txn.Property.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.Portfolio.Txn.Property.Writer' and FieldType = 'Parameter';

Data fields

Lusid.Portfolio.Txn.Property.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:

OperationSpecify using...Mandatory fieldsNotes
Upsert'Upsert' as WriteAction (or omit)TxnId
PortfolioScope
PortfolioCode
PropertyScope
PropertyCode
Value
The Value field is a text field, so you should supply the property value as a string, for example 'true' as Value or '10.5' as Value or '2020-01-01' as Value. Providing it is meaningful to do so, Luminesce automatically casts the value to the data type of the underlying property type, or raises a write error if not. For more information, and for nuances of writing time-variant and multi-value properties, see this article.
Delete'Delete' as WriteActionTxnId
PortfolioScope

PortfolioCode
PropertyScope
PropertyCode
 

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.Portfolio.Txn.Property.Writer' and FieldType = 'Column';

Write errors

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.Portfolio.Txn.Property.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. For more information on nuances of writing different kinds of property to LUSID entities, see this article.

Example 1: Add a property to a transaction

In this example, LUSID adds a property defined as an exchange code to an existing transaction. The query defaults to the 'Upsert' action as no explicit WriteAction is specified.

@table_of_data = select 'Finbourne-Examples' as PortfolioScope, 'Global-Equity' as PortfolioCode,
'Finbourne-Examples' as PropertyScope, 'Global-Equity13' as TxnId, 'ExCo' as PropertyCode, 'FRA' as Value;
select * from Lusid.Portfolio.Txn.Property.Writer where ToWrite = @table_of_data;

Example 2: Delete a property from a transaction

In this example, the explicit use of 'Delete' as WriteAction deletes a property for a particular transaction.

@table_of_data = select 'Finbourne-Examples' as PortfolioScope, 'Global-Equity' as PortfolioCode, 
'Finbourne-Examples' as PropertyScope, 'Global-Equity18' as TxnId, 'ExCo' as PropertyCode, 'Delete' as WriteAction;
select * from Lusid.Portfolio.Txn.Property.Writer where ToWrite = @table_of_data;

Example 3: Add multiple properties to multiple transactions

In this example, eight exchange code properties are added to eight different transactions at the same time using the default WriteAction.

@vals = values
('Global-Equity11', 'NYSE'),
('Global-Equity12', 'LON'),
('Global-Equity13', 'FRA'),
('Global-Equity14', 'JPX'),
('Global-Equity15', 'FRA'),
('Global-Equity16', 'LON'),
('Global-Equity17', 'NYSE'),
('Global-Equity18', 'NYSE');
@table_of_data = select 'Finbourne-Examples' as PortfolioScope, 'Global-Equity' as PortfolioCode, 
'Finbourne-Examples' as PropertyScope, column1 as TxnId, 'ExCo' as PropertyCode, column2 as Value from @vals;
select * from Lusid.Portfolio.Txn.Property.Writer where ToWrite = @table_of_data;