trigger problem
Posted in 2009
Topics: Triggers, Constraints & Referential Integrity
Oracle could use triggers to override or set a value for a column, for example: create or replace trigger trg_serv_related before insert on serv_related for each row begin :new.related_type:='01'; end; How to do it in informix? oracle has such kind of technology about 15 years ago.
CHUAN LU wrote: > Oracle could use triggers to override or set a value for a column, for > example: > > create or replace trigger trg_serv_related > before insert on serv_related > for each row > begin > :new.related_type:='01'; > end; > > How to do it in informix? oracle has such kind of technology about 15 years > ago. Informix has this thing called triggers. It's also had it for about 15 years. It's in the fucking manual (and has been for all that time.) -- Cheers, Obnoxio The Clown http://obotheclown.blogspot.com -- This message has been scanned for viruses and dangerous content by OpenProtect(http://www.openprotect.com), and is believed to be clean.
And Informix had the functionality 19 years ago. You COULD do this in
Informix with an INSERT trigger, but it would be better to do it with a
DEFAULT constraint on the column which entails far lower overhead than a
trigger. And Informix supported DEFAULT clauses a year before it supported
triggers. In the CREATE TABLE statement:
CREATE TABLE serv_related (....
related_type CHAR DEFAULT '01',
...
);
Or if the table already exists, then via ALTER TABLE (which Informix also
had for 19 years and Oracle for less than 10 (but who's counting):
ALTER TABLE serv_related MODIFY related_type DEFAULT '01';
Art
Art S. Kagel
Oninit (www.oninit.com)
IIUG Board of Directors (art@iiug.org)
Disclaimer: Please keep in mind that my own opinions are my own opinions and
do not reflect on my employer, Oninit, the IIUG, nor any other organization
with which I am associated either explicitly or implicitly. Neither do
those opinions reflect those of other individuals affiliated with any entity
with which I am affiliated nor those of the entities themselves.
On Thu, May 14, 2009 at 12:44 AM, CHUAN LU <luchuan@cn.ibm.com> wrote:
> Oracle could use triggers to override or set a value for a column, for
> example:
>
> create or replace trigger trg_serv_related
> before insert on serv_related
> for each row
> begin
> :new.related_type:='01';
> end;
>
> How to do it in informix? oracle has such kind of technology about 15 years
> ago.
>
>
>
>
*******************************************************************************
> Forum Note: Use "Reply" to post a response in the discussion forum.
>
>
--001636c597b88532960469dd4400