DBMS_LOB.substr returns 空
DBMS_LOB.substr returns null
v_tmp_clob := DBMS_LOB.substr(v_qry_strng, dbms_lob.getlength(v_qry_strng)-10,1);
上一行 returns 为空,尽管 v_qry_strng
是一个长度为 32897 个字符的 CLOB ... 谁能解释一下?
您没有指定 Oracle 版本。
DBMS_LOB.SUBSTR
returns a VARCHAR2
(除其他外,但不包括 CLOB
),最多可容纳 32767 字节的字符。
此外,DBMS_LOB.SUBSTR
returns NULL
following conditions:
- 任何参数显式为 NULL
- 参数 2(数量)< 1
- 参数 2(数量)> 32767
- 参数 3(偏移量)< 1
- 参数 3(偏移量)>
LOBMAXSIZE
在你的表达式中,你有:dbms_lob.getlength(v_qry_strng)-10
--> 32897-10
--> 32887
作为参数 2.
32887 > 32767
<-- 这就是为什么。
更新:
要直接从 LOB 复制到 LOB,请使用 DBMS_LOB.COPY
。
在你的例子中,它可能是这样的:
DBMS_LOB.COPY(v_tmp_clob, v_qry_strng, DBMS_LOB.GETLENGTH(v_qry_strng) - 10, 1, 1);
v_tmp_clob := DBMS_LOB.substr(v_qry_strng, dbms_lob.getlength(v_qry_strng)-10,1);
上一行 returns 为空,尽管 v_qry_strng
是一个长度为 32897 个字符的 CLOB ... 谁能解释一下?
您没有指定 Oracle 版本。
DBMS_LOB.SUBSTR
returns a VARCHAR2
(除其他外,但不包括 CLOB
),最多可容纳 32767 字节的字符。
此外,DBMS_LOB.SUBSTR
returns NULL
following conditions:
- 任何参数显式为 NULL
- 参数 2(数量)< 1
- 参数 2(数量)> 32767
- 参数 3(偏移量)< 1
- 参数 3(偏移量)>
LOBMAXSIZE
在你的表达式中,你有:dbms_lob.getlength(v_qry_strng)-10
--> 32897-10
--> 32887
作为参数 2.
32887 > 32767
<-- 这就是为什么。
更新:
要直接从 LOB 复制到 LOB,请使用 DBMS_LOB.COPY
。
在你的例子中,它可能是这样的:
DBMS_LOB.COPY(v_tmp_clob, v_qry_strng, DBMS_LOB.GETLENGTH(v_qry_strng) - 10, 1, 1);