::::::::::::: 에러 메세지 :::::::::::::::::::
[Microsoft][ODBC SQL Server Driver][SQL Server]TOP을 함께 지정하지 않는 한 뷰, 인라인 함수, 파생 테이블, 하위 쿼리에서 ORDER BY 절을 사용할 수 없습니다.
:::::::::::::: 소스 :::::::::::::::::::::::::::::
<%
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0);
response.setHeader("cache-control","no-cache"); //HTTP 1.1
Connection pconn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
int total=0, start=0, end=0;
int pageSize=10;
int pageTotal=0;
int cpage = 0;
String keyfield = Kr.nchk(request.getParameter("keyfield"));
String keyword = Kr.a2k(request.getParameter("keyword"));
String query0 = "";
String search = "";
String bbs = request.getParameter("bbs");
String pg = request.getParameter("pg");
bbs = (bbs==null||bbs.equals("null"))?"bbs1":bbs;
pg = (pg==null||pg.equals("null"))?"0":pg;
cpage = Integer.parseInt(pg);
String querytotal = "select count(*) from "+tableName+" where bbsid=?";
if (!keyword.equals("")) {
search = "&keyfield="+keyfield+"&keyword="+java.net.URLEncoder.encode(keyword);
query0 = " and "+keyfield+" like '%"+keyword+"%' ";
querytotal = querytotal + query0;
}
String query = "select seq,ref,lev,step,wdate,filename,email,maskname,download,filesize,subject,writer,readnum from "+tableName+" where bbsid=? "+query0+" order by ref desc, step";
if (keyfield.equals("content")) {
query = "select a.seq,a.ref,lev,a.step,wdate,filename,email,maskname,download,filesize,subject,writer,readnum from "+tableName+" a, (select seq from "+contentTableName+" where content like '%"+keyword+"%' group by seq) b where a.seq = b.seq and bbsid=? order by a.ref desc, a.step";
querytotal = "select count(*) from (select seq from "+contentTableName+" where bbsid = ? and content like '%"+keyword+"%')";
}
query = "select * from (select * from ("+query+") where rownum <= ? order by rownum desc ) where rownum <= ? order by ref desc, step";
%>
<%@ include file="db.jsp"%>
<%
try {
pstmt = pconn.prepareStatement(querytotal);
pstmt.setString(1,bbs);
rs = pstmt.executeQuery();
if(rs.next())
total = rs.getInt(1);
rs.close();
pstmt.close();
pageTotal = (total-1)/pageSize;
if (cpage<0) cpage=0;
if (cpage>pageTotal) cpage=pageTotal;
start = (cpage+1) * pageSize;
end = pageSize+(total-start)*((total<start)?1:0);
%>
|