Update lower/upper bound of range type

前端 未结 3 1395
走了就别回头了
走了就别回头了 2021-02-08 19:13

I have column of tstzrange type (timestamp with time zone range) and I need to update only upper or lower bound of this value (and keep inclusive/exclusive boundari

3条回答
  •  隐瞒了意图╮
    2021-02-08 20:10

    I found function I missed, it's possible to do that like this

    UPDATE table
    SET
        my_column = tstzrange(
            lower(my_column),
            now(),
            concat(
                CASE WHEN lower_inc(my_column) THEN '[' ELSE '(' END,
                CASE WHEN upper_inc(my_column) THEN ']' ELSE ')' END
            )
        )
    

    It would be better to create function for this probably. Or is there any other (simpler/better) solution?

提交回复
热议问题