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

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: