本文介绍了SQL - 你如何比较 CLOB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 DB2 触发器中,我需要比较 CLOB 字段的值.类似的东西:

in a DB2 trigger, I need to compare the value of a CLOB field.Something like:

IF OLD_ROW.CLOB_FIELD != UPDATED_ROW.CLOB_FIELD

但是 "!=" 不适用于比较 CLOB.

but "!=" does not work for comparing CLOBs.

比较的方法是什么?

编辑添加:

如果在更新期间更改了 Clob 字段,我的触发器需要执行一些操作.这就是我需要比较触发器代码中的 2 个 CLOB 的原因.我正在寻找有关如何完成此操作的详细信息

My trigger needs to do some action if the Clob field was changed during an update. This is the reason I need to compare the 2 CLOBs in the trigger code.I'm looking for some detailed information on how this can be done

推荐答案

在 Oracle 10g 中,您可以使用 DBMS_LOB.compare() API.

In Oracle 10g you can use DBMS_LOB.compare() API.

示例:

select * from table t where dbms_lob.compare(t.clob1, t.clob2) != 0

完整的 API:

DBMS_LOB.COMPARE (
   lob_1            IN BLOB,
   lob_2            IN BLOB,
   amount           IN INTEGER := 4294967295,
   offset_1         IN INTEGER := 1,
   offset_2         IN INTEGER := 1)
  RETURN INTEGER;

DBMS_LOB.COMPARE (
   lob_1            IN CLOB  CHARACTER SET ANY_CS,
   lob_2            IN CLOB  CHARACTER SET lob_1%CHARSET,
   amount           IN INTEGER := 4294967295,
   offset_1         IN INTEGER := 1,
   offset_2         IN INTEGER := 1)
  RETURN INTEGER;

DBMS_LOB.COMPARE (
   lob_1            IN BFILE,
   lob_2            IN BFILE,
   amount           IN INTEGER,
   offset_1         IN INTEGER := 1,
   offset_2         IN INTEGER := 1)
  RETURN INTEGER;

这篇关于SQL - 你如何比较 CLOB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 21:29