如何在 Oracle9i 中使用大于 4000 个字符的字符串运行 REPLACE 函数
我有以下 PLSQL 块,当 ln_length 为 4000 个字符或更少时,它会成功,但当 ln_length > 4000 个字符时,会失败并显示“ORA-01460:未实现或不合理的转换请求”。 4000 个字符。
该块是:
DECLARE
ls_string VARCHAR2(32767);
ls_temp VARCHAR2(32767);
ln_length NUMBER := 4000;
BEGIN
ls_string := '';
FOR i IN 1..ln_length LOOP
ls_string := ls_string || 'x';
END LOOP;
SELECT REPLACE(ls_string,'bob')
INTO ls_temp FROM dual;
END;
我如何编写一段等效的代码来满足长度最大为 32k 的字符串?
I have the following block of PLSQL that succeeds when ln_length is 4000 characters or less but fails with "ORA-01460: unimplemented or unreasonable conversion requested" when ln_length is > 4000 characters.
The block is:
DECLARE
ls_string VARCHAR2(32767);
ls_temp VARCHAR2(32767);
ln_length NUMBER := 4000;
BEGIN
ls_string := '';
FOR i IN 1..ln_length LOOP
ls_string := ls_string || 'x';
END LOOP;
SELECT REPLACE(ls_string,'bob')
INTO ls_temp FROM dual;
END;
How would I write an equivalent piece of code that caters for strings up to 32k in length?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有 9i 来测试,但也许这可以解决这个问题:
replace:
with:
RDBMS 引擎仅支持 VARCHAR2 的最大长度为 4000,而 PL/SQL 支持最大长度为 32767。避免访问数据库进行 REPLACE操作(无论如何都是不必要的)并且它似乎可以工作(至少有 10g)。
Don't have 9i to test with, but perhaps this will get around it:
replace:
with:
The RDBMS engine only supports VARCHAR2's up to 4000 in length, while PL/SQL supports up to 32767. Avoid going to the database for the REPLACE operation (it's unnecessary anyway) and it seems to work (at least w/ 10g).