This content has been marked as final. Show 5 replies
You may find it easier to perform a page validation before allowing the submit to take place. That way, you can use the error messaging system within Apex to display the error.
Thanks for your reply.
The detail part of the Form has multiple rows. Can I use sum of the sal column for all the rows being displayed to do the validation? Means if I query dept 10 and all its employees and change salary for some of the employees, it should validate on submit button that total dept sal should be below 100.
Yes, you can do that. You would need to create a page validation that loops through the records in the tabular form, checks the values entered and then returns an error message.
Create a new validation. Set it to a Page level validation, select PL/SQL and then Function returning error text, then give it a name. The PL/SQL will be something like:
This will loop through the records in column 4 and check the amount. If it is greater than 100, an error message is generated displaying the row with the error. This will stop the process on the first error. If there are no errors NULL is returned which indicates that the validation test has passed.
BEGIN FOR i IN 1..APEX_APPLICATION.G_F01.COUNT LOOP IF TO_NUMBER(APEX_APPLICATION.G_F04(i)) > 100 THEN RETURN 'Item ' || TO_CHAR(i) || ' - DEPTSAL must not be greater than 100'; END IF; END LOOP; RETURN NULL; END;
You should replace G_F04 with the correct column for your page - do a View Source on the loaded page and check for the "name" attribute for the column. G_F04 is for "f04", G_F05 is for "f05" etc.
Thanks Andy, it works.
You're welcome, Zahid