Skip to content

Commit

Permalink
Fenster für externe System-Meldungen (#10706)
Browse files Browse the repository at this point in the history
* Fenster für externe System-Meldungen

#10691

- create index ad_pinstance_log_ad_pinstance_id_created
- create index ad_pinstance_para_perf
- create db function cast_to_numeric_or_null
- create view ExternalSystem_Config_PInstance_Log_v
- create Window External System Log

* Fenster für externe System-Meldungen
#10691

* Fenster für externe System-Meldungen
#10691
fix index creation

* move external system migration scripts to dedicated module + change ET

ET = AD_Entity_Type
#10691

Co-authored-by: Tobias Schöneberg <tobias.schoeneberg@metasfresh.com>
  • Loading branch information
BodorAnnamaria and metas-ts committed Feb 25, 2021
1 parent ab6dac3 commit a652590
Show file tree
Hide file tree
Showing 7 changed files with 3,621 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE OR REPLACE FUNCTION cast_to_numeric_or_null(p_string text) RETURNS NUMERIC AS
$$
BEGIN
RETURN p_string::NUMERIC;
EXCEPTION WHEN others THEN
RETURN NULL;
END;
$$
STRICT
LANGUAGE plpgsql IMMUTABLE;
COMMENT ON FUNCTION cast_to_numeric_or_null(text) is 'Attempts to cast the given p_string to numeric. Returns null if that fails. Thx to https://stackoverflow.com/a/16206123/1012103';
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CREATE OR REPLACE FUNCTION cast_to_numeric_or_null(p_string text) RETURNS NUMERIC AS
$$
BEGIN
RETURN p_string::NUMERIC;
EXCEPTION WHEN others THEN
RETURN NULL;
END;
$$
STRICT
LANGUAGE plpgsql IMMUTABLE;
COMMENT ON FUNCTION cast_to_numeric_or_null(text) is 'Attempts to cast the given p_string to numeric. Returns null if that fails. Thx to https://stackoverflow.com/a/16206123/1012103';
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
DROP VIEW IF EXISTS ExternalSystem_Config_PInstance_Log_v;

CREATE OR REPLACE VIEW ExternalSystem_Config_PInstance_Log_v AS
SELECT pi.ad_process_id,
pil.ad_pinstance_id AS ExternalSystem_Config_PInstance_Log_v_ID,
pip_request.info AS External_Request,
pil.p_msg,
pil.p_date,
pi.ad_client_id,
COALESCE(
NULLIF(pi.record_id, '0'), /*Record_ID is not set then the process was called from AD_Scheduler */
cast_to_numeric_or_null(pip_config.p_string)) AS ExternalSystem_Config_ID,
pi.ad_org_id,
pi.ad_pinstance_id,
pi.isprocessing,
pi.errormsg,
now() as created,
100 as createdby,
now() as updated,
100 as updatedby,
'Y' as isactive
FROM ad_pinstance pi
JOIN ad_pinstance_para pip_request ON pi.ad_pinstance_id = pip_request.ad_pinstance_id AND pip_request.parametername = 'External_Request'
LEFT JOIN ad_pinstance_para pip_config ON pi.ad_pinstance_id = pip_config.ad_pinstance_id AND pip_config.parametername = 'ChildConfigId'
JOIN ad_pinstance_log pil ON pil.ad_pinstance_id = pi.ad_pinstance_id
WHERE pi.AD_Table_ID = get_table_id('ExternalSystem_Config') /*AD_Table_ID is not set then the process was called from AD_Scheduler */
OR pip_config.parametername = 'ChildConfigId'
;
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

DROP VIEW IF EXISTS ExternalSystem_Config_PInstance_Log_v;

CREATE OR REPLACE VIEW ExternalSystem_Config_PInstance_Log_v AS
SELECT pi.ad_process_id,
pil.ad_pinstance_id AS ExternalSystem_Config_PInstance_Log_v_ID,
pip_request.info AS External_Request,
pil.p_msg,
pil.p_date,
pi.ad_client_id,
COALESCE(
NULLIF(pi.record_id, '0'), /*Record_ID is not set then the process was called from AD_Scheduler */
cast_to_numeric_or_null(pip_config.p_string)) AS ExternalSystem_Config_ID,
pi.ad_org_id,
pi.ad_pinstance_id,
pi.isprocessing,
pi.errormsg,
now() as created,
100 as createdby,
now() as updated,
100 as updatedby,
'Y' as isactive
FROM ad_pinstance pi
JOIN ad_pinstance_para pip_request ON pi.ad_pinstance_id = pip_request.ad_pinstance_id AND pip_request.parametername = 'External_Request'
LEFT JOIN ad_pinstance_para pip_config ON pi.ad_pinstance_id = pip_config.ad_pinstance_id AND pip_config.parametername = 'ChildConfigId'
JOIN ad_pinstance_log pil ON pil.ad_pinstance_id = pi.ad_pinstance_id
WHERE pi.AD_Table_ID = get_table_id('ExternalSystem_Config') /*AD_Table_ID is not set then the process was called from AD_Scheduler */
OR pip_config.parametername = 'ChildConfigId'
;

0 comments on commit a652590

Please sign in to comment.