ORA-02291 [message #508353] |
Fri, 20 May 2011 09:44 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
rhnshk
Messages: 26 Registered: May 2008
|
Junior Member |
|
|
i have master-detail form and my current setting are;
my header block has V_DATE, V_CCODE,V_CODE AND V_NO
V_CCODE,V_CODE AND V_NO is a headr blk primary key
V_DATE - initial value set at design time $$date$$
V_CCODE - initial value set at design time :GLOBAL.M_CCODE
V_CODE - initial value set at design time :GLOBAL.M_CODE
in PRE-FORM trigger also i am initializaing;
V_DATE := SYSDATE
V_CCODE := :GLOBAL.M_CCODE
V_CODE := :GLOBAL.M_CODE
in WHEN-VAIDATE_ITEM of V_DATE, i am caling a procedure (P_NEW_NO)
P_NEW_NO(:V_NO, :V_CODE, :V_CCODE);
thats brings value for next header field V_NO...
(a transaction no. field, that i dont want users to fill manually..and so disabled at WNFI)
I have WHEN-CREATE-RECORD at header blk...with the following code;
:V_DATE := SYSDATE;
P_NEW_NO(:V_NO, :V_CODE, :V_CCODE);
PROCEDURE P_NEW_NO
(P_NO IN OUT NUMBER,
P_CODE IN VARCHAR2,
P_CCODE IN VARCHAR2) IS
M_CURR_NO TXN_RANGE.T_CURR_NO%TYPE ;
M_TO_NO TXN_RANGE.T_TO_NO%TYPE ;
CURSOR GET_NEW_NO IS
SELECT NVL(T_CURR_NO, 0) + 1, NVL(T_TO_NO, 0)
FROM TXN_RANGE
WHERE T_COMP_CODE = P_CCODE
AND T_TXN_CODE = P_CODE;
BEGIN
OPEN GET_NEW_NO;
FETCH GET_NEW_NO INTO M_CURR_NO, M_TO_NO ;
IF GET_NEW_NO%NOTFOUND THEN
MESSAGE('TRANSACTION NO. NOT INITIALISED');
MESSAGE(' ');
RAISE FORM_TRIGGER_FAILURE;
END IF ;
CLOSE GET_NEW_NO;
IF M_CURR_NO > M_TO_NO THEN
MESSAGE('CURRENT TXN NO. IS OVER THE LIMIT');
MESSAGE(' ');
RAISE FORM_TRIGGER_FAILURE;
END IF ;
P_NO := M_CURR_NO ;
END;
the problem occurs when i am in query mode and press NEXTRECORD and come to new record.
The cursor is in the V_DATE field and through mouse, i go into the first field of the detail record.
i enter few records in the detail record and press save button
the form gives error ORA-02291..Integrity constraint FK violated - parent key not found
but i confirm the presence of the header blk's primary key, by inserting a message;
message('Header Blk Pre-Insert PK :'||:v_ccode||'-'||:v_code||'-'||:v_no );
in the detail blk's PRE-INSERT, they are very well present i notice and
the control does not go first into the PRE-INSERT of the header block.
there is no problem when in query mode, i press CREAT_RECORD button
instead of NEXT_TECORD button and come to create new record.
please kindly someonne help me solve this...
|
|
|
Re: ORA-02291 [message #510449 is a reply to message #508353] |
Mon, 06 June 2011 01:59 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
|
Hello!
You should change your trigger from WHEN-VALIDATE-ITEM to WHEN-NEW-RECORD-INSTANCE. This will solve your problem and one other thing you don't need to initialize the same field twice. The problem is not due to this but just for your information. Initializing each item once is enough
Thanks!
Saira
|
|
|