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

          主站蜘蛛池模板: 繁峙县| 阿鲁科尔沁旗| 河池市| 松桃| 阳原县| 汕尾市| 察雅县| 和林格尔县| 理塘县| 康马县| 渭南市| 波密县| 安岳县| 晋中市| 女性| 贵州省| 咸丰县| 兖州市| 桐庐县| 盖州市| 宁强县| 鲁山县| 宝坻区| 赤水市| 桐庐县| 阜新市| 博湖县| 双流县| 盘山县| 常德市| 新疆| 嘉鱼县| 龙游县| 两当县| 开鲁县| 四平市| 大庆市| 休宁县| 沛县| 南通市| 永定县|