I have a DSPF with filtering allowed for multiple columns like - Column1, Column2, Column3. User can input values for any of these columns or all columns at once or even can leave those as blank.
My requirement is, initially when i display the screen, I load all records from the database file and show it on screen. The moment user hits enter key, i need to validate if value for any of these 3 columns are input. If yes, I need to dynamically query the database according to the selected columns only.
Example: User input value for column2 only. So, my program will run query like - "Select * from table where column2 = XXX'.
I can handle this by writing 8 possible queries (2^3 possible combinations) in the program, but i feel there must be a better way to do this.
Is there a way to do this efficiently? Or should the design be changed?