尝试从长度为18的平面文件中插入记录时,bteq中的insert语句工作正常
INSERT INTO cust(online_customer)
SELECT
CASE
WHEN t1.site_id = 1002 THEN cast(t1.membership as DECIMAL(38,0))
ELSE NULL
END
FROM trans t1
LEFT OUTER JOIN cust1 t2 ON t1.membership = t2.membership AND t1.site_id = t2.site_id
;
但是当长度增加到19 im时,出现以下错误
*** Failure 2616 Numeric overflow occurred during computation.
Statement# 1, Info =0
*** Total elapsed time was 1 second.
在online_customer
和DECIMAL(38,0)
中,cust1
被定义为membership
,VARCHAR(40)
被定义为trans
。 cust1
表具有cust
。
答案 0 :(得分:0)
这可能来自CAST
或INSERT
。尝试分解查询,看看是哪个导致错误。
在查询中,您将VARCHAR(40)
投射到DECIMAL(38,0)
,然后插入到VARCHAR(100)
中。为什么不将VARCHAR
插入VARCHAR
并使用TO_NUMBER()
来确保有效数字:
INSERT INTO cust(online_customer)
SELECT
CAST(
CASE
WHEN t1.site_id = 1002 THEN TO_NUMBER(t1.membership) -- Ensure valid number
END
AS VARCHAR(100)
)
FROM trans t1
LEFT OUTER JOIN cust1 t2 ON t1.membership = t2.membership AND t1.site_id = t2.site_id