Home » Developer & Programmer » Forms » the pre_commit not working ?
the pre_commit not working ? [message #454986] Sun, 09 May 2010 06:31 Go to next message
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 #454988 is a reply to message #454986] Sun, 09 May 2010 07:42 Go to previous messageGo to next message
Michel Cadot
Messages: 68686
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You cannot insert a NULL value in a column that is declared as NOT NULL.

Regards
Michel

[Updated on: Sun, 09 May 2010 07:42]

Report message to a moderator

Re: the pre_commit not working ? [message #454989 is a reply to message #454988] Sun, 09 May 2010 08:04 Go to previous messageGo to next message
ahmed_samir
Messages: 61
Registered: January 2009
Location: EGYPT
Member
the problems is the trigger it self .. change the tigger to :

pre_insert

and it will work ..

tanks
Re: the pre_commit not working ? [message #454993 is a reply to message #454989] Sun, 09 May 2010 11:51 Go to previous message
Littlefoot
Messages: 21818
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.
Previous Topic: Why are forms 10g Images blur on run time ?
Next Topic: FRM-92101 Windows server Forms 10g
Goto Forum:
  


Current Time: Fri Sep 20 09:26:48 CDT 2024