Type | Read/write | Author | Availability |
|---|---|---|---|
Write | FINBOURNE | Provided with LUSID |
The Lusid.Portfolio.CustodianAccount.Writer provider enables you to write a Luminesce SQL query that either adds, modifies or removes custodian accounts from transaction portfolios.
Note: By default,
Lusid.Portfolio.CustodianAccount.Writercannot add properties to custodian accounts. To do this, you must first configureLusid.Portfolio.CustodianAccount.Writerto 'inline' properties. See how to do this.
Your query should use the WriteAction field to perform one of the following operations:
Upsert a custodian account; that is, create a new one if it does not already exist in the portfolio, and update certain fields and/or inlined properties if it does. This is the default operation if you omit
WriteAction.Hard or soft delete a custodian account. Soft delete retains the account in the portfolio with a
StatusofInactive. Hard delete removes the account from the portfolio.
See also: Lusid.Portfolio.CustodianAccount
Basic usage
@table_of_data = <select-statement>;
select * from Lusid.Portfolio.CustodianAccount.Writer
where ToWrite = @table_of_data;Query parameters
Lusid.Portfolio.CustodianAccount.Writer has parameters that help you construct a valid table of data to write.
Note: The
ToWriteparameter 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 a query like this one using a suitable tool:
select FieldName, DataType, ParamDefaultValue, Description from Sys.Field
where TableName = 'Lusid.Portfolio.CustodianAccount.Writer' and FieldType = 'Parameter';Data fields
Lusid.Portfolio.CustodianAccount.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 |
|
| For a list of valid To see how to reference a legal entity using |
Soft delete |
|
| |
Hard delete |
|
To list all available fields, their data types, whether fields are considered 'main', and an explanation for each, run a query like this using a suitable tool:
select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field
where TableName = 'Lusid.Portfolio.CustodianAccount.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, an error code is returned. 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: Add a custodian account to a portfolio
@data_to_write = select
'Equities' as PortfolioScope,
'UK' as PortfolioCode,
'CustodianAccounts' as CustodianAccountScope,
'JPMorgan-FIFO' as CustodianAccountCode,
'12345678' as AccountNumber,
'JPMorgan-FIFO' as AccountName,
'FirstInFirstOut' as AccountingMethod,
'GBP' as Currency,
'InvestmentFirms' as CustodianIdentifierTypeScope,
'InvestId' as CustodianIdentifierTypeCode,
'Invest5' as CustodianIdentifierCode
;
select * from Lusid.Portfolio.CustodianAccount.Writer where ToWrite = @data_to_write;Example 2: Permanently remove a custodian account from a portfolio
You must specify 'HardDelete' as WriteAction.
@data_to_write = select
'HardDelete' as WriteAction,
'Equities' as PortfolioScope,
'UK' as PortfolioCode,
'CustodianAccounts' as CustodianAccountScope,
'JPMorgan-FIFO' as CustodianAccountCode
;
select * from Lusid.RelationalDataset.MyRDDs.Addresses.Writer where ToWrite = @data_to_write;