From 8ec04081b97f2a2cb3609ca4a2f01161d55f8148 Mon Sep 17 00:00:00 2001 From: Paul Trowbridge Date: Thu, 24 May 2018 16:54:00 -0400 Subject: [PATCH] setup files for import --- .../import/test}/data.json | 0 interface/map_def/srce_map_def_set.sql | 51 +++++++++++++++++++ .../source_maint/test}/srce.json | 0 .../source_maint/test}/srce_set_test.sql | 0 4 files changed, 51 insertions(+) rename {sample_discovercard => interface/import/test}/data.json (100%) create mode 100644 interface/map_def/srce_map_def_set.sql rename {sample_discovercard => interface/source_maint/test}/srce.json (100%) rename {sample_discovercard => interface/source_maint/test}/srce_set_test.sql (100%) diff --git a/sample_discovercard/data.json b/interface/import/test/data.json similarity index 100% rename from sample_discovercard/data.json rename to interface/import/test/data.json diff --git a/interface/map_def/srce_map_def_set.sql b/interface/map_def/srce_map_def_set.sql new file mode 100644 index 0000000..6ef417c --- /dev/null +++ b/interface/map_def/srce_map_def_set.sql @@ -0,0 +1,51 @@ +CREATE OR REPLACE FUNCTION tps.srce_map_def_set(_srce text, _map text, _defn jsonb, _seq int) RETURNS jsonb +AS +$f$ + +DECLARE + _message jsonb; + _MESSAGE_TEXT text; + _PG_EXCEPTION_DETAIL text; + _PG_EXCEPTION_HINT text; + +BEGIN + + BEGIN + + INSERT INTO + tps.map_rm + SELECT + _srce + ,_map + ,_defn + ,_seq + ON CONFLICT ON CONSTRAINT map_rm_pk DO UPDATE SET + srce = _srce + ,target = _map + ,regex = _defn + ,seq = _seq; + + EXCEPTION WHEN OTHERS THEN + + GET STACKED DIAGNOSTICS + _MESSAGE_TEXT = MESSAGE_TEXT, + _PG_EXCEPTION_DETAIL = PG_EXCEPTION_DETAIL, + _PG_EXCEPTION_HINT = PG_EXCEPTION_HINT; + _message:= + ($$ + { + "status":"fail", + "message":"error setting definition" + } + $$::jsonb) + ||jsonb_build_object('message_text',_MESSAGE_TEXT) + ||jsonb_build_object('pg_exception_detail',_PG_EXCEPTION_DETAIL); + return _message; + END; + + _message:= jsonb_build_object('status','complete','message','definition has been set'); + return _message; + +END; +$f$ +language plpgsql \ No newline at end of file diff --git a/sample_discovercard/srce.json b/interface/source_maint/test/srce.json similarity index 100% rename from sample_discovercard/srce.json rename to interface/source_maint/test/srce.json diff --git a/sample_discovercard/srce_set_test.sql b/interface/source_maint/test/srce_set_test.sql similarity index 100% rename from sample_discovercard/srce_set_test.sql rename to interface/source_maint/test/srce_set_test.sql