'Exception handling using Oracle Forms Builder

I am making my first Oracle form in Oracle Forms Builder with the help of web material i.e. tutorials etc. I have written the following code in the WHEN-BUTTON-PRESSED trigger:

INSERT INTO PATIENT VALUES 
(:CNIC_NO, :P_NAME, :CITY, :ADDRESS, :GENDER, :BLOOD_GROUP, :DISEASE, :WARD_NO);
COMMIT;

The problem here is that an unhandled exception is raised by the trigger with the following error numbers:

  • ORA-12899 (Reason is the Null value is inserted in non-Null column)
  • ORA-1400 (Reason is that the data length is too large than the allowed length)

I need to popup an informative message box for these and a default one for the others.



Solution 1:[1]

You have either to guarantee there is a suitable value will be inserted in the specified column that doesn't accept null value the you have to use NVL function inside the insert statement. Well, it's quite a good idea to have a technique too. handle Oracle Forms errors and informative messages

You have also to construct your table columns size larger enough to store the inserted as the address for example must be larger than 100 varchar2.

Solution 2:[2]

You can use The Default Oracle Forms Menu Tool Bar will handle the form's CRUD Operations for you. Instead of writing the insert,update,etc.

But, you have to specify using it by yourself for every form module.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 halfer
Solution 2 Glorfindel