以下查询适用于数值数据类型(int,bigint等)。我想做同样的事情,但将它应用于varchar。这可能吗?如何?
CREATE SEQUENCE acct_seq
START WITH 1
INCREMENT BY 1
NO MAXVALUE
NO CYCLE
CACHE 24
;
SELECT accntnum AS new_acct, old_acct
FROM FINAL TABLE (
UPDATE accounts INCLUDE(old_acct INT)
SET accntnum = NEXT VALUE FOR acct_seq, old_acct = accntnum
)
ORDER BY old_acct;
在UPDATE accounts INCLUDE(old_acct INT)
行而不是int我想使用VARCHAR(size)
。大小将在4到100之间。
答案 0 :(得分:1)
首先将INT转换为CHAR,然后转换为VARCHAR。
SET accntnum = cast(cast(NEXT VALUE FOR acct_seq as CHAR(255)) as VARCHAR(255)), old_acct = accntnum