oracle11gclobibatis.net

Problem passing a huge string to an stored function via IBatis.Net


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


Solution

  • 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:

    1. Incompatible character sets can cause an ORA-01460
    2. Using SQL Developer, attempting to pass a string to a bind variable value in excess of 4000 bytes can result in an ORA-01460
    3. With ODP, users moving from the 10.2 client and 10.2 ODP to the 11.1 client and 11.1.0.6.10 ODP reported an ORA-01460 error. This was a bug that should be fixed by patching ODP to the most recent version.