当前位置:七道奇文章资讯数据防范MSSQL防范
日期:2012-03-30 10:22:00  来源:本站整理

sql删除表中的反复记录[MSSQL防范]

赞助商链接



  本文“sql删除表中的反复记录[MSSQL防范]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:

  sql删除表中的反复记录

  CREATE OR REPLACE PROCEDURE getUserMenuResource(roid IN Varchar2)

  AS

  BEGIN

  DELETE FROM BOCO_TEMP_MENURESOURCE;

  COMMIT;

  --读出全部角色表所对应的菜单ID

  DECLARE CURSOR records IS SELECT a.funcid FROM boco_rolemenurelation a WHERE a.roleid=roid ORDER BY a.funcid;

  BEGIN

  FOR cur IN records LOOP

  --SELECT a.displayname,a.url,a.pid,a.icon,a.disorder,a.code,a.isshow INTO BOCO_TEMP_MENURESOURCE(displayname,url,pid,icon,disorder,code,isshow) FROM boco_menuresource a START WITH a.CODE =cur.funcid CONNECT BY a.PID = PRIOR a.code ;

  --Dbms_Output.put_line(cur.funcid);

  Dbms_Output.put_line(cur.funcid );

  --遍历全部根菜单下的全部子菜单项,将其写入 BOCO_TEMP_MENURESOURCE 表

  INSERT INTO BOCO_TEMP_MENURESOURCE(DISPLAYNAME,

  URL,

  PID,

  ICON,

  DISORDER,

  CODE,

  ISSHOW)

  SELECT A.DISPLAYNAME, A.URL, A.PID, A.ICON, A.DISORDER, A.CODE, A.ISSHOW FROM BOCO_MENURESOURCE A START WITH A.CODE =cur.funcid CONNECT BY A.PID = PRIOR A.code ;

  END

  LOOP;

  EXCEPTION

  WHEN OTHERS THEN

  Dbms_Output.put_line(SQLERRM);

  END;

  --删除表中反复菜单记录项

  DELETE FROM boco_temp_menuresource

  WHERE code IN (SELECT code FROM

  boco_temp_menuresource GROUP BY code HAVING COUNT(code)>1)

  AND ROWID NOT IN (SELECT MIN(ROWID) FROM boco_temp_menuresource GROUP BY code HAVING COUNT(code)>1);

  --SELECT * FROM BOCO_TEMP_MENURESOURCE;

  COMMIT;

  END;

  作者 Zhijie.Geng


  以上是“sql删除表中的反复记录[MSSQL防范]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • sql删除表中的反复记录
  • SQL删除无限极分类的存储历程(1)
  • sql删除表中某一指定数据的办法
  • <b>两种SQL删除反复记录的情形</b>
  • SQL删除反复记录的四种方法
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .