Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2004
    Posts
    10

    Unanswered: Help! I am stuck on this code.

    Hi guys,

    I am writing a trigger for a table, I am not sure should i use table level or row level triggers, but it keeps popup error message like" Couldn't change new values for this type of trigger". I don't have idea why?

    My problem is to update two related prices once one of them is updates.
    I wrote:


    CREATE TRIGGER update_sell_price
    after UPDATE (of Buy_price) ON part for each row
    Declare
    newprice number;
    BEGIN
    select sell_price into newprice from part
    where ld.buy_price <>:new.buy_price;
    :new.sell_price: = myprice * :new.buy_price/ld.buy_price;
    END update_sell_price;
    /

    Could you help me clarify it? Thanks a lot!

  2. #2
    Join Date
    Apr 2004
    Location
    Europe->Sweden->Stockholm
    Posts
    71
    Quote Originally Posted by oldersea
    Hi guys,

    I am writing a trigger for a table, I am not sure should i use table level or row level triggers, but it keeps popup error message like" Couldn't change new values for this type of trigger". I don't have idea why?
    According to the MySQL Reference Manual:
    1.8.5.4 Stored Procedures and Triggers
    /.../ Triggers are scheduled for implementation in MySQL version 5.1.

    What version are you running?

  3. #3
    Join Date
    Apr 2004
    Posts
    10
    Thanks for you response!
    Actually I am a beginner in write SQL+ script and PL/SQL for a DBMS program.
    I am not sure about the version thing.

    But I think the basic syntex for the is similar?

    thanks!

  4. #4
    Join Date
    Apr 2004
    Location
    Europe->Sweden->Stockholm
    Posts
    71
    I thought that you were trying to use triggers in MySQL, and since they are not implemented yet (in a few years maybe), there are no correct syntax. The best thing you could do is to ask in the forum for the database server you are using. People in the MySQL forum is less likely to know much about triggers I think, because MySQL doesn't support them.

  5. #5
    Join Date
    Apr 2004
    Posts
    10
    Thanks! Snorp

Posting Permissions

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