PC: Dynamic Where Clause
/*********************************************************************************
Descr: The Below code is used to populate the grid.
Developer: Krishnam Raju Nadimpalli
*********************************************************************************/
Component Rowset &Level0, &Act_Log;
Component Row &Level0_Row;
&Level0 = GetLevel0();
&Level0_Row = &Level0(1);
&Act_Log = &Level0_Row.GetRowset(Scroll.LAC_WS_ACT_LOG);
&Act_Log.Flush();
&str_WhereClause = "";
&str_NoAddnlClause = "N";
/* Clause for emplid*/
If All(LAC_WS_DERIVED.EMPLID.Value) Then
&str_WhereClause = " EMPLID = " | Quote(LAC_WS_DERIVED.EMPLID.Value);
&str_NoAddnlClause = "Y";
End-If;
/* Clause for Status */
If All(LAC_WS_DERIVED.LAC_WS_STATUS.Value) Then
If &str_NoAddnlClause = "Y" Then
&str_WhereClause = &str_WhereClause | " AND LAC_WS_STATUS = " | Quote(LAC_WS_DERIVED.LAC_WS_STATUS.Value);
Else
&str_WhereClause = " LAC_WS_STATUS = " | Quote(LAC_WS_DERIVED.LAC_WS_STATUS.Value);
&str_NoAddnlClause = "Y";
End-If;
End-If;
/* Clause for SSN */
If All(LAC_WS_DERIVED.SSN.Value) Then
If &str_NoAddnlClause = "Y" Then
&str_WhereClause = &str_WhereClause | " AND LAC_WS_SSN = '" | LAC_WS_DERIVED.SSN.Value | "' ";
Else
&str_WhereClause = " LAC_WS_SSN = '" | LAC_WS_DERIVED.SSN.Value | "' ";
&str_NoAddnlClause = "Y";
End-If;
End-If;
/* Clause for PROG_CODE */
If All(LAC_WS_DERIVED.LAC_WS_PROG_CODE.Value) Then
If &str_NoAddnlClause = "Y" Then
&str_WhereClause = &str_WhereClause | " AND LAC_WS_PROG_CODE = '" | LAC_WS_DERIVED.LAC_WS_PROG_CODE.Value | "' ";
Else
&str_WhereClause = " LAC_WS_PROG_CODE = '" | LAC_WS_DERIVED.LAC_WS_PROG_CODE.Value | "' ";
&str_NoAddnlClause = "Y";
End-If;
End-If;
/* Clause for ProcessInstance */
If All(LAC_WS_DERIVED.PROCESS_INSTANCE.Value) Then
If &str_NoAddnlClause = "Y" Then
&str_WhereClause = &str_WhereClause | " AND PROCESS_INSTANCE = '" | LAC_WS_DERIVED.PROCESS_INSTANCE.Value | "' ";
Else
&str_WhereClause = " PROCESS_INSTANCE = '" | LAC_WS_DERIVED.PROCESS_INSTANCE.Value | "' ";
&str_NoAddnlClause = "Y";
End-If;
End-If;
/* Clause for ProcessDate */
If All(LAC_WS_DERIVED.PROCESS_DATE.Value) Then
If &str_NoAddnlClause = "Y" Then
&str_WhereClause = &str_WhereClause | " AND PROCESS_DATE = '" | LAC_WS_DERIVED.PROCESS_DATE.Value | "' ";
Else
&str_WhereClause = " PROCESS_DATE = '" | LAC_WS_DERIVED.PROCESS_DATE.Value | "' ";
&str_NoAddnlClause = "Y";
End-If;
End-If;
&Date = LAC_WS_DERIVED.DATE.Value;
&Date = DateTimeToLocalizedString(&Date, "yyyy-MM-dd");
/* Clause for Date */
If All(LAC_WS_DERIVED.DATE.Value) Then
If &str_NoAddnlClause = "Y" Then
&str_WhereClause = &str_WhereClause | " AND to_char(ADD_DTTM,'yyyy-mm-dd') = " | Quote(&Date);
Else
&str_WhereClause = " to_char(ADD_DTTM,'yyyy-mm-dd') = " | Quote(&Date);
&str_NoAddnlClause = "Y";
End-If;
End-If;
If &str_NoAddnlClause = "Y" Then
&str_WhereClause = "where" | &str_WhereClause;
End-If;
&Act_Log.Select(Record.LAC_WS_ACT_LOG);
Comments
Post a Comment