Hi All,
Hoping someone can help me out on the problem i have.
I am designing a search utility using DSPF (with SQL logic in the backend). The purpose of this search utility is to identify all records from the file matching the condition.
Example:
File1 has 10 fields in it - field1 to field10
DSPF will have all 10 fields displayed
User can input any of those 10 values and the embedded SQL is supposed to find matching records according to the fields input by the user
For this purpose, I hardcode SQL keywords in my SQLRPGLE program as -
C Field1 Const('field1 = ?')
C Field2 Const('field2 = ?')
etc
Now, if user has input field1 and field5 values, I build my SQL statement in program as -
Select * from file1 where field1 = ? and field5 = ?
Then i run,
Prepare SqlStmt from :Sqlstr
Declare c1 cursor for SqlStmt
Open c1 cursor using :field1,:field5
This logic works fine, but as u can see, the problem is that there are 10! (10 factorial) possible combinations that can be input by user. And i cannot write OPEN CURSOR statement with each of the combinations.
What is the ideal way to work on scenarios like this?
Hoping someone can help me out on the problem i have.
I am designing a search utility using DSPF (with SQL logic in the backend). The purpose of this search utility is to identify all records from the file matching the condition.
Example:
File1 has 10 fields in it - field1 to field10
DSPF will have all 10 fields displayed
User can input any of those 10 values and the embedded SQL is supposed to find matching records according to the fields input by the user
For this purpose, I hardcode SQL keywords in my SQLRPGLE program as -
C Field1 Const('field1 = ?')
C Field2 Const('field2 = ?')
etc
Now, if user has input field1 and field5 values, I build my SQL statement in program as -
Select * from file1 where field1 = ? and field5 = ?
Then i run,
Prepare SqlStmt from :Sqlstr
Declare c1 cursor for SqlStmt
Open c1 cursor using :field1,:field5
This logic works fine, but as u can see, the problem is that there are 10! (10 factorial) possible combinations that can be input by user. And i cannot write OPEN CURSOR statement with each of the combinations.
What is the ideal way to work on scenarios like this?
Comment