DataType problem with CLOB, NVARCHAR, VARCHAR
698601May 8 2009 — edited May 8 2009Hi,
I've a problem with datatypes, espacially CLOB, VARCHAR, NVARCHAR in the following scenario.
A stored proc is called from .NET side (C#) via Oracle.DataAccess.
It has a input parameter which get the converted .NET Guids comma seperated like:
'0C4C80FA54A642169444DDCEFB1CD532,13B8F699FC9245689F22D81016381624,18BCD6CE55FF47A1B742EDBA238E5A64'
I have a pipelined function that splits these string and puts each entry into the TABLE of the function.
Following type and SplitFunction i've created:
CREATE OR REPLACE TYPE VARCHAR_TAB AS TABLE OF VARCHAR2(32);
CREATE OR REPLACE FUNCTION SPLITIDs
+(+
pList NVARCHAR2,
pDelimeter VARCHAR2 := ','
+)+
RETURN VARCHAR_TAB PIPELINED
IS
vIdx PLS_INTEGER;
+vList VARCHAR2(32767) := pList; --CLOB := pList;+
vCurrentID RAW(16);
vValue VARCHAR2(32);
BEGIN
LOOP
vIdx := INSTR(vList, pDelimeter);
IF vIdx > 0 THEN
vValue := RTRIM(LTRIM(SUBSTR(vList, 1, vIdx - 1)));
-- vCurrentID := HEXTORAW(vValue);
PIPE ROW(vValue);
--PIPE ROW(vCurrentID);+
vList := SUBSTR(vList, vIdx LENGTH(pDelimeter));+
ELSE
vValue := RTRIM(LTRIM(SUBSTR(vList, 1, LENGTH(vList))));
--vCurrentID := HEXTORAW(vValue);+
--vCurrentID := UTL_RAW.CAST_TO_RAW(HEXTORAW(vValue));+
PIPE ROW(vValue);
-- PIPE ROW(vCurrentID);
EXIT;
END if;
END LOOP;
RETURN;
END SPLITIDs;
The SP gets the ID - String as
p_IDList IN CLOB DEFAULT NULL
Than i use EXECUTE IMMEDIATE, a context to build my statements:
-- set param to context
DYNAMICSQL_CONTEXT.CONTEXT_SETPARAM('mIDList', p_IDList);
and use the SPLITIDS function like (only a the calling part posted)
+' WHERE pru.ID IN (SELECT * FROM TABLE(SPLITIDS(SYS_CONTEXT(''parameter'', ''mIDList'')))) '+
The ID Field which is compared is a RAW(16) column.
Now the problem:
If i call the SP with only one ID passed, it works, but if i call it with > 1 ID it crashes with the error:
Message = "ORA-06502: PL/SQL: numeric or value error: character string buffer too small\nORA-06512: at \"SPLITIDS\", line 21\nORA-06512: at line 1"
During my test yesterday it succeeds with more than 1 param, but i couldn't find, what i change yesterday.
I mean i've changed some datatypes, but couldn't find the part :(
Can somebody help me to fix this problem?
Thx a lot again.