Re: Please help in creating a trigger

From: Jochen Van den Bossche <jochen.vandenbossche_at_proximus.net>
Date: 6 Sep 2002 00:45:06 -0700
Message-ID: <2bbd972e.0209052345.2e1557e8_at_posting.google.com>


Galina.Self_at_cityofbristol.ac.uk (Galina) wrote in message news:<af2b7239.0209050634.17f51afd_at_posting.google.com>...
> Hello
> We use Oracle 8 database in our college. An Oracle application from
> outside supplier enables us to enrol students. Enrolments are
> processed from many PCs on WAN, which includes several sites.
> Recently the system started to behave a bit naughty: one very
> important parameter, number of PC, on which the enrolment is
> processed, SOMETIMES is not recorded in the database.
> I need to create a trigger, which would have fired, if in the record
> being inserted into the table there is NULL in the field, where should
> be computer number. Ideally, I'd like to get this number (to read from
> a file, for example), to insert it into the record and only then to
> insert the record into the table. Is this possible? If yes, would you
> mind to point me in the direction of a trigger code, which I could use
> as an example.
> If Oracle trigger cannot be programmed to read from a file, another
> appropriate action would be to cancel inserting the record and to show
> a message on the screen prompting the user to click SAVE button once
> more. A sample of trigger code would be very appreciated.
> Thank you.
> Galina

It seems that you need to learn some things about Oracle first, so just some tips.

  1. When you start by making the column not null you will get your error message. (Read doc on ALTER TABLE)
  2. Read doc about UTL_FILE to see how oracle can use files
  3. Learn about TRIGGERS, especially BEFORE INSERT and FOR EACH ROW

4° Learn PL/SQL. It has an IF statement. There is allso something called IS NULL. And you can assign values.

These are all the elements needed to do what you want. Received on Fri Sep 06 2002 - 09:45:06 CEST

Original text of this message