|
Re: Record In Jsp & back end differ for same query
|
Posted: Nov 6, 2003 5:58 AM
|
|
<pre>Here is the code that is created upon the option i give to get the current page & i have made sure that the query that is printed is just the query which is executed at the back end by putting out.println(querey): just before it is executed The query I get is :-- </pre>
<pre><I>select swon_category, sum(nvl(amount_inr,0)) amount_inr from ((select * from tcs_mis_operational_cost_sec_v where swon_category in ('Branch','Branch - Support','Corporate','Corporate Function','Delivery Centre' ,'Leave','Offshore Delivery Centre','Training','Training - CEP','Training - ITP','Training - MDP','Unallocated') and (dc_emp_no = '42021' or ip_emp_no = '42021' or sp_emp_no = '42021' or sect_emp_no = '42021' or lc_emp_no = '42021' or sub_ip_emp_no = '42021' or sub_sp_emp_no = '42021' ) ) union (select a.* from tcs_mis_operational_cost_sec_v a where swon_category in ('Branch','Branch - Support','Corporate','Corporate Function','Delivery Centre' ,'Leave','Offshore Delivery Centre','Training','Training - CEP','Training - ITP','Training - MDP','Unallocated') and exists (select 1 from tcs_mis_project_key_members_t b where (b.owner_emp_number='42021' or b.gl_emp_number='42021' or b.am_emp_number='42021' or b.rm_emp_number='42021' or b.brm_emp_number='42021' or b.deputy_owner_emp_number='42021' or b.supervisor_emp_number='42021' or b.bdm_emp_number='42021' or b.key_member_emp_number='42021' ) and a.project_number = b.project_number ) )) where 1=1 and UPPER(swon_category) like UPPER('%') and exp_date between to_date('03/01/2003','mm/dd/yyyy') and to_date('03/31/2003','mm/dd/yyyy') group by swon_category order by swon_category </i></pre>
<b>the code is :-</b> <java> try{ out.println("The Query==>"+selectQuery +"<br>"); //<I><B>THIS IS THE QUERY THAT IS GIVEN ABOVE </B></I> fetchRS = sttt.executeQuery(selectQuery.toString()); int k =0 ; while(fetchRS.next()) { out.println(k); k++; if(subTotalReq && !firstLoop && !tempValue.equals(fetchRS.getString(1))){ tempParam = " and " + Columns.get(0).toString() + "$'" + tempValue+"'"; tempHeader = Headings.get(0).toString() + ":" + tempValue; out.println("<tr>"); out.println("<td class=\"TrtblS_la\" style=\"background-color:silver\" colspan=\"2\"><b>SUB Total For "+tempValue+"</b></td>"); out.println("<td class=\"TrtblC_ra\" style=\"background-color:silver\" colspan=\""+(columnsCount-2)+"\"><a class=\"DLnk\" href=\""+calledPage+"?parameters="+tempParam.replace('&','^').replace('+',' |').replace('%','~')+"&headers="+tempHeader.replace('&','^').replace('+' ,'|')+"&condition="+condition.toString().replace('%','~').replace('&','^ ').replace('+','|')+"&searchBy="+searchBy+"&exp_from_date="+exp_from_dat e+"&exp_to_date="+exp_to_date+"&from_month="+from_month+"&to_month=" +to_month+"\"><strong>"+formatter.format(subTotal)+"</strong>< /a></td>"); out.println("</tr>"); subTotal = 0; } parameters = new StringBuffer(); headers = new StringBuffer(); out.println("<tr>"); for(int j =0; j< columnsCount; j++) { if( j == columnsCount-1){ out.println("<td class=\"TrtblC_ra\" colspan=\"1\"><a class=\"DLnk\" href=\""+calledPage+"?parameters="+(parameters.toString()).replace('&','^') .replace('+','|').replace('%','~').replace('"','*')+"&headers="+headers.toSt ring().replace('&','^').replace('+','|')+"&condition="+condition.toStrin g().replace('%','~').replace('&','^').replace('+','|')+"&searchBy="+sear chBy+"&exp_from_date="+exp_from_date+"&exp_to_date="+exp_to_date+"&f rom_month="+from_month+"&to_month="+to_month+"\">"+formatter.format(fetch RS.getDouble(j+1))+"</a></td>"); totalINR = totalINR + fetchRS.getDouble(j+1); subTotal = subTotal + fetchRS.getDouble(j+1); }else{ out.println("<td class=\"TrtblS_la\" colspan=\"1\">"+fetchRS.getString(j+1)+"</td>"); if((Columns.get(j).toString()).equals("PROJ_DESCRIPTION")){ parameters.append(" and "+Columns.get(j)+" like'"+fetchRS.getString(j+1).replace('"','*')+"%'"); }else{ if((Columns.get(j).toString()).equalsIgnoreCase("CUSTOMER_NAME")){ parameters.append(" and customer_id $'"+fetchRS.getString("customer_id")+"'"); }else{ parameters.append(" and "+Columns.get(j)+"$'"+fetchRS.getString(j+1)+"'"); } }//end if headers.append(" "+Headings.get(j)+"$"+fetchRS.getString(j+1)+(j%2==0?"<BR>":" ")); }//End of IF }// End of For out.println("</tr>"); recCount++; tempValue = fetchRS.getString(1); firstLoop = false; }//END OF WHILE }catch(Exception exp){ </java>
|
|