728x90
반응형
XML파일 에서는 <부등호를 TAG로 인식하기 때문에
"The content of elements must consist of well-formed character data or markup." 라는 에러가 나옴
이러한 문제를 해결하기 위해서는 Query안에 사용되고 있는 부등호가 문자열이라는 것을 의미하게
<![CDATA[내용]]> 으로 감싸준다.
변경 전 코드 :
select li.lec_id
,li.lec_name
,tm.test_name
,case when start_date < now() and end_date > now() then '강의중'
when start_date > now() then '강의 시작전'
when end_date < now() then '강의 종료'
else '기타'
end letstatus
,li.pre_pnum
,ifnull(tl.cnt,0) as cnt
,(li.pre_pnum - ifnull(tl.cnt,0)) as notest
,ifnull(li.lec_type_id,0) as lec_type_id
,ifnull(li.test_id,0) as test_id
from tb_lec_info li
inner join tb_testmaster tm on li.test_id = tm.test_id
left outer join (
select lec_id
,count(*) as cnt
from tb_test_user
group by lec_id
) tl on tl.lec_id = li.lec_id
변경 후 코드 :
SELECT
li.lec_id
,li.lec_name
,tm.test_name
,CASE
WHEN <![CDATA[start_date < now() and end_date > now() then '강의중'
WHEN start_date > now() then '강의 시작전'
WHEN end_date < now() then '강의 종료']]>
ELSE '기타'
end letstatus
,li.pre_pnum
,ifnull(tl.cnt,0) as cnt
,(li.pre_pnum - ifnull(tl.cnt,0)) as notest
,ifnull(li.lec_type_id,0) as lec_type_id
,ifnull(li.test_id,0) as test_id
FROM tb_lec_info li
INNER JOIN tb_testmaster tm on li.test_id = tm.test_id
LEFT OUTER JOIN (
SELECT lec_id
,count(*) as cnt
FROM tb_test_user
GROUP BY lec_id
) tl on tl.lec_id = li.lec_id
///// case when 부분에 보면 부등호로 인해 계속 에러메시지가 떠서
[CDATA]로 넣으니 에러가 사라졌다
728x90
반응형