FRM-40508 : ORACLE error: unable to INSERT record. [message #574616] |
Mon, 14 January 2013 04:14 |
|
goldray
Messages: 108 Registered: December 2012
|
Senior Member |
|
|
Hi,
I have an interface composed of five elements:
1.display_item (primary key)
2-list_item (foreign key) / / dynamic list :this is the cause of the error
3-lis_item (foreign key) / / dynamic list
4-text_item
5-button (insert commit)
when I click the button, an error is displayed:
FRM-40508: ORACLE error: unable to INSERT record.
in detail: ora-02291 integrity constraint Violated - parent key not found
Note:
-the elements of two lists already exist in the parent table!!
-I use a block based.
-button code:
[Updated on: Mon, 14 January 2013 04:17] Report message to a moderator
|
|
|
Re: FRM-40508 : ORACLE error: unable to INSERT record. [message #574623 is a reply to message #574616] |
Mon, 14 January 2013 06:14 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Oracle doesn't lie. So the value used in the list item doesn't match the value in the parent table.
You do realise that list items have a display value and a stored value. Display value is what you see on the screen, stored value is what is sent to the database.
So how are populating the list item?
|
|
|
|
Re: FRM-40508 : ORACLE error: unable to INSERT record. [message #574635 is a reply to message #574623] |
Mon, 14 January 2013 08:01 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
I can read. Which is why I said:
cookiemonster wrote on Mon, 14 January 2013 12:14Oracle doesn't lie. So the value used in the list item doesn't match the value in the parent table.
You may think it does exist in the parent, you're wrong.
Which is why I asked my question.
What query?
What's the parent table?
What columns are in the fk?
|
|
|
Re: FRM-40508 : ORACLE error: unable to INSERT record. [message #574636 is a reply to message #574635] |
Mon, 14 January 2013 08:16 |
|
goldray
Messages: 108 Registered: December 2012
|
Senior Member |
|
|
Here is the code to create the list:
PROCEDURE pop_list IS
/*
** Built-in: CREATE_GROUP_FROM_QUERY
**Example: Create a record group from a query, and populate it.
*/
list_id ITEM;
list_name VARCHAR2(40) := 'emp.id';
rg_name VARCHAR2(40) := 'abc';
rg_id RecordGroup;
errcode NUMBER;
outcome NUMBER;
BEGIN
-- Make sure group doesn't already exist
list_id :=Find_Item(list_name);
rg_id := Find_Group( rg_name );
-- If it does not exist, create it and add the two
-- necessary columns to it.
IF Id_Null(rg_id) THEN
rg_id := Create_Group_From_Query( rg_name,'SELECT to_char(id),to_char(id) FROM grade',FORM_SCOPE,200);
END IF;
IF Not Id_Null(rg_id) THEN
delete_group(rg_id);
rg_id := Create_Group_From_Query( rg_name,'SELECT to_char(id),to_char(id) FROM emp',FORM_SCOPE,200);
END IF;
-- Populate the record group
errcode := Populate_Group_with_query( rg_id,'SELECT to_char(id),to_char(id) FROM emp' );
IF errcode = 0 THEN
outcome := GET_GROUP_ROW_COUNT(rg_id);
--Message(outcome);
END IF;
Clear_List(list_id);
Populate_List(list_id,rg_id);
END;
the column 's : id(foreign key)
in the parent table (dept), there are these values:
123
77
and in the list, there are also the same values:
123
77
i have 2 FK:
Id(from the table parent dept)
mgr_no(from the table parent manager)
|
|
|
|
Re: FRM-40508 : ORACLE error: unable to INSERT record. [message #574656 is a reply to message #574643] |
Mon, 14 January 2013 13:13 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
1) why are you to_charing id? If it's a number in the parent tables then it should be a number in the one your block is based on.
2) Why are do you have a query against grade when you're not using it (the result is immediately overwritten)?
3) Why do you talk about dept and manager when there's no reference to them in the sample code?
|
|
|
|
Re: FRM-40508 : ORACLE error: unable to INSERT record. [message #574665 is a reply to message #574660] |
Mon, 14 January 2013 14:09 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
1) if the parent table column is number then the child column should also be number. If the parent column is varchar2 then the to_char is silly. Either way it should not be there.
2) So you're running the same query twice to populate the same group? That makes even less sense. Or are there more typos? Try copying and pasting the code.
3) That doesn't answer my question at all. List all the tables involved. State which one is parent and child for each fk. State which one the block is based on.
|
|
|
|
Re: FRM-40508 : ORACLE error: unable to INSERT record. [message #574708 is a reply to message #574666] |
Tue, 15 January 2013 06:30 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
1) So why are you to_charing a char?
2)
Your code:
IF Id_Null(rg_id) THEN
rg_id := Create_Group_From_Query( rg_name,'SELECT to_char(id),to_char(id) FROM grade',FORM_SCOPE,200);
END IF;
IF Not Id_Null(rg_id) THEN
delete_group(rg_id);
rg_id := Create_Group_From_Query( rg_name,'SELECT to_char(id),to_char(id) FROM emp',FORM_SCOPE,200);
You've got 2 create_group_from_query for the same record group with 2 different queries. Why?
3) You don't understand a list of simple questions? What exactly do you not understand?
|
|
|
|
Re: FRM-40508 : ORACLE error: unable to INSERT record. [message #574717 is a reply to message #574716] |
Tue, 15 January 2013 07:45 |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
2) Again - why are you using two different selects for the same list item? Why is there a condition at all?
3) You don't understand "list all tables involved"? You don't understand "State which one the block is based on"?
Really?
You have a form that is giving a foreign key error. I want you to list all the tables that are involved - the one the datablock is based on and the ones referenced by the foreign keys. You've given bits of the list so far. I want the full list. With a clear explanation of the relationships between the tables.
How do you expect us to be able to tell what the problem is without that information?
|
|
|
|
|
Re: FRM-40508 : ORACLE error: unable to INSERT record. [message #574725 is a reply to message #574722] |
Tue, 15 January 2013 08:12 |
|
goldray
Messages: 108 Registered: December 2012
|
Senior Member |
|
|
2)
i remplaced this part :
IF Id_Null(rg_id) THEN
rg_id := Create_Group_From_Query( rg_name,'SELECT to_char(id),to_char(id) FROM emp',FORM_SCOPE,200);
END IF;
IF Not Id_Null(rg_id) THEN
delete_group(rg_id);
rg_id := Create_Group_From_Query( rg_name,'SELECT to_char(id),to_char(id) FROM emp',FORM_SCOPE,200);
by this:
rg_id := Create_Group_From_Query( rg_name,'SELECT to_char(id),to_char(id) FROM emp',FORM_SCOPE,200);
Now the list is populated
the problem 's solved ! thank you very much Sir
[Updated on: Tue, 15 January 2013 08:40] Report message to a moderator
|
|
|
|
|