Subject Re: [ib-support] Triggers
Author Lee Catlett
Thanks Lucas, yes I think that works when I use a constant. Any idea on how
to do this when the 'abc_def' part needs to come from a table value?
Lee

Lucas Franzen wrote:

> Lee Catlett schrieb:
> >
> > I may have posted this a week or so ago so my apologies for duplicating
> > the question, but I need some input if anyone can help. Can someone
> > give me some idea of how to write a trigger that would generate keys
> > that would look something like this:
> > abc_def_100. I know that getting the 100 is the easy part, but how does
> >
> > one preface the number with some other literal that could be a constant
> > or db derived value??
>
> Lee,
>
> supposed I understood it right, you could do something like:
>
> create trigger BI_MYTABLE FOR MYTABLE
> BEFORE INSERT POSITION 0
> AS
> BEGIN
> NEW.SOMEFIELD = 'abc_def_' || CAST ( GEN_ID ( G_MYGENERATOR, 1 ) AS
> VARCHAR(12) );
> END
>
> this fill the field SOMEFIELD with abc_def_ + the generator-value.
>
> Is this what you're lookung for?
>
>
> To unsubscribe from this group, send an email to:
> ib-support-unsubscribe@egroups.com
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/