Results 1 to 3 of 3

Thread: Trigger error

  1. #1
    Join Date
    Jan 2002
    Posts
    3

    Unanswered: Trigger error

    This is my trigger code and when I compile this..

    create trigger ins_uomconv_trig
    before insert or update on uom_conversion
    for each row

    begin
    Declare as_xml varchar2(255),as_from_uom varchar2(20),as_to_uom varchar2(20),as_tab_name varchar2(50),as_oper varchar2(20);

    as_from_uom = :new.from_uom;
    as_to_uom = :new.to_uom;
    as_tab_name := 'uom_conversion';
    as_oper := 'INSERT';
    as_xml := '<from_uom>'+:as_from_uom+'</from_uom>';
    as_xml := :as_xml+'<to_uom>'+:as_to_uom+'</to_uom>';
    end;
    /

    When I compile I get the following error.

    PLS-00103: Encountered the symbol "DECLARE" when expecting one of the following:

    begin function package pragma procedure subtype type use
    <an identifier> <a double-quoted delimited-identifier> cursor
    form current external language

    Where am I going wrong?

    Thanks

  2. #2
    Join Date
    Jan 2002
    Location
    Toronto
    Posts
    21
    it should be:

    CREATE OR REPLACE TRIGGER trigger_name
    before INSERT or UPDATE or DELETE on table_name
    FOR EACH ROW
    DECLARE
    your_variable integer;
    begin
    -- body of the trigger
    end;
    /

    Edward

  3. #3
    Join Date
    Jan 2002
    Posts
    3
    Thanks Edward. I want to know the difference between := and =: type of operators. Which one should I use to assign a value to a user defined var from the new.column_name

    Thanks

Posting Permissions

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