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

Home -> Community -> Usenet -> c.d.o.misc -> Re: trigger for logtable

Re: trigger for logtable

From: Nuno Guerreiro <nuno-v-guerreiro_at_telecom.pt>
Date: 1998/03/30
Message-ID: <35216c8f.93062877@news.telecom.pt>#1/1

On Fri, 27 Mar 1998 10:11:34 +0100, Paul Kreis <nkrepa_at_ascom.ch> wrote:

>hello,
>
>I work on Solaris 2.5.1 with Oracle Server 7.3.3 and Oracle Forms 4.5.
>I have to create my first productive database.
>
>For the tables there are logtables. Now I should write
>a trigger (preupdate) who read out only the (old)values of the row, who
>will be updated of the table and put them
>to the log table.
>
>Example of the tables
>
>tb_port
>port_id switch_id (foreign_key) port
>12 20 5.1
>
>log_port
>port_id switch_id port logdate
>
>Could anyone help me?
>
>--
>=================================================================
>Paul C. Kreis Informatiker Ascom
> Phone: ++41(0)31 999 6605
>paul.kreis_at_ascom.ch Natel: ++41(0)79 432 0514

Open a SQL*Plus session and type the following text:

CREATE TRIGGER tb_port_upd_row
BEFORE UPDATE ON tb_port
FOR EACH ROW
BEGIN

	INSERT INTO log_port (port_id, switch_id, port, logdate)
	VALUES (:old.port_id, :old.switch_id, :old.port, sysdate);
END;
/

I guess this will work, if I haven't made any syntax error.

Study Oracle Application Developer's Guide in order to get a good picture of how you should design your application and a good understanding on triggers.

Send my regards to the beautiful village of Grindelwald and to Interlaken in general,

Nuno Guerreiro Received on Mon Mar 30 1998 - 00:00:00 CST

Original text of this message

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