for (int sel = 0; sel < x; sel++)
{
tempItem = (JCheckListItem) listDictionary.getModel().getElementAt(sel);
if (tempItem.isSelected())
{
JDBQMDictionary dictItem = (JDBQMDictionary) tempItem.getValue();
String testID = dictItem.getTestID();
String description = dictItem.getDescription();
String tempField = ",MAX(CASE TEST_ID WHEN '" + testID + "' THEN RESULT ELSE NULL END) AS '" + description + "'";
if (fieldsSQL.equals(""))
{
fieldsSQL = tempField;
} else
{
fieldsSQL = fieldsSQL + tempField;
}
}
}
}
String joinSQL = "FROM VIEW_QM_RESULTS WHERE 1 = 1";
String whereSQL = "";
if (textFieldProcessOrder.getText().equals("") == false)
{
whereSQL = whereSQL + " AND PROCESS_ORDER = '" + textFieldProcessOrder.getText() + "'";
}
if (textFieldMaterial.getText().equals("") == false)
{
whereSQL = whereSQL + " AND MATERIAL = '" + textFieldMaterial.getText() + "'";
}
if (textFieldInspectionID.getText().equals("") == false)
{
whereSQL = whereSQL + " AND INSPECTION_ID = '" + textFieldInspectionID.getText() + "'";
}
if (textFieldUserData1.getText().equals("") == false)
{
whereSQL = whereSQL + " AND USER_DATA_1 = '" + textFieldUserData1.getText() + "'";
}
if (textFieldUserData2.getText().equals("") == false)
{
whereSQL = whereSQL + " AND USER_DATA_2 = '" + textFieldUserData2.getText() + "'";
}
int dateParams = 0;
if (checkBoxSampleFrom.isSelected())
{
dateParams++;
}
if (checkBoxSampleTo.isSelected())
{
dateParams++;
}
if (dateParams > 0)
{
if (dateParams == 1)
{
if (checkBoxSampleFrom.isSelected())
{
whereSQL = whereSQL + " AND SAMPLE_DATE >= ? ";
}
if (checkBoxSampleTo.isSelected())
{
whereSQL = whereSQL + " AND SAMPLE_DATE <= ? ";
}
} else
{
if (dateParams == 2)
{
whereSQL = whereSQL + " AND SAMPLE_DATE >= ? AND SAMPLE_DATE <= ? ";
}
}
}
String groupSQL = "GROUP BY SAMPLE_ID,SAMPLE_DATE,Inspection_ID,Activity_ID,MATERIAL,PROCESS_ORDER,USER_DATA_1,USER_DATA_2";
String sqlHaving = "";
if (x > 0)
{
int count = 0;
String limit = Common.hostList.getHost(Common.selectedHostID).getDatabaseParameters().getjdbcDatabaseSelectLimit();
String fieldDelim1 = "";
String fieldDelim2 = "";
if (limit.equals("top"))
{
fieldDelim1 = "'";
fieldDelim2 = "'";
}
if (limit.equals("rownum"))
{
fieldDelim1 = "\"";
fieldDelim2 = "\"";
}
if (limit.equals("limit"))
{
fieldDelim1 = "`";
fieldDelim2 = "`";
}
JCheckListItem tempItem;
for (int sel = 0; sel < x; sel++)
{
tempItem = (JCheckListItem) listDictionary.getModel().getElementAt(sel);
if (tempItem.isSelected())
{
JDBQMDictionary dictItem = (JDBQMDictionary) tempItem.getValue();
String description = dictItem.getDescription();
if (count == 0)
{
sqlHaving = " HAVING ("+fieldDelim1+description+fieldDelim2+" IS NOT NULL) ";
}