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

前端 未结 15 1759
野的像风
野的像风 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:

    
        
            SELECT SEQ.nextVal FROM DUAL
        
        insert into MYTABLE(
            ID,
            ...,
            PDF
        ) values (
            #{id, jdbcType=VARCHAR},
            ...,
            #{tcPdf, jdbcType=BLOB},
        )
    
    

    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.

提交回复
热议问题