ORA-01461: can bind a LONG value only for insert into a LONG column-Occurs when querying

前端 未结 15 1756
野的像风
野的像风 2020-11-30 02:44

When I try to query objects, I end up with following error:

ORA-01461: can bind a LONG value only for insert into a LONG column

Could someo

相关标签:
15条回答
  • 2020-11-30 03:34

    In my particular case, I was trying to store a Base64 encoded file into a table BLOB field, using Mybatis.

    So in my xml I had:

    <insert id="save..." parameterType="...DTO">
        <selectKey keyProperty="id" resultType="long" order="BEFORE">
            SELECT SEQ.nextVal FROM DUAL
        </selectKey>
        insert into MYTABLE(
            ID,
            ...,
            PDF
        ) values (
            #{id, jdbcType=VARCHAR},
            ...,
            #{tcPdf, jdbcType=BLOB},
        )
    </insert>
    

    and in my DTO:

    String getPdf(){
        return pdf;
    }
    

    That makes to Mybatis threat as if were a String char sequence and try to store it as a Varchar. So my solution was the following:

    In my DTO:

    Byte[] getPdf(){
        return pdf.getBytes();
    }
    

    And worked.

    I hope this could help anybody.

    0 讨论(0)
  • 2020-11-30 03:37

    I was facing the same issue and solve it by just replacing VARCHAR with CLOB. This link helped me out.

    0 讨论(0)
  • 2020-11-30 03:38

    I encountered this error message when trying to insert String into an XMLTYPE column.

    Specifically using Java's PreparedStatement like this:

    ps.setString('XML', document);
    

    where XML here is defined as XMLTYPE.

    0 讨论(0)
提交回复
热议问题