简体   繁体   English

db2 REGEXP_INSTR 问题与大输入字符串

[英]db2 REGEXP_INSTR issue with large input string

DB2 Regular expression REGEXP_INSTR works perfectly using host variables(pl1 program), but somehow it has issues when the input string has more than 360 characters, trailing spaces would not be a issue. DB2 正则表达式 REGEXP_INSTR 使用主机变量(pl1 程序)完美地工作,但是当输入字符串超过 360 个字符时它会出现问题,尾随空格不会成为问题。



        3 Info          CHAR(378),

       EXEC SQL
       SELECT REGEXP_INSTR(:Info,
                           :RG_EXPR,
                           1,
                           1)
             INTO   :REGEXP_START
             FROM SYSIBM.DUAL;

Error Message:错误信息:

SQL0302N The value of a host variable in the EXECUTE or OPEN statement is out of range for its corresponding use. SQL0302N EXECUTE 或 OPEN 语句中的主变量值超出了相应使用的范围。 .SQL STATE=22001. .SQL 状态=22001。

Edit: Issue seems to be resovlved when I use a VAR CHAR variable instead.编辑:当我改用 VAR CHAR 变量时,问题似乎得到了解决。 But this issue occurs with non-var char field with large inputs.但是这个问题发生在具有大量输入的非 var char 字段中。

This is less to do with regexp_instr() than simple fundamentals.这与 regexp_instr() 的关系不如简单的基础知识。

Instead, it concerns Db2 database fundamentals, specifically the maximum length of fixed length character strings.相反,它涉及 Db2 数据库基础知识,特别是固定长度字符串的最大长度。

A fixed length character string (data type CHAR in SQL) in Db2 can occupy between 1 and 255 bytes. Db2 中的固定长度字符串(SQL 中的数据类型 CHAR)可以占用 1 到 255 个字节。

A variable length character string (database type VARCHAR and others) can occupy between 1 and 32,672 bytes.可变长度字符串(数据库类型 VARCHAR 等)可以占用 1 到 32,672 个字节。

If you need longer length strings, then you need to use large objects (for example CLOB which allows up to 2gigabytes).如果您需要更长的字符串,那么您需要使用大对象(例如 CLOB,它最多允许 2GB)。

Please refer to the documentation for your Db2-version on your Db2 platform (z/os, i series, linux/unix/windows).请参阅 Db2 平台(z/os、i 系列、linux/unix/windows)上的 Db2 版本的文档。

Your host variables need to reflect these rules, and your host variables must match (or be fully compatible with) the database columns or result-set columns to/from which they are assigned.您的主机变量需要反映这些规则,并且您的主机变量必须匹配(或完全兼容)数据库列或分配它们的结果集列。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM