When inserting or updating the CLOB field on the Oracle database, the INSERT into and UPDATE statements are directly spliced, and a
ora-01704: String file too long
The exception. That's because Oracle's implicit conversion mechanism is that Oracle converts strings to VARCHAR2 types by default, and this string has a length greater than 4000, so a ora-01704 error is reported. To put it more generally, the characters between the two single quotes cannot be more than 4000, but I have to use single quotes to draw them because of business requirements. So I searched a lot of methods from the Internet, which was solved by the for Update method. But MyBatis does not know how to get resultset, so this method can only be dropped. Later saw the use of pl/sql on the Internet, I would like to try the direct use in the MyBatis can run, the results of a test found incredibly can. ...... Moved...... Tears running. The implementation methods are as follows:
Update the large segment individually
private void Updateclobfields (String tablename,string dataid,list<map> FieldList, Ravforminstancemapper mapper) {for
(Map field:fieldlist) {
stringbuffer sb=new stringbuffer ();
SB. Append ("DECLARE")
. Append (" clobvalue clob;")
. Append ("BEGIN")
. Append (" clobvalue: = '" +field.get ("value") + "';")
. Append (" UPDATE" +tablename+ "t SET T." +field.get ("column") + "= Clobvalue WHERE t.id= '" +dataid+ "';")
. Append (" COMMIT;")
. Append ("END;");
Mapper.updateinst (Sb.tostring ());
}
The Mapper.updateinst code is:
@Update ("${sql}") Public
void Updateinst (@Param (value = "SQL") String SQL);