setting parameters [message #718594] |
Wed, 24 August 2011 15:31  |
Eclipse User |
|
|
|
I have a Dataset that I have created in Java and it contains a BeforeOpen event handler. I dynamically create the prepared statement query and it is dependent on the three Report parameters values to what the prepared statement query will look like with in the BeforeOpen event handler. I could have 0 - 3 parameters that need to be populated on my dataset when the prepared statement is created. Is there any way to populate my dataset parameters in the BeforeOpen method on my dataset? Thanks for your suggestions and time.
Thanks,
Marc
|
|
|
|
|
|
|
|
|
Re: setting parameters [message #718930 is a reply to message #718919] |
Thu, 25 August 2011 11:58   |
Eclipse User |
|
|
|
Jason,
This is an example of how I build my prepared statement. There are 4 report parameters "name", "number", "type" and "company" this information is what builds the following prepared statement:
sql = sql
+ "select A.KYVENID, "
+ "A.VENNAME, "
+ "A.VENSTATUS, "
+ "A.VENPHONE, "
+ "A.XADATASTATUS, "
+ "A.XAAUDITUID, "
+ "A.XAAUDITTS, "
+ "A.COMPANY, "
+ "A.VENNUM, "
+ "A.VENABOUT, "
+ "A.VENCONTACT, "
+ "A.VENEMAIL, "
+ "A.VENSTREET, "
+ "A.VENCITY, "
+ "A.VENZIP, "
+ "A.REMARKS, "
+ "from DATA.VENDORINFO A, " + "DATA.MASTERLIST B ";
sql = sql + "where ";
if (vname != null) {
if (vname.length() != 0) {
searchPercent = vname.indexOf("%");
searchUnderscore = vname.indexOf("_");
textAdded = true;
if (searchPercent == -1 && searchUnderscore == -1) {
sql = sql + "A.VENNAME = ?";
} else {
sql = sql + "A.VENNAME like ?";
}
}
}
if (textAdded) {
sql = sql + " and ";
}
textAdded = false;
if (vnumber != null) {
if (vnumber.length() != 0) {
searchPercent = vnumber.indexOf("%");
searchUnderscore = vnumber.indexOf("_");
textAdded = true;
if (searchPercent == -1 && searchUnderscore == -1) {
sql = sql + "A.VENNUM = ?";
} else {
sql = sql + "A.VENNUM like ?";
}
}
}
if (textAdded) {
sql = sql + " and ";
}
textAdded = false;
if (vtype != null) {
if (vtype.length() != 0) {
searchPercent = vtype.indexOf("%");
searchUnderscore = vtype.indexOf("_");
textAdded = true;
if (searchPercent == -1 && searchUnderscore == -1) {
sql = sql + "B.MLDESCRIPTION = ?";
} else {
sql = sql + "B.MLDESCRIPTION like ?";
}
}
}
if (textAdded) {
sql = sql + " and ";
}
sql = sql + "A.COMPANY = ?"
+ " and B.KYMASTERLISTID = CAST(A.VENTYPE as INTEGER)";
dataset.setQueryText(sql);
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04780 seconds