Forum OpenACS Q&A: table-drop error

Collapse
Posted by Kim Tran on
Hi All,

When I drop the table from a package i'm developing, most of the tables and sequences are dropped, except I get this error for one of my tables:

ERROR: acs_obj_context_idx_anc_id_fk referential integrity violation - key in acs_objects still referenced from acs_object_context_index

this error occurs at the 'select_inline_1()' function call where inline_1() is:

create function inline_1 ()
returns integer as '
declare
    object_rec        record;
begin
    for object_rec in select object_id from acs_objects where object_type=''mip_topic''
    loop
        perform acs_object__delete( object_rec.object_id );
        end loop;

        return 0;
end;' language 'plpgsql';

select inline_1();
drop function inline_1();

this error occurs when dropping this table:

create table mip_topics (
      topic_id                    integer
                    constraint mip_topics_topic_id_fk
                    references acs_objects(object_id)
                    constraint mip_topics_topic_id_pk
                    primary key,
      package_id                  integer
                                    constraint mip_topics_package_id_fk
                                    references apm_packages(package_id),
      owner_id                    integer
                                    constraint mip_topics_owner_id_fk
                                    references users(user_id),
      name                        varchar(255),
      description                  text,
      creation_date                timestamp,
      last_updated                timestamp
);

does anyone know where i might be going wrong?

thankyou for any assistance,
Kim

Collapse
2: Re: table-drop error (response to 1)
Posted by Peter Marklund on
That error message usually means that there are other acs objects with a context_id pointing at the object you are trying to delete. You can find out which objects these are with a query like

select object_type, object_id from acs_objects where context_id in (select object_id from acs_objects where object_type = 'your_object_type');