Clob Class
The Clob class defines the common properties of objects of type CLOB. A CLOB is a large character object stored as a column value in a row of a database table. A Clob object contains a logical pointer to a CLOB, not the CLOB itself.
译:Clob类定义了CLOB类型的对象的通用属性。
Methods of the Clob class enable you to perform specific tasks related to Clob objects, including methods for getting the length of a SQL CLOB, for materializing a CLOB on the client, and for extracting a part of the CLOB.
译:你可以通过Clob类的方法来实现和Clob对象相关的特定任务,包括获取CLOB的长度等。
Methods in the ResultSet and Statement classes, such as getClob() and setClob(), enable you to access an SQL CLOB value.
1. To create a null Clob object, use the syntax:
Clob();
译:通过上面的语法创建一个空的Clob对象。
The only methods valid on a null Clob object are setNull(), isNull(), and operator=().
译:对于一个空的Clob对象,只有setNull(),isNull()和operator=()三个方法是可用的。
也就是说,一个空的Clob对象,除了等着被赋值之外,没有任何实际意义。
2. To create an uninitialized Clob object, use the syntax:
Clob(const Connection *connectionp);
译:通过上面的语法可以创建一个未被初始化的Clob对象。
An uninitialized Clob object can be initialized by:
译:一个未被初始化的Clob对象可以通过以下方面进行初始化:
The setEmpty() method. The CLOB can then be modified by inserting this CLOB into the table and retrieving it using SELECT … FOR UPDATE. The write() method will modify the CLOB; however, the modified data will be flushed to the table only when the transaction is committed. Note that an insert is not required.
译:使用setEmpty()方法,将一个未初始化的Clob对象置空。这时无法直接调用write()方法,需要将此对象先插入到数据库,然后使用SELECT ... FOR UPDATE
将对象取出来 ,才能使用write()方法来修改,但是只有等事务提交的时候,修改后的数据才会写到表中。另外插入语句不是必须的,也就是说,如果当前是INSERT,那么就按这个方法来做,但如果当前是UPDATE,则可以先更新非CLOB字段,然后使用SELECT ... FOR UPDATE
将CLOB对象取出来,再更新。
这里比较绕,在后续的文章里,我会以源代码的方式来介绍到底是如何实现的。Assigning an initialized Clob object to it.
译:将一个已经初始化的对象赋值给它。
3. To create a copy of a Clob object, use the syntax:
Clob(const Clob &srcClob);
译:通过上面的语法创建一个Clob对象的副本。