나는 다음과 같은 기능이 있습니다오라클 NCLOB 문제
CREATE OR REPLACE FUNCTION GetVarchar2 (iclCLOB IN Nvarchar2)
return NVARCHAR2
IS
cnuMAX_LENGTH Constant number := 32767 ;
nuLength Number := DBMS_LOB.getlength(iclCLOB);
sbBuffer Nvarchar2(32767);
begin
dbms_lob.read(iclCLOB,nuLength,1,sbBuffer);
return sbBuffer;
END;
내가 같이 호출 :
select GetVarChar2(text) from posts where postid = 'anId';
내가이 오류를 :
ORA-22835: Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: 6058, maximum: 2000)
22835. 00000 - "Buffer too small for CLOB to CHAR or BLOB to RAW conversion (actual: %s, maximum: %s)"
*Cause: An attempt was made to convert CLOB to CHAR or BLOB to RAW, where
the LOB size was bigger than the buffer limit for CHAR and RAW
types.
Note that widths are reported in characters if character length semantics are in effect for the column, otherwise widths are reported in bytes.
*Action: Do one of the following
1. Make the LOB smaller before performing the conversion,
for example, by using SUBSTR on CLOB
2. Use DBMS_LOB.SUBSTR to convert CLOB to CHAR or BLOB to RAW.
문제는 그 NCLOB 유형의 게시물 테이블에있는 텍스트 크기이며 6059 바이트입니다. 함수를 호출하지 않고 이렇게하면 잘 실행되기 때문에 이상합니다. 즉 다음 스크립트를 실행할 때 :
declare
iclCLOB nvarchar2(6100) := 'Here is the same 6059 bytes string';
cnuMAX_LENGTH number := 32767 ;
nuLength Number := DBMS_LOB.getlength(iclCLOB);
sbBuffer Nvarchar2(32767);
sbBuffer1 Nvarchar2(32767);
begin
dbms_lob.read(iclCLOB,nuLength,1,sbBuffer);
select GetVarChar2(text) into sbBuffer1 from posts where postid = 'anId';
end;
아무런 문제없이 실행됩니다.
감사합니다.
마지막 예제가 문제없이 실행되지 않는다고 생각합니다. 그것은 SELECT ... INTO인가요? – DCookie
당신이 옳습니다. 복사 - 붙여 넣기 실수였습니다. – Shayan