MinBangHome

CLOB 컬럼 사이즈 이슈 본문

Develop/DB

CLOB 컬럼 사이즈 이슈

Byungwook Min 2020. 3. 5. 09:43

CLOB 컬럼 내에 데이터 업데이트 시

 

ORA-01704: 문자열이 너무 깁니다

01704. 00000 -  "string literal too long"

*Cause:    The string literal is longer than 4000 characters.

*Action:   Use a string literal of at most 4000 characters.

           Longer values may only be entered using bind variables.

 

이슈 발생.

 

 - 해결 방법

* update set clob_col = TO_CLOB(dbms_lob.substr(내용,4000,1)) || TO_CLOB( dbms_lob.substr(내용,4000,1))

 

DBMS_LOB을 쓴 이유는 기존 clob 컬럼을 불러오는 일도 있을 경우

직접 입력이라면 같은 내용을 붙여넣거나 변수처리한뒤 뒤쪽은 4000, 4001로 4001번째 부터 4000개 를 잘라내는 방법

 

update 테이블

Set clob컬럼 = TO_CLOB(4000자글자까지) ||TO_CLOB( 4000자넘어가는글자까지 이어붙이기)

;

 

두번하는 방법도 있습니다.

update 테이블 

Set clob  =  4000글자까지 

;

 

 

update 테이블 

Set clob  =  clob컬럼 || 4000글자넘어가는글자

;

 

 

UPDATE TESTCLOB SET C_COL = TO_CLOB('A') || TO_CLOB('B3') ;

 

그냥 UPDATE하면

SQL 오류: ORA-01704: 문자열이 너무 깁니다

01704. 00000 -  "string literal too long"

*Cause:    The string literal is longer than 4000 characters.

*Action:   Use a string literal of at most 4000 characters.

           Longer values may only be entered using bind variables.

 

,

 

TO_CLOB없이 그냥 || 로 묶어주면

 

 

SQL 오류: ORA-01489: 문자열 연결의 결과가 너무 깁니다

01489. 00000 -  "result of string concatenation is too long"

*Cause:    String concatenation result is more than the maximum size.

*Action:   Make sure that the result is less than the maximum size.

 

 

 

TO_CLOB 로 || 할경우

 

1 행 이(가) 업데이트되었습니다.

 

 

- 출처

OKKY : https://okky.kr/article/399912

Comments