• maximo开发中可能用到的一些sql(各级菜单查询、完整删除应用)


    一级菜单查询:

    select t.position APP,
    'MODULE' appType,
    '' APPURL,
    mod.description,
    '' mainTbName,
    '5' maxAppsId,
    t.position ORDERID,
    NULL PARENT
    from maxmenu t, maxmodules mod
    where t.keyvalue = mod.module
    and t.menutype = 'MODULE'
    and t.elementtype = 'MODULE'
    and t.visible = 1

    二级菜单查询:

    select t.position app,
    'APP' appType,
    p.app APPURL,
    p.description,
    '' mainTbName,
    '5' maxAppsId,
    t.position ORDERID,
    m.position parent
    from maxmenu t,
    maxapps p,
    (select t.position, mod.module
    from maxmenu t, maxmodules mod
    where t.keyvalue = mod.module
    and t.menutype = 'MODULE'
    and t.elementtype = 'MODULE'
    and t.visible = 1
    and t.moduleapp in
    (select m.moduleapp
    from maxmenu m
    where m.menutype = 'MODULE'
    and m.elementtype = 'APP'
    and m.keyvalue in
    (select distinct a.app
    from applicationauth a
    where a.groupname in
    (select g.groupname
    from groupuser g)
    -- where g.userid = inuserid)
    and a.optionname = 'READ'
    ))) m
    where t.keyvalue = p.app
    and t.menutype = 'MODULE'
    and t.elementtype = 'APP'
    and t.moduleapp = m.module
    and t.subposition = 0
    and t.visible = 1

    比如:
    查询设备维修计划
    select t.position app,
    'APP' appType,
    p.app APPURL,
    p.description,
    '' mainTbName,
    '5' maxAppsId,
    t.position ORDERID,
    t.position parent,
    t.maxmenuid
    from maxmenu t,
    maxapps p
    where t.keyvalue = p.app
    and t.menutype = 'MODULE'
    and t.elementtype = 'APP'
    -- and t.moduleapp = m.module
    and t.subposition = 0
    and t.visible = 1
    and p.description like '设备维修计划'

    三级菜单查询:

    select t.subposition app,
    'APP' appType,
    p.app APPURL,
    p.description,
    '' mainTbName,
    '5' maxAppsId,
    t.subposition ORDERID,
    pa.position parent
    from maxmenu t,
    maxapps p,
    (select t.position, M.module
    from maxmenu t,
    (select t.position, mod.module
    from maxmenu t, maxmodules mod
    where t.keyvalue = mod.module
    and t.menutype = 'MODULE'
    and t.elementtype = 'MODULE'
    and t.visible = 1
    and t.moduleapp in
    (select m.moduleapp
    from maxmenu m
    where m.menutype = 'MODULE'
    and m.elementtype = 'APP'
    and m.keyvalue in
    (select distinct a.app
    from applicationauth a
    where a.groupname in
    (select g.groupname
    from groupuser g
    )
    and a.optionname = 'READ'))) m
    where t.menutype = 'MODULE'
    and t.elementtype = 'HEADER'
    and t.moduleapp = m.module
    and t.visible = 1
    and t.moduleapp in
    (select m.moduleapp
    from maxmenu m
    where m.menutype = 'MODULE'
    and m.keyvalue in
    (select distinct a.app
    from applicationauth a
    where a.groupname in
    (select g.groupname
    from groupuser g
    )
    and a.optionname = 'READ'))) PA
    where t.keyvalue = p.app
    and t.menutype = 'MODULE'
    and t.elementtype = 'APP'
    and t.moduleapp = PA.module
    AND T.position = PA.position
    and t.visible = 1

    如上,那么各级菜单的信息都查出来了,更改菜单等级应该就有理可询了

    下面是完整删除一个应用要包含的操作了:

    delete from maxapps where app='SBWXJH2';

    delete from maxpresentation where app='SBWXJH2';

    delete from sigoption where app='SBWXJH2';

    delete from applicationauth where app='SBWXJH2';

    delete from maxlabels where app='SBWXJH2';

    delete from maxmenu where moduleapp='SBWXJH2' and menutype !='MODULE';

    delete from maxmenu where elementtype='APP' and keyvalue='SBWXJH2';

    delete from appdoctype where app='SBWXJH2';

    delete from sigoptflag where app='SBWXJH2';

    上面这个是删除一个应用程序为SBWXJH2的应用

     下面是域查询的相关sql:

    select * from maxattribute where objectname='SBREWORKER' and attributename='REMARK';

    select * from maxdomain where domainid='REWORKERTITLE';

    select * from alndomain where domainid='REWORKERTITLE';

    查看sequence:

    SELECT * FROM SYSCAT.SEQUENCES where seqname like 'SB%';

    设置默认值:

    alter table sbrepairplan alter column hasld set with default 0

    UPDATE sbrepairplan SET hasld = DEFAULT WHERE hasld IS NULL;

    ALTER TABLE sbrepairplan ALTER COLUMN hasld DROP DEFAULT;

    这个设置默认值的sql是我网上查询的,虽然上次有使用,但是没有去验证结果,慎用

  • 相关阅读:
    荷兰国旗问题
    读取文件中数据到数组
    从五个球中选出3个枚举的简单运用
    搜索算法总结
    匿名对象
    欧几里得距离C++代码实现
    用递归法吧字符串S倒序
    利用系统来完成十进制,十六进制,八进制的转换
    DBHelper 使用的是存储过程
    DBHelper的一个小例子
  • 原文地址:https://www.cnblogs.com/binTke170120/p/6364941.html
Copyright © 2020-2023  润新知