Oracle Error Workaround

Source: Internet
Author: User
Tags oracleconnection

Some problems occurred when using ORACLE in the actual project. The problem is avoided through the work und. I wrote this article to make it easy to use!

1. ORA-01403: no data found-NO DATA FOUND

A. Add an exception to handle the exception.

Exception when NO_DATA_FOUND THEN...

B. Use count to calculate whether the value is greater than 0, that is, whether there is a value. If there is no value, 0 is returned instead of NULL.

Select count (*) into field from table where...

2. ORA-01704: string literal too long-text STRING is TOO LONG

This error message is displayed when you INSERT a long-byte field CONTEXT to ORACLE using a statement similar to insert into table (ID, CONTEXT) VALUES ('1 ','... ').

A. parameters can be used in the program.

C # code

1 OracleConnection ocon = new OracleConnection ();
2 OracleCommand ocom = new OracleCommand (SQL, ocon );
3 ocom. Connection. Open ();
4 ocom. Parameters. Add (": Value", OracleType. Blob );
5 ocom. Parameters [": Value"]. Value = longvalue;
6 ocom. ExecuteNonQuery ();

B. It is relatively simple to use stored procedures, as long as the parameters are passed in.

DECLARE
V_context CLOB: = 'long context ';
BEGIN
Insert into table (ID, CONTEXT) VALUES ('1',: v_context );
END;

 

Agoni 2010-04-10

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.