Results 1 to 8 of 8

Thread: Trigger Error

  1. #1
    Join Date
    Feb 2008
    Posts
    4

    Unanswered: Trigger Error

    Hi guys , thanks for all those who helped in my previous question, i have a trigger which keeps giving me an error, basically i want it to fire when my stock level is low, this is what i get from oracle, i dont know where i'm going wrong. .


    SQL> CREATE OR REPLACE TRIGGER LOW_STOCK
    2 AFTER INSERT OR UPDATE OF STOCK_LEVEL ON STOCK
    3 FOR EACH ROW
    4
    5
    6
    7 BEGIN
    8 WHEN(NEW.STOCK_LEVEL<= OLD.STOCK_MINLEVEL);
    9
    10 DBMS_OUPUT.PUT_LINE('STOCK LEVEL IS LOW PLEASE REORDER
    11
    12 END LOW_STOCK;
    13 /

    Warning: Trigger created with compilation errors.

    SQL> SHOW ERROR
    Errors for TRIGGER LOW_STOCK:

    LINE/COL ERROR
    -------- ------------------------------------------------------
    2/5 PLS-00103: Encountered the symbol "WHEN" when expectin
    the following:
    begin case declare exit for goto if loop mod null prag
    raise return select update while with <an identifier>
    <a double-quoted delimited-identifier> <a bind variabl
    close current delete fetch lock insert open rollback
    savepoint set sql execute commit forall merge pipe

  2. #2
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    Well, there's nothing we can do about it; we can't read documentation instead of you. As this is an ordinary syntax error which is the result of wrong use of the CREATE TRIGGER statement, go to the nearest Oracle documentation page and learn how to properly use it.

    By the way, shame on you! You should have already done it!

  3. #3
    Join Date
    Feb 2008
    Posts
    4
    i'm just learnming littlefoot, i'm not a pro like you , take it easy

  4. #4
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    True, not everyone learns the same way. Someone reads the documentation, while the others do it using the "trial and error" (or, if you wish, "guess and check") method.

    While the first one usually brings the result, the second one is time consuming and doesn't guarantee that you'll ever manage to guess the correct syntax.

    So, if you decided to do it by guessing, no problem. Happy hunting!

  5. #5
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    I have received a private message from greatguy112, which says that he can not find it in the documentation and requests spoonfeeding solution. Unfortunately, greatguy112, I can not solve your (or anyone else's) problems via private messages; we can, though, discuss it in public.

    This is the CREATE TRIGGER Oracle 10g document, and here's a hint: the error says that the WHEN keyword was found on an unexpected position.

    Now open documentation, use your browser's "search" facility and search through the document for all appearances of the WHEN keyword. I believe you'll manage to find the solution by yourself. Actually, I expect you to find it. If you don't, oh boy, you're in deep trouble. Why? Because this problem is really not a problem, it just requires you to be capable of reading and understanding what you've read. And if you are incapable of doing that ...

  6. #6
    Join Date
    Dec 2008
    Posts
    99
    Quote Originally Posted by Littlefoot
    I have received a private message from greatguy112, which says that he can not find it in the documentation and requests spoonfeeding solution. Unfortunately, greatguy112, I can not solve your (or anyone else's) problems via private messages; we can, though, discuss it in public.

    This is the CREATE TRIGGER Oracle 10g document, and here's a hint: the error says that the WHEN keyword was found on an unexpected position.

    Now open documentation, use your browser's "search" facility and search through the document for all appearances of the WHEN keyword. I believe you'll manage to find the solution by yourself. Actually, I expect you to find it. If you don't, oh boy, you're in deep trouble. Why? Because this problem is really not a problem, it just requires you to be capable of reading and understanding what you've read. And if you are incapable of doing that ...

    Hi,
    I just saw this thread,Littlefoot you are right but blaming or offending is further.I think he didnot search google for trigger examples.He must search try few examples and if then he cannot solve we can help him.as you helped me in other thread
    Thanks

  7. #7
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    I have never said that we will not provide help when necessary.

    This particular problem is a matter of reading the documentation; nothing more, nothing less.

  8. #8
    Join Date
    Dec 2008
    Posts
    99
    Quote Originally Posted by Littlefoot
    I have never said that we will not provide help when necessary.

    This particular problem is a matter of reading the documentation; nothing more, nothing less.
    I agree on it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •