the pre_commit not working ? [message #454986] |
Sun, 09 May 2010 06:31 |
ahmed_samir
Messages: 61 Registered: January 2009 Location: EGYPT
|
Member |
|
|
hi there
this is the fields of : hr_family_info
Column Name ID Pk Null? Data Type Default Histogram
FAMILY_ID 1 1 N NUMBER (38) Yes
FAMILY_NAME 2 Y VARCHAR2 (100 Byte) Yes
FAMILY_BIRTHDAY 3 Y DATE Yes
FAMILY_RELATION 4 Y VARCHAR2 (10 Byte) Yes
FAMILY_NOTES 5 Y VARCHAR2 (1000 Byte) Yes
EMP_ID 6 Y NUMBER (10) Yes
i made this form to add the family for the employees ..
after made it i made a form trigger called "pre_commit" to get the max of the FAMILY_ID to add for every record . and this is the code :
/* Formatted on 2010/05/09 13:24 (Formatter Plus v4.8.8) */
SELECT NVL (MAX (FAMILY_ID), 1)+1
INTO :HR_FAMILY_INFO.FAMILY_ID
FROM hr_family_info;
but the problem is when i try to save the record .. an error raise :
ORA-01400: cannot insert NULL into ("ACCURATE"."HR_FAMILY_INFO"."FAMILY_ID")
note :
FAMILY_ID & EMP_ID [ the required & visible ] is set to no coz i need it to generate auto ..
how to solve this ..
|
|
|
|
|
Re: the pre_commit not working ? [message #454993 is a reply to message #454989] |
Sun, 09 May 2010 11:51 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
Note that "MAX + 1" leads to a possible uniqueness problem, if two (or more) users do the same job at the same time. Perhaps you should consider using a sequence instead.
|
|
|