Type | Read/write | Author | Availability |
Write | FINBOURNE | Provided with LUSID |
Providing you have sufficient access control permissions, the Lusid.Fund.Writer
provider enables you to write a Luminesce SQL query that either creates or deletes funds in LUSID.
Note: By default,
Lusid.Fund.Writer
cannot add properties to funds. To do this, you must first configureLusid.Fund.Writer
to 'inline' properties. See how to do this.
You must construct a valid table of data to write, one fund per record. Lusid.Fund.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. Note a fund references a particular ABOR and no other fund can reference the same ABOR.
Your query can use the WriteAction
field to perform one of the following operations:
Upsert a fund; that is, create a fund if it does not exist, and update just its inlined properties if it does. Note you cannot currently update the core data fields of an existing fund. This is the default operation if you omit
WriteAction
.Insert a new fund.
Update just the inlined properties of an existing fund.
Delete a fund.
See also: Lusid.Fund
Basic usage
@table_of_data = <select-statement>;
select * from Lusid.Fund.Writer where toWrite = @table_of_data;
Query parameters
Lusid.Fund.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.Fund.Writer' and FieldType = 'Parameter';
Data fields
Lusid.Fund.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 |
|
| No other fund can reference the same You can only update inlined properties of an existing fund, not core data fields. |
Insert |
| No other fund can reference the same | |
Update |
| You can only update inlined properties of an existing fund, not core data fields. | |
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.Fund.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.Fund.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 fund
The referenced ABOR must already exist and be referenced by no other fund.
@data_to_write = select 'Funds' as FundScope, 'Growth' as FundCode, 'Abor' as AborScope, 'Standard' as AborCode,
#2024-01-01# as InceptionDate, 'Fund for growth' as DisplayName, 12 as YearEndMonth, 31 as YearEndDay;
select * from Lusid.Fund.Writer where ToWrite = @data_to_write;
Example 2: Create a fund with share class instruments
Share class instruments are optional but any referenced must already exist either in an explicit instrument scope or in the default
(system) scope.
@shareclasses = values
('LUID_00003DTJ', 'MyShareclassInstrScope'),
('LUID_00003DTI', 'default');
@data_to_write = select 'Funds' as FundScope, 'Growth' as FundCode, 'Abor' as AborScope, 'Standard' as AborCode,
#2024-01-01# as InceptionDate, 'Fund for growth' as DisplayName, 12 as YearEndMonth, 31 as YearEndDay,
column1 as ShareClassInstrumentLusidInstrumentId, column2 as ShareClassInstrumentScope from @shareclasses;
select * from Lusid.Fund.Writer where ToWrite = @data_to_write;
Example 3: Delete a fund
Specify 'Delete' as WriteAction
to delete a fund.
@data_to_write = select 'Funds' as FundScope, 'Growth' as FundCode, 'Delete' as WriteAction;
select * from Lusid.Fund.Writer where ToWrite = @data_to_write;