使用 CLOB 给出 ORA-06502: PL/SQL: 数字或值错误
Using CLOB gives ORA-06502: PL/SQL: numeric or value error
下面的代码抛出一个错误:“ORA-06502:PL/SQL:数字或值错误
ORA-06512: 在第 24 行。
DECLARE
v_clob CLOB;
CURSOR cur_a
IS
SELECT
device_num,
Account_number,
CustomerName,
Prem_address ,
contact_phone ,
W_status ,
A_status ,
"12-1 AM" Twelve21,
"1-2 AM" One22,
"2-3 AM" Two23,
"3-4 AM" Three24,
CIn4Hrs
FROM account a
WHERE 1 =1 ;
BEGIN
DBMS_LOB.CreateTemporary( v_clob, true );
FOR rec IN cur_a
LOOP
v_clob := v_clob ||rec.device_num|| ',' ||rec.Account_number|| ',' ||rec.contact_phone || ',' ||rec.W_status|| ',' ||rec.A_status|| ',' ||rec.Twelve21|| ',' ||rec.One22|| ',' ||rec.Two23|| ',' ||rec.Three24|| ',' ||rec.CIn4Hrs|| ',' ||SUBSTR(rec.CustomerName,1,15)|| ',' ||SUBSTR(rec.Prem_address,1,15) || UTL_TCP.crlf;
END LOOP;
END;
您不能使用字符串连接运算符||附加到 clob。 VARCHAR2(记录字段的默认类型)最大为 32K。 clob 的大小超过了那个。你需要包裹
每个元素都带有 to_clob 函数,例如:
v_clob || to_clob(rec.device_num) || ',' || to_clob(rec.Account_number)
等等
下面的代码抛出一个错误:“ORA-06502:PL/SQL:数字或值错误 ORA-06512: 在第 24 行。
DECLARE
v_clob CLOB;
CURSOR cur_a
IS
SELECT
device_num,
Account_number,
CustomerName,
Prem_address ,
contact_phone ,
W_status ,
A_status ,
"12-1 AM" Twelve21,
"1-2 AM" One22,
"2-3 AM" Two23,
"3-4 AM" Three24,
CIn4Hrs
FROM account a
WHERE 1 =1 ;
BEGIN
DBMS_LOB.CreateTemporary( v_clob, true );
FOR rec IN cur_a
LOOP
v_clob := v_clob ||rec.device_num|| ',' ||rec.Account_number|| ',' ||rec.contact_phone || ',' ||rec.W_status|| ',' ||rec.A_status|| ',' ||rec.Twelve21|| ',' ||rec.One22|| ',' ||rec.Two23|| ',' ||rec.Three24|| ',' ||rec.CIn4Hrs|| ',' ||SUBSTR(rec.CustomerName,1,15)|| ',' ||SUBSTR(rec.Prem_address,1,15) || UTL_TCP.crlf;
END LOOP;
END;
您不能使用字符串连接运算符||附加到 clob。 VARCHAR2(记录字段的默认类型)最大为 32K。 clob 的大小超过了那个。你需要包裹 每个元素都带有 to_clob 函数,例如:
v_clob || to_clob(rec.device_num) || ',' || to_clob(rec.Account_number)
等等