A
select no, b_ref, b_level, b_step from board order by b_ref desc, b_step;
B
형식 : select rownum num, no, b_ref, b_level, b_step from (A);
질의 : select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step);
C
시작위치
형식 : select num from (B) where num = 5;
질의 : select num from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num = 5;
D
마지막위치
행번호가 C보다 크고 b_level 1인것
형식 : select min(num) from (B) where num > (C) and b_level = 1;
질의 : select min(num) from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num > (select num from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num = 5) and b_level <= 1;
E
본질의
형식 : select no from (B) where num between (C)+1 and (D)-1;
질의 : select no from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num between (select num from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num = 5)+1 and (select min(num) from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num > (select num from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num = 5) and b_level <= 1)-1;
** 진짜 질의
형식 : update board set del_p=1 where no in(E);
질의 : update board set del_p=1 where no in(select no from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num between (select num from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num = 5)+1 and (select min(num) from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num > (select num from (select rownum num, no, b_ref, b_level, b_step from (select no, b_ref, b_level, b_step from board order by b_ref desc, b_step)) where num = 5) and b_level <= 1)-1);
** 이제 이 질의문을 프로그램에 적용시키기
1. BoardDao 에 deleteBoard 에다가 질의문 써주고 변수처리 해준다 굵은글씨 3부분을..
2. 삭제하기전에 원래글의 정보를 저장해둔다. BoardVo 를 생성해서..
3. viewPage 의 listBoard.jsp 에가서
<a href="detailBoard.do?no=${b.no }">${b.title } </a> 여기 밑에 추가해줌
이렇게
<c:if test="${b.del_p ==1 }">
<font color="hotPink" ><small>부모글이 삭제됨</small></font>
</c:if>
'JAVA > Oracle' 카테고리의 다른 글
오라클 - 테이블 생성시에 제약사항 (0) | 2016.06.18 |
---|---|
오라클 - like 연산자의 변수 처리 및 예제 (0) | 2016.06.18 |
오라클 - 질의문을 이용한 책 추천 시스템 풀이 (0) | 2016.06.18 |
오라클 - 질의문 예제와 풀이 (0) | 2016.06.18 |
오라클 - 자료의 수정과 자료의 삭제 update, delete 명령어 (0) | 2016.06.18 |