Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Oracle triggers

Re: Oracle triggers

From: <assoy_at_my-deja.com>
Date: Sun, 14 Nov 1999 22:47:26 GMT
Message-ID: <80ne5t$slu$1@nnrp1.deja.com>


Try this

CREATE TABLE TT_TEST
( THE_ID NUMBER(3),
  vchInsertBy VARCHAR2(30),
  dtInsertDate DATE);
/

CREATE OR REPLACE TRIGGER JT_TRIG_ROW
BEFORE INSERT OR UPDATE ON JT_COBA
FOR EACH ROW
BEGIN    IF ( :NEW.dtInsertDate IS NULL )
   THEN
        :NEW.dtInsertDate := SYSDATE;
   END IF;
END;
/

SQLWKS> insert into TT_TEST ( the_id, The_name )

     2> Values (1,'TEST');
1 row processed.
SQLWKS> select * from jt_coba

     2>
THE_ID     VCHINSERTBY                    DTINSERTDATE
---------- ------------------------------ --------------------
         1 TEST                           14-NOV-99
1 row selected.

In article <80cibs$bsp$1_at_nnrp1.deja.com>,   jdefreitas_at_my-deja.com wrote:
> Hi. I am running Oracle 8.0.5, and have a question
> about triggers.
>
> On our tables there are "dtInsertDate" and
> "vchInsertBy" fields. I want to alter the
> "TI" triggers (the triggers that execute when a
> record is inserted) so that if a user does not
> supply the dtInsertDate, the field will be set to
> sysdate.
>
> I was wondering if anyone had some PL/SQL
> examples of this, and also whether the trigger
> should fire before or after the insert (I assume
> after).
>
> Thanks! - John G. de Freitas
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Sun Nov 14 1999 - 16:47:26 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US