DROP FUNCTION IF EXISTS fw_core.fn_insert_DB_error;
	CREATE OR REPLACE FUNCTION fw_core.fn_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 fw_core.DB_Run_Status ( client_Id, function_id, user_id, user_name, file_syspk, file_mnemonic, file_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;
