In a standard search page, there are say 4 fields. 1 Go and 1 clear button.
When we hit Go, the query that runs is :
where po_number = :1
If we have values in field2, then the where clause gets appended by
AND po_line = :2 and so on.
Now I add another field through personalization and extend the CO to append the VO query:
vo.setWhereClause("xyz = :1");
vo.setWhereClauseParams(null); // Always reset
But it gives an error, wrong index, as the index 1 is already used._Here_ is the issue.
How will I know which index number it will get. If I select 1 param, the index will be :1 if I select 1 more it will be :2.
So when I add a new field and pass it to view where clause, what is the best technique_ to handle the index, so that it automatically takes the next incremented value.
Explanation with an example will be highly appreciated.
In the case of dynamic where clause, we always start the indexing from the next number.
Suppose if your View Object contain :1, then on the dynamic where clause you will always append next value, which will be :2 and so on.
Yes, we do write that when we are sure about the numbers..but in my case, some times user can put 1 value, so my index will be 2, but the moment user selects a second field, my index will fail.
I have to check wht fields user selects, take d count, and based on that i gotta assign index, that can be 1 way, but wanted to cnfrm, if any other generic method is there to do this..
If you don't wish to use positional parameter, I think you can go with Named Parameters and then use setNamedWhereClauseParam in VO. This way you need not worry about existing position parameter index. I haven't used this, so not sure of any impacts. Refer to the JDev guide to understand the named parameters and possible issues.
I din't find anything like 'setNamedWhereClauseParam' in jdev guide. In some of the forums it is said, setNamedWhereClauseParam is applicable to adf and not oaf. Am not sure how much that is authentic.
If anyone has any working code in oaf, it will be very much helpful.
Use the following code snippet to add where clause
String s = "xyz="+vXYZ;
Using a variable (vXYZ: value that you want as filter) in string definition would save you to have a named bind parameter and still be able to add the additional bind parameter. This should work.