我写了查询语句追加到原来的SQL中
可是查询结果不显示
我第一次运行结果出来了
可后来就怎么也出不来了
程序如下
帮忙看看那
<%@ page contentType="text/html; charset=gb2312" language="java" import="java.sql.*" import="javax.swing.JOptionPane" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>数据处理</title>
</head>
<body>
<%
 String section=request.getParameter("section_no");
String pinpai=request.getParameter("pinpai");
int  section_no= -100;
boolean flag = false;
if(section!=null && !section.equals(""))
  {section_no = Integer.parseInt(section);
   flag = true;
  }  
String bianm[]=new String[2000];
String mingc[]=new String[2000];
float weis[]=new float[2000];
float shuie[]=new float[2000];
float hans[]=new float[2000];
float cux[]=new float[2000];
 Connection conn=null;
 Statement Stmt=null;
 ResultSet rs=null;
Class.forName("oracle.jdbc.driver.OracleDriver");
String url="jdbc:oracle:thin:@194.1.1.236:1521:css";
String user="stdba";
String password="glq73hzz";
conn=DriverManager.getConnection(url,user,password);
Stmt=conn.createStatement();
String strquery="select e.brand_no as group_no,e.name as name,sum(round(b.sales_amnt_td_p,2)-round(b.sales_amnt_td_c,2))  as sales_amnt_td_p,sum(round(b.sales_amnt_td_c,2))  as sales_amnt_td_c, round(sum(b.prof_amnt_td),2) as prof_amnt_td,sum(round(b.sales_amnt_td,2)) as sales_amnt_td from items a,items_sales b,items_recpt c,vat d,brand e,vat f where a.item_no=b.item_no(+) and a.item_no=c.item_no(+) and a.sell_vat=d.vat_no and a.buy_vat=f.vat_no and a.brand=e.brand_no(+) and a.status>0 and (b.sales_amnt_td<>0 or a.stock_adj<>0 or c.recpt_td<>0 or a.start_stock<>0)";
if(flag)
{strquery = strquery.concat("and a.section_no='"+section+"'");
 if(pinpai!=null)
  strquery = strquery.concat("and e.brand_no='"+pinpai+"'");
}
else
if(pinpai!=null){
strquery =  strquery.concat("and  e.brand_no='"+pinpai+"'");}
else  {strquery = strquery.concat("and a.section_no='"+section+"'");}
strquery =  strquery.concat(" group by e.brand_no,e.name");
try{
rs=Stmt.executeQuery(strquery);
}
catch(Exception e)
{
 System.out.print(e+"数据库连接失败!");

int i=0;
%>
<table width="100%"  border="1" cellpadding="0" cellspacing="0">
  <tr align="center">
    <td width="2%" rowspan="3">&nbsp;</td>
    <td colspan="2" rowspan="2">品牌</td>
    <td height="15" colspan="4">销售金额</td>
  </tr>
  <tr>
    <td height="15" colspan="3" align="center">正常</td>
    <td width="15%" rowspan="2" align="center">促销</td>
  </tr>
  <tr>
    <td width="19%" align="center">编码</td>
    <td width="19%" align="center">名称</td>
    <td width="15%" align="center">weis</td>
    <td width="15%" align="center">税额</td>
    <td width="15%" align="center">含税</td>
  </tr>
 <%! 
     float sum3;
 float sum4;
 float sum5;
 float sum6;
 
 %>
  <% if(rs!=null)
     if(rs.next())
      { do
         { 
          bianm[i]=rs.getString(1);
          mingc[i]=rs.getString(2);
          weis[i]=rs.getFloat(3);
          shuie[i]=rs.getFloat(4);
          hans[i]=rs.getFloat(5);
          cux[i]=rs.getFloat(6);
  sum3=sum3+weis[i];
  sum4=sum4+shuie[i];
  sum5=sum5+hans[i];
  sum6=sum6+cux[i];
   %>
  <tr>
    <td>&nbsp;</td>
    <td><%=bianm[i]%></td>
    <td><%=mingc[i]%></td>
    <td><%=weis[i]%></td>
    <td><%=shuie[i]%></td>
    <td><%=hans[i]%></td>
    <td><%=cux[i]%></td>
  </tr>
   
<%
     i++;
  }while(rs.next());
 }%>
 <tr bgcolor="#FFFF00">
    <td height="15">&nbsp;</td>
    <td>合计:</td>
    <td>&nbsp;</td>
    <td><%=sum3%></td>
    <td><%=sum4%>;</td>
    <td><%=sum5%></td>
    <td><%=sum6%></td>
  </tr>
</table>
</body>
</html>
<%  Stmt.close();
  conn.close();
  %>

解决方案 »

  1.   

    java.sql.SQLException: ORA-01722: invalid number
      

  2.   

    if(flag) 
    {strquery = strquery.concat("and a.section_no="+section+""); 
    if(pinpai!=null) 
    strquery = strquery.concat("and e.brand_no="+pinpai+""); 

    是不是把它当成字符串了?
      

  3.   

    太长了没看完strquery =  strquery.concat(" group by e.brand_no,e.name"); 
    System.out.println(strquery);//打出来看就知道了噻,SQL语句看得懂噻
    rs=Stmt.executeQuery(strquery); 
    初步估计是把数值类型的字段弄成字符串了
      

  4.   

    invalid number:
    在sql语句中,字符数字类型转换错误,无法将字符串转化成有效数字.
      

  5.   

    这个...你是传值有问题吧
    在数值类型 的字段上不要用''
    if(flag) 
    {strquery = strquery.concat("and a.section_no="+section+""); 
    if(pinpai!=null) 
    strquery = strquery.concat("and e.brand_no="+pinpai+""); 

    else 
    if(pinpai!=null){ 
    strquery =  strquery.concat("and  e.brand_no="+pinpai+"");} 
    else  {strquery = strquery.concat("and a.section_no="+section+"");}