2. 컴퓨터 이야기/데이타베이스

여러줄 나오는 쿼리를 한줄로 줄일때 Clob 이 대상이라면 다른 방법을 찾아 봐야..

래빗 크리스 2009. 5. 12. 22:25

select title, content, isrtid
  from tableA
;

상기 결과가 다음과 같을때.. 이걸 한 줄로 고쳐보고 있을 거다.
titleA contentA isrtIdA
titleB contentB isrtIdA
titleC contentC isrtIdA
titleD contentD isrtIdA
..

그러면 당연히 isrtid 로 group by 를 하고, max 와 decode 를 사용할 것인데.. 그렇다면 쿼리가 다음과 같이 된다.
select isrtid,
         max(decode(title, 'titleA', content)) content1,
         max(decode(title, 'titleB', content)) content2,
         max(decode(title, 'titleC', content)) content3,
         max(decode(title, 'titleD', content)) content4
  from (select title, content, isrtid from tableA)
group by isrtid
;

대부분은 작업이 잘 될 것인데..
만약 content 칼럼이 Clob 이면 어떻게 될까..?
다른 DB 에서는 모르겠는데, Oracle 에서의 답변은 다음과 같다.
ORA-00932: 데이터 유형이 일치하지 않습니다.

이럴때는 해결책이 어떻게 되는 것인지..?