Views:
TypeRead/writeAuthorAvailability
Data providerWriteFinbourneProvided with LUSID

The Lusid.Portfolio.Txn.Property.Writer provider enables you to write a Luminesce SQL query that either upserts or deletes one or more properties to or from transactions in LUSID.

Note: The LUSID user running the query must have sufficient access control permissions to both use the provider and modify transaction property data in LUSID. This should automatically be the case if you are the domain owner.

You must construct a valid table of data to write, one property per record. Lusid.Property.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:

OperationMandatory fields in table of data to write
Upsert or delete

PortfolioScope
PortfolioCode
TxnId
PropertyScope
PropertyCode
Value

The Value field shown in the examples below is of type string. You can also quote other data types for use with the Value field, such as boolean, float, or date. For example, you could enter 'true' as Value, or '10.5' as Value, or '2020-01-01' as Value.  As long as the data type matches the definition, then Luminesce casts the data type for the Value field appropriately.

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.

For example, the query:

@table_of_data = select 'Finbourne-Examples' as PortfolioScope, 'Finbourne-Examples' as PropertyScope, 'Global-Equity14' as TxnId, 
'ExCo' as PropertyCode, 'JPX' as Value, 'delete' as WriteAction;
select WriteErrorCode, WriteError, WriteErrorDetail from Lusid.Portfolio.Txn.Property.Writer where toWrite = @table_of_data;

... fails because a PortfolioCode is not specified.

Examples

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

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;