Chan Chen Coding...

          SP

          -- --------------------------------------------------------------------------------
          -- Routine DDL
          -- Note: comments before and after the routine body will not be stored by the server
          -- --------------------------------------------------------------------------------
          DELIMITER $$
          CREATE DEFINER=`root`@`localhost` PROCEDURE `chan_insert_date_by_starttime`()
          BEGIN
            DECLARE var_id decimal(18,0); 
            DECLARE var_issue decimal(18,0); 
            DECLARE var_date datetime ;
            DECLARE cur1 CURSOR FOR 
              SELECT issue, datevalue 
              FROM jira.customfieldvalue
              where customfield in (10006,10007)
              and issue in (
                  SELECT distinct issue
                  FROM jira.customfieldvalue
                  where customfield in (10007)
              )
              and issue not in (
                  SELECT distinct issue
                  FROM jira.customfieldvalue
                  where customfield in (10006)
              );
            OPEN cur1;
            read_loop: LOOP
              FETCH cur1 INTO var_issue, var_date;
                select (max(id) + 1) into var_id from jira.customfieldvalue ;
                INSERT INTO jira.customfieldvalue(id,issue, customfield,datevalue) 
                VALUES (var_id,var_issue,10006, var_date);
            END LOOP;
            CLOSE cur1;
          END



          -- --------------------------------------------------------------------------------
          -- Routine DDL
          -- Note: comments before and after the routine body will not be stored by the server
          -- --------------------------------------------------------------------------------
          DELIMITER $$
          CREATE DEFINER=`root`@`localhost` PROCEDURE `chan_insert_date_by_created`()
          BEGIN
            DECLARE var_id decimal(18,0); 
            DECLARE var_issue decimal(18,0); 
            DECLARE var_date datetime ;
            DECLARE cur1 CURSOR FOR 
              SELECT id, created FROM jira.jiraissue where id in 
              (    SELECT issue 
                  FROM jira.customfieldvalue
                  where customfield in (10000)
                  and issue not in (
                      SELECT distinct issue
                      FROM jira.customfieldvalue
                      where customfield in (10007)
                  )
                  and issue not in (
                      SELECT distinct issue
                      FROM jira.customfieldvalue
                      where customfield in (10006)
                  )
              )  ;
           
            OPEN cur1;
            read_loop: LOOP
              FETCH cur1 INTO var_issue, var_date;
                select (max(id) + 1) into var_id from jira.customfieldvalue ;
                INSERT INTO jira.customfieldvalue(id,issue, customfield,datevalue) 
                VALUES (var_id,var_issue,10006, var_date);
            END LOOP;
            CLOSE cur1;
          END


          -----------------------------------------------------
          Silence, the way to avoid many problems;
          Smile, the way to solve many problems;

          posted on 2012-04-10 18:14 Chan Chen 閱讀(205) 評論(0)  編輯  收藏 所屬分類: DB

          主站蜘蛛池模板: 浦江县| 江北区| 利川市| 延川县| 英德市| 迁安市| 琼结县| 西丰县| 双峰县| 綦江县| 杂多县| 苏州市| 汕尾市| 简阳市| 雷州市| 崇左市| 宁都县| 丹阳市| 西藏| 林周县| 延津县| 长垣县| 通辽市| 临泽县| 栾川县| 克东县| 三原县| 内乡县| 平凉市| 象州县| 论坛| 祁门县| 略阳县| 乐亭县| 江陵县| 康马县| 阿克陶县| 彭泽县| 阳朔县| 宜都市| 云阳县|