relation_remove (public)

 relation_remove [ rel_id ]

Defined in packages/acs-subsite/tcl/relation-procs.tcl

Removes the specified relation. Throws an error if we violate a relational constraint by removing this relation.

Parameters:
rel_id (optional)
Returns:
1 if we delete anything. 0 otherwise (e.g. when the relation was already deleted)
Author:
Michael Bryzek <mbryzek@arsdigita.com>
Created:
1/5/2001

Partial Call Graph (max 5 caller/called nodes):
%3 test_acs_subsite_relation_procs acs_subsite_relation_procs (test acs-subsite) relation_remove relation_remove test_acs_subsite_relation_procs->relation_remove db_0or1row db_0or1row (public) relation_remove->db_0or1row db_exec_plsql db_exec_plsql (public) relation_remove->db_exec_plsql relation_segment_has_dependent relation_segment_has_dependent (public) relation_remove->relation_segment_has_dependent acs_user::demote_user acs_user::demote_user (public) acs_user::demote_user->relation_remove application_link::delete_links application_link::delete_links (public) application_link::delete_links->relation_remove group::remove_member group::remove_member (public) group::remove_member->relation_remove packages/acs-subsite/www/admin/groups/rel-type-remove-2.tcl packages/acs-subsite/ www/admin/groups/rel-type-remove-2.tcl packages/acs-subsite/www/admin/groups/rel-type-remove-2.tcl->relation_remove packages/acs-subsite/www/admin/rel-types/delete-2.tcl packages/acs-subsite/ www/admin/rel-types/delete-2.tcl packages/acs-subsite/www/admin/rel-types/delete-2.tcl->relation_remove

Testcases:
acs_subsite_relation_procs
Source code:
    # Pull out the segment_id and the party_id (object_id_two) from
    # acs_rels. Note the outer joins since the segment may not exist.
    if { ![db_0or1row select_rel_info_rm {}] } {
        # Relation doesn't exist
        return 0
    }

    # Check if we would violate some constraint by removing this relation.
    # This query basically says: Does there exist a segment, to which
    # this party is an element (with any relationship type), that
    # depends on this party being in this segment? That's tough to
    # parse. Another way to say the same things is: Is there some constraint
    # that requires this segment? If so, is the user a member of the segment
    # on which that constraint is defined? If so, we cannot remove this
    # relation. Note that this segment is defined by joining against
    # acs_rels to find the group and rel_type for this relation.

    if { $segment_id ne "" } {
        if { [relation_segment_has_dependent -segment_id $segment_id -party_id $party_id] } {
            error "Relational constraints violated by removing this relation"
        }
    }

    db_exec_plsql relation_delete {}

    return 1
Generic XQL file:
<fullquery name="relation_remove.select_rel_info_rm">
    <querytext>

	select s.segment_id, r.object_id_two as party_id, t.package_name
	  from acs_rels r
	         left outer join rel_segments s
		   on (r.object_id_one = s.group_id and r.rel_type = s.rel_type), 
	       acs_object_types t
	 where r.rel_type = t.object_type
	  and r.rel_id = :rel_id
    
      </querytext>
</fullquery>
packages/acs-subsite/tcl/relation-procs.xql

PostgreSQL XQL file:
<fullquery name="relation_remove.relation_delete">
    <querytext>
        select ${package_name}__delete(:rel_id) from dual
      </querytext>
</fullquery>
packages/acs-subsite/tcl/relation-procs-postgresql.xql

Oracle XQL file:
<fullquery name="relation_remove.relation_delete">
    <querytext>
      begin ${package_name}.del(:rel_id); end;
      </querytext>
</fullquery>
packages/acs-subsite/tcl/relation-procs-oracle.xql

[ hide source ] | [ make this the default ]
Show another procedure: