Skip to content
Advertisement

Oracle APEX master detail page creation: ORA-06531 error

I am creating a flock management application with APEX with the following PL/SQL scheme:

In this scheme, the SALE and EVENT tables reference the EID field of the SHEEP table (unique identifier of 5 numbers and one letter – representing the yellow tag they have in their ears). I am trying to create a Master Detail page that would link a sheep to specific events (what happened to the sheep) and a sales history (if it has been sold, when, where, for how much).

I tried to use both the Create Application Wizard and the Create Page Wizard but each time I get the same error:

Ajax call returned server error ORA-06531: Reference to uninitialized collection for Execute PL/SQL Code.

It still lets me continue in the wizard but when I want to select the details tables (SALE & EVENT), they don’t even show up in selecting list (cf here).

Does someone have an idea? I am quite new to APEX and I might have missed something. Also, if you have any recommendations considering my relational scheme (change to make, improvements for efficiency), don’t hesitate to tell me as well.

Thanks in advance!

Advertisement

Answer

There is no relationship between event and sheep or between sale and sheep. You state the SALE and EVENT tables reference the EID field of the SHEEP table but the database doesn’t know about that, because that relationship has not been defined by way of a foreign key. A foreign key in a table references the primary key of the other table, you can’t reference another column (like the EID), even if that is unique.

In your script, make sheep_id NUMBER in all tables and create a foreign key in SALE and EVENT. Like this:

This is the way to create a master detail relationship in relational database system and it should allow you to create a Master-Detail form in APEX as well.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement