If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Help! I am stuck on this code.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-28-04, 00:24
oldersea oldersea is offline
Registered User
 
Join Date: Apr 2004
Posts: 10
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!
Reply With Quote
  #2 (permalink)  
Old 04-28-04, 00:44
snorp snorp is offline
Registered User
 
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?
Reply With Quote
  #3 (permalink)  
Old 04-28-04, 00:50
oldersea oldersea is offline
Registered User
 
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!
Reply With Quote
  #4 (permalink)  
Old 04-28-04, 00:56
snorp snorp is offline
Registered User
 
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.
Reply With Quote
  #5 (permalink)  
Old 04-28-04, 01:18
oldersea oldersea is offline
Registered User
 
Join Date: Apr 2004
Posts: 10
Thanks! Snorp
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On