有人能帮我解决这个 SQL 问题吗?实际上我知道只会返回一条记录,但是现在代码还是会跳转到异常处理部分。
好的...我修改了代码后还是得到同样的结果。依旧会跳转到异常处理部分。
<%
String sqlpminfo = "select ea.PreferredName, ea.LastName, ea.AreaCityCode, ea.PhoneNo, eemail.EmployeeEmailAddress from Program p join ProgramXXXEmployeeRole pxxx on pxxx.ProgramID = p.ProgramID and pxxx.RoleCode=799 join EmployeeAdmin ea on ea.XXXEmployeeCode = pxxx.XXXEmployeeCode join EmployeeEmail eemail on eemail.XXXEmployeeCode = pxxx.XXXEmployeeCode where p.ProgramID=" + formFields.getValue("programID");
try {
log.info(sqlpminfo);
log.info("programID: " + formFields.getValue("programID"));
QueryWrap pmwrap = new QueryWrap();
ResultSet pmrt = pmwrap.executeQueryWithException(sqlpminfo);
if (pmrt == null || pmrt.equals(""))
{ pmrt.close();
}
else
{
int i = 0;
while ( pmrt.next() )
{
String pmFname = pmrt.getString(1);
String pmLname = pmrt.getString(2);
String pmAreacode = pmrt.getString(3);
String pmPhone = pmrt.getString(4);
String pmemail = pmrt.getString(5);
log.info ("PM Contact: " + pmrt.getString(1) + " " + pmrt.getString(2) );
%>
Name: <%=pmFname%> <%=pmLname%> <br/>
Email: <a href="mailto:<%=pmemail%>"><%=pmemail%></a><br/>
Phone: (<%=pmAreacode%>)
<%if (pmPhone.length() == 7) {%><%=pmPhone.substring(0, 3)%>-<%=pmPhone.substring(3, 7)%> <%} else {%><%=pmPhone%><%} %>
<br/><br/>
<%
i++;
} //end of while
pmrt.close();
if(i == 0)
{
%>
Contact Information is not available. Please email <br/>
<%
}
} //end if if
} catch (Exception ee) {
%>
log.error("caught exception in PMcontactinfo: " + e);
<% }%>