added deployment folder with latest code

This commit is contained in:
Deepthi
2021-04-27 16:13:33 +05:30
parent 37f73d5dfd
commit c8985b2d62
112 changed files with 42492 additions and 0 deletions

View File

@@ -0,0 +1,88 @@
CREATE TABLE mmt_staging2.mmt_DB_Run_Status
( syspk bigserial NOT NULL,
client_id int,
function_id int,
user_id int,
user_name text,
file_syspk int,
file_format text,
sheet_mnemonic text,
block_name text,
staging_type text,
error_function text,
error_state text,
error_message text,
error_detail text,
error_hint text,
error_context text,
status text,
error_timestamp timestamp default now(),
CONSTRAINT mmt_DB_error_pkey PRIMARY KEY (syspk)
);
drop table mmt_staging2.mmt_DB_Errors;
ALTER TABLE mmt_staging2.mmt_DB_Errors
ADD status text;
DROP FUNCTION IF EXISTS mmt_staging2.mmt_insert_DB_error;
CREATE OR REPLACE FUNCTION mmt_staging2.mmt_insert_db_error( clientId int, functionId int, userId int, userName varchar, fileSyspk int,
fileFormat varchar,sheetMnemonic varchar,blockName varchar,stagType varchar, eFunction varchar, eState varchar, eMessage varchar, eDetail varchar, eHint varchar,eContext varchar, sta varchar)
RETURNS text AS $$
DECLARE
_message_text text;
_returned_sqlstate text;
BEGIN
BEGIN
INSERT INTO mmt_staging2.mmt_DB_Run_Status ( client_Id, function_id, user_id, user_name, file_syspk, file_format, sheet_mnemonic, block_name, staging_type, error_function, error_state, error_message, error_detail, error_hint, error_context,status)
values ( clientId, functionId, userID, userName, fileSyspk, fileFormat, sheetMnemonic, blockName, stagType, eFunction, eState, eMessage, eDetail, eHInt, eContext, sta );
EXCEPTION when OTHERS THEN
_message_text := '';
_returned_sqlstate := '';
GET STACKED DIAGNOSTICS
_message_text = MESSAGE_TEXT,
_returned_sqlstate = RETURNED_SQLSTATE;
RETURN 'Failed: DB Error Creation : ' || _returned_sqlstate || ' : ' || _message_text;
END;
RETURN 'Success: DB Error Creation ';
END
$$ LANGUAGE plpgsql;
DROP FUNCTION IF EXISTS mmt_staging2.test_mmt_db_error;
CREATE OR REPLACE FUNCTION mmt_staging2.test_mmt_db_error ()
RETURNS text AS $$
DECLARE
v_state text;
v_msg text;
v_detail text;
v_hint text;
v_context text;
v_block text;
begin
v_block := 'nothing';
CREATE TABLE t_test( test_id int);
v_block := 'nothing';
CREATE TABLE t_test(test_id int); -- this will cause an error
EXCEPTION when OTHERS then
GET STACKED DIAGNOSTICS
v_state = returned_sqlstate,
v_msg = message_text,
v_detail = pg_exception_detail,
v_hint = pg_exception_hint,
v_context = pg_exception_context;
perform mmt_staging2.mmt_insert_db_error ( 10, 1, 1001, 'Compegence',1,'ftdry','ftdry_trs',v_block,'stg2', 'test_db_error', v_state, v_msg, v_detail, v_hint, v_context,'error');
return v_block;
END;
$$ LANGUAGE plpgsql;
select mmt_staging2.test_mmt_db_error ()
select * from mmt_staging2.mmt_DB_Errors
delete from mmt_staging2.mmt_DB_Errors;

View File

@@ -0,0 +1,79 @@
drop function if exists mmt_ods.fn_update_NA();
create or replace function mmt_ods.fn_update_NA()
returns void AS $$
/***********
select mmt_ods.fn_update_NA()
********/
declare
__n integer:=0;
__na_sql text;
__space_sql text;
__div_sql text;
__ref_sql text;
__hyphen_sql text;
__not_applicable text;
__NR text;
begin
loop
exit when __n=53;
__n := __n+1;
__na_sql := 'update mmt_staging1.mmt_staging_generic_table set '|| concat('column',__n)||' =null
where '||concat('column',__n)||'=''NA''';
__space_sql := 'update mmt_staging1.mmt_staging_generic_table set '|| concat('column',__n)||' =null
where '||concat('column',__n)||'=''''';
__div_sql := 'update mmt_staging1.mmt_staging_generic_table set '|| concat('column',__n)||' =null
where '||concat('column',__n)||'=''#REF!''';
__ref_sql := 'update mmt_staging1.mmt_staging_generic_table set '|| concat('column',__n)||' =null
where '||concat('column',__n)||'=''#DIV/0!''';
__hyphen_sql := 'update mmt_staging1.mmt_staging_generic_table set '|| concat('column',__n)||' =null
where '||concat('column',__n)||'=''-''';
__not_applicable := 'update mmt_staging1.mmt_staging_generic_table set '|| concat('column',__n)||' =null
where '||concat('column',__n)||'=''Not Applicable ''';
__NR := 'update mmt_staging1.mmt_staging_generic_table set '|| concat('column',__n)||' =null
where '||concat('column',__n)||'=''NR''';
execute __na_sql;
execute __space_sql;
execute __div_sql;
execute __ref_sql;
execute __hyphen_sql;
execute __not_applicable;
execute __NR;
end loop;
end;
$$ LANGUAGE plpgsql;
drop function if exists mmt_staging2.fn_jobctrl_block_begin;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_jobctrl_block_begin(p_client_id int,p_function_id int,p_file_syspk int,p_block_table_name text,p_file_format text,p_sheet_mnemonic text,p_block_seq int)
RETURNS void AS $$
begin
/*************************
select mmt_staging2.fn_jobctrl_block_begin(1,2,255,'block1','file','sheet',1)
***********************/
execute 'insert into mmt_ods.fw_jobctrl_file_sheet_block_run_schedule
(client_id,function_id,file_syspk,block_table_name,file_format,sheet_mnemonic,begin_status,block_table_load_seq,start_time)
select '||p_client_id||', '||p_function_id||', '''||p_file_syspk||''','''||p_block_table_name||''','''||p_file_format||''','''||p_sheet_mnemonic||''',1,'||p_block_seq||',current_timestamp';
end
$$ LANGUAGE plpgsql;
drop function if exists mmt_staging2.fn_jobctrl_block_end;
CREATE OR REPLACE FUNCTION mmt_staging2.fn_jobctrl_block_end(p_file_syspk int,p_block_table_name text)
RETURNS void AS $$
begin
/*********************************
select mmt_staging2.fn_jobctrl_block_end(255,'block1')
*********************************/
execute 'update mmt_ods.fw_jobctrl_file_sheet_block_run_schedule set end_status=1 , end_time=current_timestamp
where file_syspk='''||p_file_syspk||'''and block_table_name='''||p_block_table_name||'''';
end
$$ LANGUAGE plpgsql;