Results 1 to 3 of 3

Thread: Triggers

  1. #1
    Join Date
    Feb 2005
    Location
    Barcelona
    Posts
    42

    Unanswered: Triggers



    CREATE OR REPLACE TRIGGER calcula_edad
    AFTER INSERT ON persons
    FOR EACH ROW
    BEGIN

    UPDATE birth SET age = YEAR(SYSDATE) - YEAR(:new.birth) WHERE code = (:new.code);

    END calcula_edad;

    17110 Warning

    Which is the problem?

    Thanks in advance.


  2. #2
    Join Date
    Jul 2003
    Posts
    2,296
    you possibly need a declare and the fact that YEAR is not a function?
    PHP Code:
    CREATE OR REPLACE TRIGGER calcula_edad
    AFTER INSERT ON persons
    FOR EACH ROW
    DECLARE
    BEGIN

      UPDATE birth 
      SET age 
    = (
        
    to_number(to_char(SYSDATE'YYYY') ) - 
        
    to_number(to_char(:new.birth'YYYY') )
                     )
      
    WHERE code = :new.code;

    END calcula_edad;

    - The_Duck
    you can lead someone to something but they will never learn anything ...

  3. #3
    Join Date
    Jan 2004
    Location
    Croatia, Europe
    Posts
    4,094
    Provided Answers: 4
    I agree with the fact Duck mentioned; however, I'd say that DECLARE isn't necessary as there's nothing to declare.

Posting Permissions

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