Clob Class 介紹

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對象的副本。

發佈了124 篇原創文章 · 獲贊 17 · 訪問量 23萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章