I have the following type and function:
CREATE OR REPLACE TYPE SERIAL_NUMBER_TABLE AS TABLE OF VARCHAR2(4000);
CREATE OR REPLACE FUNCTION F_DEVICE_SERIAL_TABLE(
SN_LIST IN CLOB,
SN_DELIMITER IN VARCHAR2 DEFAULT ';')
RETURN SERIAL_NUMBER_TABLE
IS
V_STRING LONG := SN_LIST || SN_DELIMITER;
V_POS PLS_INTEGER;
V_DATA SERIAL_NUMBER_TABLE := SERIAL_NUMBER_TABLE();
BEGIN
LOOP
V_POS := INSTR(V_STRING, SN_DELIMITER);
EXIT WHEN (NVL(V_POS, 0) = 0);
V_DATA.EXTEND;
V_DATA(V_DATA.COUNT) := TRIM(SUBSTR(V_STRING, 1, V_POS - 1));
V_STRING := SUBSTR(V_STRING, V_POS + 1);
END LOOP ;
RETURN V_DATA;
END F_DEVICE_SERIAL_TABLE;
And I'm trying to pass a huge string through the following mapping in the IBatis map xml configuration:
<parameterMaps>
<parameterMap id="StringClob" class="DeviceAlias">
<parameter property="SerialNumber" type="String" dbType="CLOB"/>
</parameterMap>
</parameterMaps>
<select id="SelectBySerialNumberList" parameterMap="StringClob" resultMap="DeviceResult">
<![CDATA[
SELECT *
FROM DEVICE D
INNER JOIN
(SELECT * FROM TABLE(CAST(F_DEVICE_SERIAL_TABLE(?) AS SERIAL_NUMBER_TABLE))) SERIAL_TABLE
ON SERIAL_TABLE.COLUMN_VALUE = D.S_NUMBER
]]>
</select>
When I run this code passing a DeviceAlias object with a huge SerialNumber property set (e.g SN0001;SN0002;...), I get the following error:
ORA-01460: unimplemented or unreasonable conversion requested
Any ideas of how to get around this problem? PS: For small entries, this code works
This error is normally caused when you mix PLSQL & SQL.
Try to replace your "dbType" (CLOB) with "VARCHAR as follows:
<parameterMaps>
<parameterMap id="StringClob" class="DeviceAlias">
<parameter property="SerialNumber" type="String" dbType="VARCHAR"/>
</parameterMap>
</parameterMaps>
Other possible causes are as follows: