Oracle is still quite common, So I studied the Oracle Clob type and shared it with you here. I hope it will be useful to you. Oracle Clob type processing parsing recently used the NHibernate ing type to insert data into the Clob field. It is found that when the number of characters is one byte, one byte, and one full byte) an error occurred between 2000-4000: ORA-01461: only LONG values in LONG columns can be inserted ). Oracle Clob type Method 1: directly spell the CLOB value in an SQL statement. Code:
- StringId=Guid. NewGuid (). ToString ();
- OracleCommandCmd=Conn. CreateCommand ();
- Cmd. CommandText="Insert into xx (id, test) values ('"+ Id + "','" + data + "')";
- // Data is a variable that stores the string you want to insert
- Cmd. ExecuteNonQuery ();
Case Analysis: an error is reported when the length of data is greater than 4000 (ORA-01704: text string is too long) and is inserted normally if the length is less than or equal to 4000.
Cause Analysis: an error occurs when the length is greater than 4000 because the number of characters between two single quotes in Oracle SQL statements cannot exceed 4000. '"+ Data +" 'data is between SQL statements. If the value of data is greater than 4000 bytes, an error is returned.
Solution: This method is tricky, but there is a better method, which will be discussed below.
Oracle Clob type Method 2: parameter format. Code:
- StringId=Guid. NewGuid (). ToString ();
- OracleCommandCmd=Conn. CreateCommand ();
- Cmd. CommandText="Insert into xx (id, test) values ('"+ Id + "','" + data + "')";
- // Data is a variable that stores the string you want to insert
- Cmd. ExecuteNonQuery ();
Situation Analysis: This method can be used for normal insertion. This method is recommended.
Cause Analysis: None
Solution: None
- Oracle listener, let you listen to what you want
- Do you know the Oracle. Net protocol stack?
- Introduction to Oracle Database Optimizer
- Brief Introduction to Oracle Provider
- Detailed description of the Execution Plan for capturing Oracle SQL statements