简体   繁体   中英

How to store string length greater than 4000 char at a time in oracle clob datatype column?

I am using JPA and trying to store value greater than 4000 chars inside oracle database column with data type clob. But it is not able store that saying you can store 4000 character at a time. In clob data type column there is limit is of 4GB but we can insert only 4000 chars at a time. I have seen some solutions that we can use to_char() function but do not find any solution how to use it with JPA?

How to store such value when i am working with JPA ?

Try to use @Lob annotation in column description. For example:

@Entity
@Table(name="TBL")
public class Tbl {
@Id
@Column(name = "TBL_ID")
private long id;    
@Lob
private byte[] addinfo;

Also, check if there can be length restriction on this field

To insert a CLOB you cannot rely on simply string concatenation. You'll need to assign the CLOB to a PL/SQL variable first, and then insert the variable.

DECLARE
l_clob;
BEGIN
l_clob := @my_clob_string;
INSERT INTO (my_clob_column) VALUES (l_clob);
END;
/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM