Re: Trigger using results from other trigger

[prev] [thread] [next] [Date index for 2005/04/04]

From: Peter Speltz
Subject: Re: Trigger using results from other trigger
Date: 17:41 on 04 Apr 2005
--- Charles Bailey <bailey@xxxxxx.xxxxx.xxx> wrote:
> --On April 3, 2005 11:46:53 AM -0700 Peter Speltz <peterspeltz@xxxxx.xxx> 
> wrote:
> 

> > In specific (specifically),
> > I have a class, Dialup, with an is_a relationship to IntrntSrvc. The is_a
> > sets a before create trigger to create the IntrntSrvc object. I want to
> > use the IntrntSrvc object's id as the id for Dialup.  I couldn't set the
> > is_a on Dialup's id cause of inflation issues so Dialup just has two
> > columns with same value.
> >
> > What's best way to do this?
> 
> That could be tough, depending on what assumption C::D::R::IsA's trigger 
> makes.  You could write your trigger to create the IntrntSrvc object if 
> needed, but that depends on the IsA trigger knowing enough not to try to 
> create the object again (just using find_or_create would work).
> 

Thanks for the reply. 
IsA.pm's before_create trigger looks pretty complex and i didn't feel like
trying to duplicate it in Dialup.  I tried after_create  but as suspected that
didn't work because i altered the primary key. Perhaps i could have undefed the
object and done the alter  in sql and maybe cleared the object index but that
may not have worked.  I didn't want to do it after create anyway.

So simple solution was to add a line to IsA's before create trigger sub to set
the sub class object column named  'id' (Dialup's id) to the foreign class
object's id (IntrntSrvc id) right after it creates fobj.  This works  as I
can't imagine a case where I wouldn't want the isa related classes to have same
key. Can you?

One question however, is it possible to override one if IsA.pm 's subs in say
my model base class? The trigger sub is called _creator.
So could i say in My::CDBIBase

package Class::DBI::Relationship::IsA;
sub _creator {
..
}

I'll try that ....
Nope. Didn't work.  How could I  override that sub somewhere without creating a
new relationship?

thanks

> --
> Regards,
> Charles Bailey  < bailey _at_ newman _dot_ upenn _dot_ edu >
> Newman Center at the University of Pennsylvania
> 

pjs


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Personals - Better first dates. More second dates. 
http://personals.yahoo.com

Trigger using results from other trigger
Peter Speltz 18:46 on 03 Apr 2005

Re: Trigger using results from other trigger
Charles Bailey 23:17 on 03 Apr 2005

Re: Trigger using results from other trigger
Peter Speltz 17:41 on 04 Apr 2005

Generated at 14:42 on 11 Apr 2005 by mariachi v0.52