Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2002
    Posts
    77

    Unanswered: Trigger creation

    I created the following trigger:


    create or repalce trigger checkdate
    before insert or update of startdate on scheduledclasses
    for each row


    declare

    vdate date;



    begin

    vdate := add_months(SYSDATE,3);

    if :NEW.startdate > vdate then

    raise_Application_Error(-20001, 'Cannot schedule a course more than 3 months in advance');

    end if;


    end;

    But I get the following error

    SP2-0552: Bind variable "NEW" not declared.




    I can't seem to find the problem, I thought I could use the predefined variable :NEW. Could you guys help me out. thanks

  2. #2
    Join Date
    Feb 2001
    Location
    NC, USA
    Posts
    200

    Re: Trigger creation

    Try this
    Code:
    
    CREATE OR REPLACE TRIGGER CHECKDATE
     BEFORE 
     INSERT OR UPDATE
     ON SCHEDULEDCLASSES
     FOR EACH ROW 
    declare 
        vdate date; 
    begin 
        vdate := add_months(SYSDATE,3); 
        if :NEW.startdate > vdate then 
            raise_Application_Error(-20001, 
              'Cannot schedule a course more than 3 months in advance'); 
        end if; 
    end;
    /
    You made just one little typo in the 'replace' word. Not a very helpful error message though.

  3. #3
    Join Date
    Jan 2002
    Posts
    77

    ooops

    Mispelled replace, thanks paul.

Posting Permissions

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