How to reproduce:
- Open your View Object, go to Query section and click Create new view criteria sign. Create View Criteria wizard will be opened
- In Edit Query Criteria tab, press Add Item button. As Attribute choose EmployeeId and for Operand select Bind Variable option
- Press New button, available next to Parameter field
- In Bind Variable wizard, provide employeeIdVar for Name and Number for Type. Press OK
- Press OK in Create View Criteria wizard - EmployeesViewCriteria is created and Bind Variable is defined as well. So far its okej
- Now let's say we will want to modify our View Criteria. Click Edit selected view criteria sign for EmployeesViewCriteria. Edit View Criteria dialog will be opened
- Press Add Item button and change Attribute for added item to FirstName. For Operand slect Bind Vraiable option
- Press New button, available next to Parameter field
- In Bind Variable wizard, provide firstNameVar for Name and String for Type. Press OK
- Everything looks okej, so press OK in Edit View Criteria wizard in order to update EmployeesViewCriteria
- Save your View Object
- Now, reopen Edit View Criteria wizard by clicking on Edit selected view criteria sign
- I know, you will be surprised now, but you will see that for FirstName item is assigned employeeIdVar Bind Variable. Here is a Bug - correct Bind Variables are not stored correctly, simply first one from the list is assigned after you closing Edit View Criteria wizard:
This means, if developer will forget to fix this, on runtime same Bind Variable will be used for both parameters. In this case Number type Bind Variable is assigned to String type parameter.
On runtime, when user will select value for EmployeeId parameter, same value will applied for FirstName parameter:
WHERE part of SQL statement looks pretty funny as well:
WHERE ( ( ( ( Employees.EMPLOYEE_ID = :employeeIdVar ) OR ( :employeeIdVar IS NULL ) ) AND ( ( UPPER(Employees.FIRST_NAME) LIKE UPPER( :employeeIdVar || '%') ) OR ( :employeeIdVar IS NULL ) ) ) )
Workaround (not smart enough):
- If you are using Edit View Criteria wizard and adding new Items with new Bind Variables, always reopen (after first change) this wizard and check if Bind Variables are not reassigned. If they are, change them back and close wizard - next time reassignment for already defined items will not be done
Spanish Summary:
Titulo: Bugs en el asistente de Jdeveloper 11g cuando se crean formularios de ALTA y EDICION.
Resumen: En este post se reproduce un error que genera el asistente de jdeveloper cuando se construyen formularios. Este articulo incluye la manera de solucionar este inconveniente.