hi all
i have a problem with my code.following is my code:
[Codes]
Connection con = null;
PreparedStateme nt stmt = null;
ResultSet rs = null;
Map resultMap = null;
List result = null;
String sql="";
try{
con = Utilities.getDb Connection();
sql="select * from tran_event where tran_event_cd is not null";
if (chk1.equals("Y ") && !eventCd.equals ("null")){
sql=sql + " AND event_cd='"+eve ntCd+"'";
System.out.prin tln("anything.. .eventcode..... ....."+sql);
}
/* else
{
sql=sql;
}*/
if
(chk2.equals("Y ") && !partyCd.equals ("null")){
sql=sql + " AND party_cd='"+par tyCd+"'";
System.out.prin tln("anything.. .partyCode..... ....."+sql);
}
/*else
{
sql=sql;
}*/
if
(chk3.equals("Y ") && projectCd!="nul l"){
sql=sql + " AND project_cd='"+p rojectCd+"'";
System.out.prin tln("anything.. .projectcode... ......."+sql);
}
/* else
{
sql=sql;
}*/
if
(chk4.equals("Y ") && fromDt!="null" && toDt!="null"){
sql=sql + " AND event_dt between '"+fromDt+"' and '"+toDt+"'";
}
/* else
{
sql=sql;
}*/
stmt = con.prepareStat ement(sql);
System.out.prin tln("check"+ stmt);
rs = stmt.executeQue ry();
[/Codes]
my problem is that i need my sql statement to enter in each of the specified if condition. if the condition doesn't meet the requirement then the sql statement should be added to the next condition that meets the requirement.
but my code only meets to that condition where the sql statement is placed just with that condition.
so please help me
thanks in advance
i have a problem with my code.following is my code:
[Codes]
Connection con = null;
PreparedStateme nt stmt = null;
ResultSet rs = null;
Map resultMap = null;
List result = null;
String sql="";
try{
con = Utilities.getDb Connection();
sql="select * from tran_event where tran_event_cd is not null";
if (chk1.equals("Y ") && !eventCd.equals ("null")){
sql=sql + " AND event_cd='"+eve ntCd+"'";
System.out.prin tln("anything.. .eventcode..... ....."+sql);
}
/* else
{
sql=sql;
}*/
if
(chk2.equals("Y ") && !partyCd.equals ("null")){
sql=sql + " AND party_cd='"+par tyCd+"'";
System.out.prin tln("anything.. .partyCode..... ....."+sql);
}
/*else
{
sql=sql;
}*/
if
(chk3.equals("Y ") && projectCd!="nul l"){
sql=sql + " AND project_cd='"+p rojectCd+"'";
System.out.prin tln("anything.. .projectcode... ......."+sql);
}
/* else
{
sql=sql;
}*/
if
(chk4.equals("Y ") && fromDt!="null" && toDt!="null"){
sql=sql + " AND event_dt between '"+fromDt+"' and '"+toDt+"'";
}
/* else
{
sql=sql;
}*/
stmt = con.prepareStat ement(sql);
System.out.prin tln("check"+ stmt);
rs = stmt.executeQue ry();
[/Codes]
my problem is that i need my sql statement to enter in each of the specified if condition. if the condition doesn't meet the requirement then the sql statement should be added to the next condition that meets the requirement.
but my code only meets to that condition where the sql statement is placed just with that condition.
so please help me
thanks in advance
Comment