How to find Teradata MLoad session against a particular table

select U.SUBJ_NAME, F.TASK_NAME WORKFLOW_NAME, T.Instance_name session_name,
S.INSTANCE_NAME target_name,
F.subject_id, F.TASK_ID WORKFLOW_ID, s.session_id, s.MAPPING_ID
from OPB_TASK_INST T, OPB_TASK F, OPB_SUBJECT U,
(
select session_id, sess_widg_inst_id, version_number,
instance_name, mapping_id,
rank() over (partition by session_id, sess_widg_inst_id order by
version_number desc) sort_id
from OPB_SWIDGET_INST
where widget_type = 2
and UPPER(INSTANCE_NAME) LIKE '%MY_TABLE_NAME%'
) S
where (s.session_id, s.sess_widg_inst_id, s.version_number) in
(
select session_id, sess_widg_inst_id, max(VERSION_NUMBER) version_number
from OPB_EXTN_ATTR e
where object_type = 79 and object_subtype = 315000 -- MLoad Extension
group by SESSION_ID, sess_widg_inst_id
)
and s.SORT_ID = 1 -- only the current version
and s.SESSION_ID = T.task_id
and s.VERSION_NUMBER = T.VERSION_NUMBER
and T.WORKFLOW_ID = F.TASK_ID
and T.VERSION_NUMBER = F.VERSION_NUMBER
and F.subject_id = U.SUBJ_ID
order by 1,2,3;

-- It will be nice to see workflow name in View Point
update OPB_EXTN_ATTR
set ATTR_VALUE = 'SubjectArea=$PMFolderName; Workflow=$PMWorkflowName;
Session=$PMSessionName; WorkflowRunId=$PMWorkflowRunId;'
where attr_id = 26 -- Query Band Expression
and object_type = 79 -- Target
and OBJECT_SUBTYPE = 315000 -- Teradata Plug-in
and (SESSION_ID, SESS_WIDG_INST_ID, VERSION_NUMBER) in
(
select session_id, sess_widg_inst_id, max(VERSION_NUMBER) version_number
from OPB_EXTN_ATTR e
where object_type = 79 and object_subtype = 315000
group by SESSION_ID, sess_widg_inst_id
);

update OPB_EXTN_ATTR
set ATTR_VALUE = '1'
where attr_id = 10 -- Check "Drop Log/Error Tables" option
and object_type = 79 -- Target
and OBJECT_SUBTYPE = 315000 -- Teradata Plug-in
and ATTR_VALUE = '0'; -- Option is not set yet


Sign up to vote on this title
UsefulNot useful