Re: Update table's column in table's trigger
Posted in 1999
Topics: Stored Procedures & SPL, Triggers, Constraints & Referential Integrity
I have an idea, but I'm not sure it will be suitable for you.
Just create a simple stored procedure like:
create procedure _upper(f char(255))
returning char(255);return upper(f);
end procedure;
and then modify your trigger to look like:
CREATE TRIGGER tri_composer INSERT on composer
REFERENCING NEW as post
FOR EACH ROW( execute procedure _upper( post.lastname ) into_ulastname);
I didn't test it and I'm not sure it will work in all cases.
Best Regards,
Octav
Mike wrote:
>
> How do I write a trigger to update a column in the table that is being
> updated, based on a value from another column in the table?
>
> For example, in table composer, with columns lastname and _ulastname, this
> doesn't work
>
> CREATE TRIGGER tri_composer INSERT on composer
> REFERENCING NEW as post
> FOR EACH ROW( post._ulastname = upper( post.lastname ) );>
> Any help is greatly appreciated.
>
> Thanks
> Mike Skillicorn
--
Octav Chiriac Phone: (373) 2 22 99 67
NetInfo S.R.L. Fax: (373) 2 21 36 59
Chisinau (373) 2 22 84 88
Moldova, Republic of mailto:com@netinfo-moldova.com
Octav
Thanks for your suggestion, it works! I CANNOT BELIEVE you have to write
the trigger this way, but as long as it works.....
Thanks
Mike
Octav Chiriac <com@netinfo-moldova.com> wrote in article
<7u4c8n$ats$1@news.xmission.com>...
>
> I have an idea, but I'm not sure it will be suitable for you.
> Just create a simple stored procedure like:
>
> create procedure _upper(f char(255))
> returning char(255);> return upper(f);
> end procedure;
>
> and then modify your trigger to look like:
>
> CREATE TRIGGER tri_composer INSERT on composer
> REFERENCING NEW as post
> FOR EACH ROW( execute procedure _upper( post.lastname ) into> _ulastname);
>
>
> I didn't test it and I'm not sure it will work in all cases.
>
> Best Regards,
> Octav
>
>
> Mike wrote:
> >
> > How do I write a trigger to update a column in the table that is being
> > updated, based on a value from another column in the table?
> >
> > For example, in table composer, with columns lastname and _ulastname,
this
> > doesn't work
> >
> > CREATE TRIGGER tri_composer INSERT on composer
> > REFERENCING NEW as post
> > FOR EACH ROW( post._ulastname = upper( post.lastname ) );> >
> > Any help is greatly appreciated.
> >
> > Thanks
> > Mike Skillicorn
>
> --
> Octav Chiriac Phone: (373) 2 22 99 67
> NetInfo S.R.L. Fax: (373) 2 21 36 59
> Chisinau (373) 2 22 84 88
> Moldova, Republic of mailto:com@netinfo-moldova.com
>