Forum OpenACS Development: remove relation

Collapse
Posted by Iuri Sampaio on
In attempt to remove a "acs relation" (that i created using relation::add) from acs_rels i used [relation::remove].

But unfortunately it returned errors of dependencies related to references from another table called {rel_type}_ext

ERRO: atualização ou exclusão em tabela "acs_rels" viola restrição de chave estrangeira "message_room_rel_ext_rel_id_fk" em "message_room_rel_ext"
DETAIL: Chave (rel_id)=(28060) ainda é referenciada pela tabela "message_room_rel_ext".
CONTEXT: comando SQL "delete from acs_objects where object_id = 28056"
PL/pgSQL function "acs_object__delete" line 45 at EXECUTE statement
comando SQL "SELECT acs_object__delete( $1 )"
PL/pgSQL function "content_item__del" line 108 at PERFORM
comando SQL "SELECT content_item__del ( $1 )"
PL/pgSQL function "content_item__delete" line 4 at PERFORM
comando SQL "SELECT content_item__delete( $1 )"
PL/pgSQL function "acs_message__delete" line 5 at PERFORM

API Reference:
api-doc/proc-view?proc=relation_remove&source_p=1&version_id=

Please correct me if i am wrong but the API [relation::remove] calls a psql function as in

db_exec_plsql relation_delete "begin ${package_name}.del(:rel_id); end;"

which is showed as:

fullquery name="relation_remove.relation_delete"
querytext
begin perform ${package_name}__delete(:rel_id); return null; end;
/querytext
/fullquery

Moreover, it is missing the chunk of code that removes the relation from the table {rel_type}_ext to be executed before the line

begin perform ${package_name}__delete(:rel_id); return null; end;

The best way would be to create a plsql function that would do the job to totally and properly remove the relation from the system.

Do i make any sense?

Collapse
2: Re: remove relation (response to 1)
Posted by Iuri Sampaio on
Sorry,

the name of the APIs are wrong. Their names are relation_add and relation_remove.