Oracle 使用 varchar 更新 CLOB
我有一个表TABLENAME,其COLUMNNAME数据类型为CLOB。例如,它仅包含 3 行,其中 COLUMNNAME 的 1st 行值为 123,456,789,2nd 为 NULL 和 3rd 是一个空字符串
当我运行这个查询时,我有这个查询
UPDATE TABLENAME
SET COLUMNNAME = COLUMNNAME || CASE
WHEN TRIM(COLUMNNAME) = '' OR COLUMNNAME IS NULL THEN
'098765'
ELSE ',098765'
END
,我收到错误消息ORA-00932:不一致的数据类型:预期 - 得到 CLOB
如何修复它?
我使用 Oracle 数据库 10g 企业版版本 10.2.0.1.0 - 64 位
I have a table TABLENAME with COLUMNNAME data type is CLOB. For example it's contains only 3 rows with 1st row of COLUMNNAME value is 123,456,789 and the 2nd is NULL and the 3rd is an empty string
And I have this query
UPDATE TABLENAME
SET COLUMNNAME = COLUMNNAME || CASE
WHEN TRIM(COLUMNNAME) = '' OR COLUMNNAME IS NULL THEN
'098765'
ELSE ',098765'
END
when I run this query, I've got error message ORA-00932: inconsistent datatypes: expected - got CLOB
how to fix it?
I use Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - 64bit
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,TRIM(COLUMNNAME) = '' 总是会失败,因为 '' 为 NULL 并且无法与等号匹配。
尝试使用 PL/SQL :
字符串文字被定义为 CHAR,它可以很好地转换为 VARCHAR2,但当您尝试将其视为 CLOB 时,会出现不兼容错误。
Firstly, TRIM(COLUMNNAME) = '' will always fail as '' is NULL and doesn't get matched by an equals.
Try using PL/SQL :
A string literal is defined as a CHAR which converts nicely to a VARCHAR2 but through incompatibility errors when you try to treat it like a CLOB.