Skip to content

Commit

Permalink
Update CustomerMgmtView.sql
Browse files Browse the repository at this point in the history
  • Loading branch information
techvaquero authored Aug 2, 2023
1 parent 8b62519 commit 608c3dd
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions models/snowflake/base/CustomerMgmtView.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,22 @@
get(xmlget($1, 'Customer'), '@C_ID')::BIGINT as customerid,
get(xmlget(xmlget($1, 'Customer'), 'Account'), '@CA_ID')::BIGINT as accountid,
get(xmlget(xmlget(xmlget($1, 'Customer'), 'Account'), 'CA_B_ID'), '$')::BIGINT as brokerid,
nullif(get(xmlget($1, 'Customer'), '@C_TAX_ID'), '') as taxid,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Account'), 'CA_NAME'), '$'), '') as accountdesc,
nullif(get(xmlget($1, 'Customer'), '@C_TAX_ID'), '')::STRING as taxid,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Account'), 'CA_NAME'), '$'), '')::STRING as accountdesc,
get(xmlget(xmlget($1, 'Customer'), 'Account'), '@CA_TAX_ST')::TINYINT as taxstatus,
decode(get($1, '@ActionType'), 'NEW','Active', 'ADDACCT','Active', 'UPDACCT','Active', 'UPDCUST','Active', 'CLOSEACCT','Inactive', 'INACT','Inactive') as status,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Name'), 'C_L_NAME'), '$'), '') as lastname,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Name'), 'C_F_NAME'), '$'), '') as firstname,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Name'), 'C_M_NAME'), '$'), '') as middleinitial,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Name'), 'C_L_NAME'), '$'), '')::STRING as lastname,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Name'), 'C_F_NAME'), '$'), '')::STRING as firstname,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Name'), 'C_M_NAME'), '$'), '')::STRING as middleinitial,
nullif(upper(get(xmlget($1, 'Customer'), '@C_GNDR')), '') as gender,
nullif(get(xmlget($1, 'Customer'), '@C_TIER'), '') as tier,
nullif(get(xmlget($1, 'Customer'), '@C_TIER'), '')::STRING as tier,
get(xmlget($1, 'Customer'), '@C_DOB')::DATE as dob,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_ADLINE1'), '$'), '') as addressline1,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_ADLINE2'), '$'), '') as addressline2,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_ZIPCODE'), '$'), '') as postalcode,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_CITY'), '$'), '') as city,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_STATE_PROV'), '$'), '') as stateprov,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_CTRY'), '$'), '') as country,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_ADLINE1'), '$'), '')::STRING as addressline1,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_ADLINE2'), '$'), '')::STRING as addressline2,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_ZIPCODE'), '$'), '')::STRING as postalcode,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_CITY'), '$'), '')::STRING as city,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_STATE_PROV'), '$'), '')::STRING as stateprov,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'Address'), 'C_CTRY'), '$'), '')::STRING as country,
nvl2(
nullif(get(xmlget(xmlget(xmlget(xmlget($1, 'Customer'), 'ContactInfo'), 'C_PHONE_1'), 'C_LOCAL'), '$'), ''),
concat(
Expand All @@ -48,11 +48,11 @@
get(xmlget(xmlget(xmlget(xmlget($1, 'Customer'), 'ContactInfo'), 'C_PHONE_3'), 'C_LOCAL'), '$'),
nvl(get(xmlget(xmlget(xmlget(xmlget($1, 'Customer'), 'ContactInfo'), 'C_PHONE_3'), 'C_EXT'), '$'), '')),
cast(null as string)) phone3,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'ContactInfo'), 'C_PRIM_EMAIL'), '$'), '') as email1,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'ContactInfo'), 'C_ALT_EMAIL'), '$'), '') as email2,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'TaxInfo'), 'C_LCL_TX_ID'), '$'), '') as lcl_tx_id,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'TaxInfo'), 'C_NAT_TX_ID'), '$'), '') as nat_tx_id,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'ContactInfo'), 'C_PRIM_EMAIL'), '$'), '')::STRING as email1,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'ContactInfo'), 'C_ALT_EMAIL'), '$'), '')::STRING as email2,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'TaxInfo'), 'C_LCL_TX_ID'), '$'), '')::STRING as lcl_tx_id,
nullif(get(xmlget(xmlget(xmlget($1, 'Customer'), 'TaxInfo'), 'C_NAT_TX_ID'), '$'), '')::STRING as nat_tx_id,
to_timestamp(get($1, '@ActionTS')) as update_ts,
get($1, '@ActionType') as ActionType
get($1, '@ActionType')::STRING as ActionType
FROM @{{var('stage')}}/Batch1 (FILE_FORMAT => 'XML', PATTERN => '.*CustomerMgmt[.]xml.*')

0 comments on commit 608c3dd

Please sign in to comment.