在项目中遇到CLOB文本字符集的处理,但在处理CLOB字符的时候,我不用DBMS_CLOB包里的函数,而直接用
SUBSTR(RESULT VARCHAR2
STR1 IN VARCHAR2
POS IN BINARY_INTEGER
LEN IN BINARY_INTEGER) ,
INSTR()
TRIM()
...
...
等字符串处理函数来处理CLOB字符串,为什么能正常返回字符串结果呢? VARCHAR2 不是最大支持32676字节吗?但我的CLOB里的字符远超过这个数字,真的很让我纳闷了。--------------------
举个例来说明
DECALRE V_AAA CLOB;
BEGIN
SELECT SUBSTR(A,1,500000) INTO V_AAA FROM TABLE_1; /* TABLE_1表中字段A的字符长度有200多万 */
DBMS_OUPT.PUT_LINE(LENGTH(V_AAA)); /* 输出结果是正确的,为 500000 */
END;SUBSTR()函数为什么没截断字符呢?? 不理解....
如果 DECALRE V_AAA CLOB; 申明为 DECALRE V_AAA VARCHAR2(32767);
那么是不能赋值上去了。....难道SUBSTR()函数也能处理大字符串数据?????那还要DBMS_LOB包做什么呢??
SUBSTR(RESULT VARCHAR2
STR1 IN VARCHAR2
POS IN BINARY_INTEGER
LEN IN BINARY_INTEGER) ,
INSTR()
TRIM()
...
...
等字符串处理函数来处理CLOB字符串,为什么能正常返回字符串结果呢? VARCHAR2 不是最大支持32676字节吗?但我的CLOB里的字符远超过这个数字,真的很让我纳闷了。--------------------
举个例来说明
DECALRE V_AAA CLOB;
BEGIN
SELECT SUBSTR(A,1,500000) INTO V_AAA FROM TABLE_1; /* TABLE_1表中字段A的字符长度有200多万 */
DBMS_OUPT.PUT_LINE(LENGTH(V_AAA)); /* 输出结果是正确的,为 500000 */
END;SUBSTR()函数为什么没截断字符呢?? 不理解....
如果 DECALRE V_AAA CLOB; 申明为 DECALRE V_AAA VARCHAR2(32767);
那么是不能赋值上去了。....难道SUBSTR()函数也能处理大字符串数据?????那还要DBMS_LOB包做什么呢??
解决方案 »
- pro*c编程中 预编译选项MODE=ANSI 与MODE=ORACLE 这些在那里设置?为什么MODE=ORACLE 可以直接用变量
- Oracle怎么让两条插入语句同时插入到各子表中
- 请教一下两个Oracle库如何用Dblink保持数据同步?
- 数据累计问题(带表结构及数据)
- 哪里有免费的监测工具,监测oracle数据库性能的而且是图形界面的工具
- 请高手指点这个sql怎么写?
- 安装次序问题
- 8.17版本的ORACLE数据库启不来,我该怎么办?请看错误信息是“ORACLE不可用”
- 我刚学Oracle,问一个比较菜的问题
- ORACLE sql Developer 解析XML
- sql函数转oracle
- PL/SQL 存储过程怎么使用临时表
不是什么SQL中和PL/SQL中的的神奇之处,在SQL中一样也可以.....
ORACLE对VARCHA2定义好象没说清楚.....
谁能解开这个迷团,分就是谁的....
The SUBSTR functions return a portion of char, beginning at character position, substring_length characters long. SUBSTR calculates lengths using characters as defined by the input character set. SUBSTRB uses bytes instead of characters. SUBSTRC uses Unicode complete characters. SUBSTR2 uses UCS2 code points. SUBSTR4 uses UCS4 code points.If position is 0, then it is treated as 1.If position is positive, then Oracle Database counts from the beginning of char to find the first character.If position is negative, then Oracle counts backward from the end of char.If substring_length is omitted, then Oracle returns all characters to the end of char. If substring_length is less than 1, then Oracle returns null.char can be any of the datatypes CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB. Both position and substring_length must be of datatype NUMBER, or any datatype that can be implicitly converted to NUMBER, and must resolve to an integer. The return value is the same datatype as char. Floating-point numbers passed as arguments to SUBSTR are automatically converted to integers.
char(2000B)
varchar2(4000B)CLOB/BLOB/NCLOB 4GB