Wednesday, December 12, 2012

Miscellaneous SQL Repository Research

I frequently use SQL to track down potential issues in the repository.  Here are a couple of statements that help solve common problems:

Fields Inactivated in the BC but Active in the Integration Object

select io.name int_obj, ic.name int_comp, icf.NAME int_field from siebel.S_INT_FIELD icf, siebel.S_INT_COMP ic, siebel.S_INT_OBJ io, siebel.s_repository r, siebel.s_buscomp bc, siebel.s_field f
where icf.INT_COMP_ID = ic.row_id and ic.INT_OBJ_ID = io.row_id and io.repository_id = r.row_id and r.name = 'Siebel Repository'
and ic.EXT_NAME = bc.name and icf.EXT_NAME = f.name and f.buscomp_id = bc.row_id and bc.repository_id = r.row_id and f.inactive_flg = 'Y'
and io.inactive_flg = 'N' and ic.inactive_flg = 'N' and icf.inactive_flg = 'N' and f.last_upd > to_date('11/01/2012', 'MM/DD/YYYY');

 Identify potential causes of the Truncation or Null Fetch error

This can sometimes be caused by not compiling the Table object too.  The first query finds business component joined fields where the BC field length or data type does not match the column length.  The second does the same but only analyzes base table columns and adds a last updated parameter which could be added or removed from either.  The last updated date is useful because vanilla actually has numerous instances of this potential problem.  I say potential because any records returned need to be checked against the data.  The error will only occur if the data in the column is longer than the BC length specified.  The Third query is an example of how to check assuming for instance S_ORDER_ITEM.ATTRIB_40 is mapped to a DTYPE_ID BC field..

select bc.name Bus_comp, f.name field, f.join_name Join, j.DEST_TBL_NAME Tbl_name, f.col_name Col_name, f.type Field_Type, f.textlen Fld_Lgth, c.DATA_TYPE Col_type, c.LENGTH col_lgth
from siebel.s_field f, siebel.s_repository r, siebel.s_join j, siebel.s_buscomp bc, siebel.s_column c, siebel.s_table t
where bc.REPOSITORY_ID = r.row_id and r.name = 'Siebel Repository'
and bc.row_id = f.buscomp_id and j.name = f.join_name and j.buscomp_id = bc.row_id
and c.TBL_ID = t.row_id and t.NAME = j.DEST_TBL_NAME and c.name = f.col_name
and r.row_id = t.REPOSITORY_ID and r.row_id = f.REPOSITORY_ID and r.row_id = c.REPOSITORY_ID
and t.INACTIVE_FLG = 'N' and c.INACTIVE_FLG = 'N' and bc.INACTIVE_FLG = 'N' and f.INACTIVE_FLG = 'N'
and ((f.type = 'DTYPE_ID' and c.length > 15)
or (f.type = 'DTYPE_PHONE' and c.length > 40)
or (f.type = 'DTYPE_BOOL' and c.length > 1)
or (f.type = 'DTYPE_TEXT' and c.DATA_TYPE like 'Date%'))
order by j.DEST_TBL_NAME, f.col_name;

select bc.name Bus_comp, f.name field, t.NAME tbl_name, f.col_name Col_name, f.type Field_Type, f.textlen Fld_Lgth, c.DATA_TYPE Col_type, c.LENGTH col_lgth
from siebel.s_field f, siebel.s_repository r, siebel.s_buscomp bc, siebel.s_column c, siebel.s_table t
where bc.REPOSITORY_ID = r.row_id and r.name = 'Siebel Repository'
and bc.row_id = f.buscomp_id
and c.TBL_ID = t.row_id and t.NAME = bc.TABLE_NAME and c.name = f.col_name
and r.row_id = t.REPOSITORY_ID and r.row_id = f.REPOSITORY_ID and r.row_id = c.REPOSITORY_ID
and t.INACTIVE_FLG = 'N' and c.INACTIVE_FLG = 'N' and bc.INACTIVE_FLG = 'N' and f.INACTIVE_FLG = 'N'
and ((f.type = 'DTYPE_ID' and c.length > 15)
or (f.type = 'DTYPE_PHONE' and c.length > 40)
or (f.type = 'DTYPE_BOOL' and c.length > 1)
or (f.type = 'DTYPE_TEXT' and c.DATA_TYPE like 'Date%'))
and f.last_upd > to_date('06/01/2010', 'MM/DD/YYYY')
order by t.NAME, f.col_name;

select ATTRIB_40 from siebel.S_ORDER_ITEM_XM where length(ATTRIB_40) > 15;

WF Deployed but not activated:

select wpr.proc_name, wpr.version from siebel.S_WFR_PROC wpr, siebel.s_repository r
where r.row_id = wpr.REPOSITORY_ID and r.name = 'Siebel Repository' and wpr.STATUS_CD = 'COMPLETED'
and wpr.name like 'PPT%'
and exists (select 'x' from siebel.S_WFA_DPLOY_DEF wpd where wpd.NAME = wpr.proc_name and wpd.TYPE_CD = 'PROCESS' and wpd.DEPLOY_STATUS_CD = 'ACTIVE'
            and wpd.REPOSITORY_VERSION <> wpr.VERSION)
and wpr.version = (select max(wpr1.version) from siebel.S_WFR_PROC wpr1
                  where r.row_id = wpr1.REPOSITORY_ID and wpr1.STATUS_CD = 'COMPLETED' and wpr1.proc_name = wpr.proc_name)
order by wpr.proc_name;

BC Fields not configured as boolean that should be

select bc.name, f.name, f.type, f.CALCVAL from siebel.s_field f, siebel.s_buscomp bc, siebel.s_repository r
where f.BUSCOMP_ID = bc.row_id and bc.repository_id = r.row_id and r.name = 'Siebel Repository'
and (f.CALCVAL like '%,%Y%,%N%)' OR f.CALCVAL like '%,%N%,%Y%)')
and f.TYPE <> 'DTYPE_BOOL'
and f.inactive_flg = 'N' and bc.name like 'PPT%' and bc.inactive_flg = 'N'
order by bc.name, f.name;

select bc.name, f.name, f.type, f.CALCVAL from siebel.s_field f, siebel.s_buscomp bc, siebel.s_repository r
where f.BUSCOMP_ID = bc.row_id and bc.repository_id = r.row_id and r.name = 'Siebel Repository'
and f.TEXTLEN = 1
and f.TYPE <> 'DTYPE_BOOL'
and f.inactive_flg = 'N' and bc.name like 'PPT%' and bc.inactive_flg = 'N'
order by bc.name, f.name;

Applet controls where checkbox not configured correctly

select a.name, lc.name, lc.field_name, lc.HTML_TYPE, lc.HTML_ICON_MAP, f.type from siebel.s_list_column lc, siebel.s_list l, siebel.s_applet a, siebel.s_repository r, siebel.s_field f, siebel.s_buscomp bc
where lc.list_id = l.row_id and l.applet_id = a.row_id and a.repository_id = r.row_id and r.name = 'Siebel Repository' and lc.inactive_flg = 'N' and a.inactive_flg = 'N'
and (lc.HTML_ICON_MAP is null or lc.HTML_TYPE <> 'CheckBox')
and f.name = lc.FIELD_NAME and f.BUSCOMP_ID = bc.row_id and bc.name = a.BUSCOMP_NAME and f.TYPE = 'DTYPE_BOOL' and a.name like 'PPT%';

Integration Object Maps that have changed since a prior release:

select release, Map_Name, change_level, Field_Upd, Field_User, Comp_Upd, Comp_User, Obj_Upd, Obj_user, Comp_Name, src_expr, dst_int_fld_name, Obj_Comments
from ( -- Object level
select o.x_release release, o.name Map_Name, '1-Object' change_level, null Field_Upd, null Field_User, null Comp_Upd, null Comp_User, o.last_upd Obj_Upd, ou.login Obj_user, null Comp_Name, null src_expr, null dst_int_fld_name, o.comments Obj_Comments
from siebel.S_INT_OBJMAP o, siebel.s_user ou
where o.last_upd_by = ou.row_id and o.last_upd >= to_date('04/23/2019', 'MM/DD/YYYY')
UNION ALL -- Component level
select o.x_release release, o.name Map_Name, '2-Component' change_level, null Field_Upd, null Field_User, c.last_upd Comp_Upd, cu.login Comp_User, null Obj_Upd, null Obj_user, c.name Comp_Name, c.SRC_SRCHSPEC src_expr, null dst_int_fld_name, o.comments Obj_Comments
from siebel.S_INT_OBJMAP o, siebel.S_INT_COMPMAP c, siebel.s_user cu, siebel.s_user ou
where c.int_obj_map_id = o.row_id and c.last_upd_by = cu.row_id and o.last_upd_by = ou.row_id --and o.x_release = '1.27.12'
and c.last_upd >= to_date('4/23/2019', 'MM/DD/YYYY')
UNION ALL -- Field level
select o.x_release release, o.name Map_Name, '3-Field' change_level, f.last_upd Field_Upd, fu.login Field_User, null Comp_Upd, null Comp_User, null Obj_Upd, null Obj_user, c.name Comp_Name, f.src_expr, f.dst_int_fld_name, o.comments Obj_Comments
from siebel.S_INT_OBJMAP o, siebel.S_INT_COMPMAP c, siebel.S_INT_FLDMAP f, siebel.s_user fu, siebel.s_user cu, siebel.s_user ou
where f.int_comp_map_id = c.row_id and c.int_obj_map_id = o.row_id and f.last_upd_by = fu.row_id and c.last_upd_by = cu.row_id and o.last_upd_by = ou.row_id --and o.x_release = '1.27.12'
and (f.last_upd >= to_date('4/23/2019', 'MM/DD/YYYY'))
) where release <> '1.27.13'
order by Map_Name, change_level;

No comments:

Post a Comment