Home  >  Article  >  Database  >  Oracle Sql语句长度限制问题及解决

Oracle Sql语句长度限制问题及解决

WBOY
WBOYOriginal
2016-06-07 16:55:432510browse

最近在写Sql语句时,碰到两个问题:1)ORA-01795: maximum number of expressions in a list is 1000起因:写出了这样的sql语句:

最近在写Sql语句时,碰到两个问题:

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

起因:写出了这样的sql语句:SELECT PALLET_ID,BOX_ID,STATUS FROM SD_CURRENT_BOX WHERE PALLET_ID IN('"+pallets+"');其中的pallets是有很多个pallet_id组合成的字符串。

分析:很显然,,根据错误提示可以知道:in 中items的限制 1000个。

解决:用子查询来代替pallets长字串。

2)ORA-01704: string literal too long

起因:写出了这样的Sql语句:UPDATE PDM_MEMBERLIST SET MEMBERS=' ...  此处略去n多串 '.

分析:数据库设计MEMBERS字段为xmltype格式,数据存储时候,是以字符串的形式存储。这样在xml数据量大的时候,造成sql语句过长,尝过2k的限制。

解决:参数化sql语句。

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn