home wiki.fukuchiharuki.me
Menu

参照

パスを取得する

子を取得する

部分木を取得する

更新

リーフを追加する

  • objecttarget下に
    UPDATE 
      02_DIRECTORY Target
        INNER JOIN
      02_DIRECTORY Shift
        ON 
          Shift.R >= Target.R
    SET
      Shift.R = Shift.R + 2
    , Shift.L = CASE WHEN Shift.L > Target.L 
                  THEN Shift.L + 2 
                  ELSE Shift.L 
                END
    WHERE
      Target.DIRECTORY_ID = :target;
    
    INSERT INTO 02_DIRECTORY
    SELECT :object, R-2 AS L, R-1 AS R FROM 02_DIRECTORY WHERE DIRECTORY_ID = :target;

部分木を移動する

  • objecttarget下に
    UPDATE 
      02_DIRECTORY Target
        INNER JOIN
      02_DIRECTORY Shift
        ON 
          Shift.R >= Target.R
        INNER JOIN
      02_DIRECTORY Object
        ON 
          Object.DIRECTORY_ID = :object
    SET
      Shift.R = Shift.R + (Object.R - Object.L + 1)
    , Shift.L = CASE WHEN Shift.L > Target.L 
                  THEN Shift.L + (Object.R - Object.L + 1)
                  ELSE Shift.L 
                END
    WHERE
      Target.DIRECTORY_ID = :target;
    
    UPDATE 
      02_DIRECTORY Target
        INNER JOIN
      02_DIRECTORY Object
        ON 
          Object.DIRECTORY_ID = :object
        INNER JOIN
      02_DIRECTORY Shift
        ON 
          Shift.L >= Object.L
          AND
          Shift.R <= Object.R
    SET
      Shift.R = Shift.R + (Target.R - 1 - Object.R)
    , Shift.L = Shift.L + (Target.R - 1 - Object.R)
    WHERE
      Target.DIRECTORY_ID = :target;