-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrm_4_lux_minus_table.sql
More file actions
58 lines (46 loc) · 1.29 KB
/
rm_4_lux_minus_table.sql
File metadata and controls
58 lines (46 loc) · 1.29 KB
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
50
51
52
53
54
55
56
57
58
-- PROCEDURE: datamart.rm_4_lux_minus_table()
-- DROP PROCEDURE datamart.rm_4_lux_minus_table();
CREATE OR REPLACE PROCEDURE datamart.rm_4_lux_minus_table(
)
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE environnement VARCHAR;
DECLARE tstart TIMESTAMP;
DECLARE tend TIMESTAMP;
DECLARE duration INTERVAL;
BEGIN
CALL public.log_message('Create Luxembourg one');
drop table if exists datamart.opportunity_li_fact_lux;
create table
datamart.opportunity_li_fact_lux as
select
*
FROM
datamart.opportunity_li_fact as oplif
where
country = 'Luxembourg';
drop table if exists datamart.opportunity_lux;
create table
datamart.opportunity_lux as
SELECT
"Id" as id,
"Amount" as amout,
"CloseDate" as close_date,
"IsWon" as is_won,
"CampaignId" as campaign_id,
"s360a__Contact__c" as contact_id,
"s360a__RegularGivingScheduleDate__c" as rg_date,
"s360a__RegularGiving__c" as rg_id,
"gpi__GiftCountryOfOwnership__c" as country,
"RecordTypeId" as id_record_type
FROM
salesforce."Opportunity" as opp
WHERE
"Id" in (select opportunity_id from datamart.opportunity_li_fact_lux);
CALL public.log_message('first');
tend := clock_timestamp();
duration := tend - tstart;
CALL public.log_message('first step COMPLETE. Execution time: '||duration);
CALL public.log_message('CORRECTLY FINISH.');
END
$BODY$;