Restrictions on the length of OracleSql statements and Solutions

Source: Internet
Author: User
Recently when writing SQL statements, encountered two problems: 1) ORA-01795: maximumnumberofexpressionsinalistis1000 cause: Write such SQL statement:

Recently I encountered two problems when writing SQL statements: 1) ORA-01795: maximum number of expressions in a list is 1000 cause: I wrote such an SQL statement:

When I was writing SQL statements recently, I encountered two problems:

1) ORA-01795: maximum number of expressions in a list is 1000

Cause: the following SQL statement is written: SELECT PALLET_ID, BOX_ID, STATUS FROM SD_CURRENT_BOX WHERE PALLET_ID IN ('"+ pallets + "'); among them, pallets is a string composed of many pallet_ids.

Analysis: Obviously, according to the error prompt, we can know that there are 1000 items restrictions in.

Solution: replace pallets long strings with subqueries.

2) ORA-01704: string literal too long

Cause: the following SQL statement is written: UPDATE PDM_MEMBERLIST SET MEMBERS =' ... N multiple strings are omitted here '.

Analysis: The MEMBERS field in the database design is in xmltype format. data is stored as strings. In this way, when the xml data volume is large, the SQL statement is too long and the limit of 2 K has been tasted.

Solution: parameterized 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.