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 Code

Re: Trigger Code

From: Mark C. Stock <mcstockX_at_Xenquery>
Date: Sun, 21 Mar 2004 06:58:30 -0500
Message-ID: <mJSdnfnp_q8cHsDdRVn-hw@comcast.com>

"Redd" <javatek?@usa.com> wrote in message news:EM67c.68419$p77.57341_at_bignews3.bellsouth.net...
|
|
| --
| javatek?@usa.com
|
| remove the ? to reply.
| "Mark C. Stock" <mcstockX_at_Xenquery .com> wrote in message
| news:PfWdnc-muMypasHdRVn-gQ_at_comcast.com...
| > | Quantity Integer
| > | OldQuantity Integer
| > | OnOrder Char
| > |
| > |
| > | Does anyone know how to write the trigger that on update
| > | if Quantity is equal to or less than OldQuantity write the
| > | Character "T" to the OnOrder field.
| > |
| > |
| > |
| > |
| >
| > use a 'before update ... for each row' trigger with a 'when' condition
| that
| > compares the oldquantity and new quantity, and assign the value 'T' to
| > onorder
| What I would like is to see what that actual code segment would look like.
| We are going to use this as a small test to see if any of the DBAs to be
| interviewed can write triggers. I am not a programmer.
|
|

more than happy to oblige, but you do have other criteria for determining if the dba is qualified, right? ;-)

create or replace trigger sample_trigger before insert or update on t1
for each row
when (new.quantity > old.quantity)
begin

   :new.onorder := 'T';
end;
/

there are other ways to do this, and there are some subtleties which could make code that looks almost exactly like this not work -- so if the candidates answers are being reviewed by a non-technical person, you really won't know if he/she supplied valid code

also, hopefully your dba candidate will recognize that the sample table design hold derived data that is not maintained by this trigger (ie oldquantity)

and hopefully you will have a way of determining if the dba can do dba-related tasks -- this is really a developer skill, although i would expect a dba to have be have an excellent grasp on it

;-{ mcs Received on Sun Mar 21 2004 - 05:58:30 CST

Original text of this message

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