Brief description of Oracle Clob type

Source: Internet
Author: User

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:

 
 
  1. StringId=Guid. NewGuid (). ToString ();
  2. OracleCommandCmd=Conn. CreateCommand ();
  3. Cmd. CommandText="Insert into xx (id, test) values ('"+ Id + "','" + data + "')";
  4. // Data is a variable that stores the string you want to insert
  5. 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:

 
 
  1. StringId=Guid. NewGuid (). ToString ();
  2. OracleCommandCmd=Conn. CreateCommand ();
  3. Cmd. CommandText="Insert into xx (id, test) values ('"+ Id + "','" + data + "')";
  4. // Data is a variable that stores the string you want to insert
  5. Cmd. ExecuteNonQuery ();

Situation Analysis: This method can be used for normal insertion. This method is recommended.

Cause Analysis: None

Solution: None

  1. Oracle listener, let you listen to what you want
  2. Do you know the Oracle. Net protocol stack?
  3. Introduction to Oracle Database Optimizer
  4. Brief Introduction to Oracle Provider
  5. Detailed description of the Execution Plan for capturing Oracle SQL statements

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.