-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathupload-transactions-from-xml.sql
49 lines (45 loc) · 1.38 KB
/
upload-transactions-from-xml.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
-- ============================================================
-- Description:
-- 1. In this query, we run an ETL process on some transactions.
-- 2. First, we load a XML file of transactions from Drive.
-- 3. Next, we transform the shape of the transaction data.
-- 4. Finally we upload the transaction data into LUSID.
-- ============================================================
-- Extract transaction data from LUSID Drive
@txn_data =
use Drive.Xml
--file=/luminesce-examples/transactions.xml
--nodePath=transactions/transaction
--columns
TransactionID=transactionId
Type=type
TransactionDate=transactionDate
SettlementDate=settlementDate
Units=units
Price=price
TotalConsideration=totalConsideration
Currency=price/@currency
ClientInternal=clientInternal
enduse;
-- Set variables for the portfolio's scope and code
@@portfolio_scope = select 'IBOR';
@@portfolio_code = select 'uk-equity';
--Transform data using SQL
@transactions =
select
@@portfolio_scope as PortfolioScope,
@@portfolio_code as PortfolioCode,
TransactionID as TxnId,
Type as Type,
TransactionDate as TransactionDate,
SettlementDate as SettlementDate,
Units as Units,
Price as TradePrice,
TotalConsideration as TotalConsideration,
Currency as SettlementCurrency,
ClientInternal as ClientInternal
from @txn_data;
-- Upload the transformed data into LUSID
select *
from Lusid.Portfolio.Txn.Writer
where ToWrite = @transactions;