Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 10th, 2004, 04:08 AM
macuser55 macuser55 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 19 macuser55 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Trigger Prob.

Hello All

I have used the trigger suggested as follows (removing new):

CREATE TRIGGER oTrigger AFTER UPDATE ON orders
FOR EACH ROW
BEGIN
IF (paymentStatus IS NOT NULL AND deliveryStatus IS NOT NULL)
INSERT INTO storedAt VALUES (PID, WID, Number)
END IF
END

The problem is that I get the following error after updating the table:
" User.Otrigger is invalid and failed re-validation". No change is made to the database.

I wish the variables paymentStatus, deliverystatus, PID, WID, and Number to be from the updated tuple only.

Any help is appreciated.

Thanks

Chris

Reply With Quote
  #2  
Old May 10th, 2004, 07:19 AM
dhananjayshetty dhananjayshetty is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 24 dhananjayshetty User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 33 m 16 sec
Reputation Power: 0
trigger prob.

hi there ,

instead of using after update trigger why don't you use before update trigger...

the trigger will work this way, it will check the two columns .if they satisfy your condition then only it will perform the update part.

Last edited by dhananjayshetty : May 10th, 2004 at 07:21 AM.

Reply With Quote
  #3  
Old May 10th, 2004, 03:42 PM
shammat shammat is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Munich, Bavaria
Posts: 996 shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level)shammat User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 4 h 55 m 48 sec
Reputation Power: 66
You should have read my example more closely

Instead of

IF (paymentStatus IS NOT NULL AND deliveryStatus IS NOT NULL)

you have to write:

IF (new.paymentStatus IS NOT NULL AND new.deliveryStatus IS NOT NULL)

Reply With Quote
  #4  
Old May 12th, 2004, 02:49 AM
macuser55 macuser55 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 19 macuser55 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Another Trigger

Thanks for all the help. I abandoned that trigger as the tasks I needed to complete were to complicated to put in a trigger.

I am trying to create a simpler trigger though.... This would have to be about as easy as I could do.

When I add a tuple to product through:

INSERT INTO PRODUCT VALUES (pid, wid, name);

I want a tuple to automatically be added to STOREDAT like:

INSERT INTO STOREDAT VALUES (pid, wid, 0);

This is my trigger, which causes validation error:

CREATE TRIGGER pInsert_T AFTER INSERT ON product
FOR EACH ROW
BEGIN
INSERT INTO storedAt VALUES (new.PID, new.WID, 0)
END;

What is wrong here?

Thanks

Chris

Reply With Quote
  #5  
Old May 12th, 2004, 02:05 PM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
use colon (:) with new, like this

INSERT INTO storedAt VALUES (:new.PID, :new.WID, 0);

Reply With Quote
  #6  
Old May 13th, 2004, 04:53 AM
macuser55 macuser55 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 19 macuser55 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Cheers for that,

I'm understanding the concept of new, old, and how the triggers work now.

String orderT = "CREATE TRIGGER orderT BEFORE UPDATE ON orders " +
"FOR EACH ROW " +
"BEGIN " +
"IF (deliveryStatus = 'paid' AND paymentStatus = 'paid') THEN " +
"RAISE_APPLICATION_ERROR(-20000, 'A completed order cannot be updated') " +
"END IF " +
"END";

This is my trigger in the form of a Java string. Do i have to embed any semi colons in it?

Here is my trigger in a more easy to read form. Of course, it does not work. Triggers are the most annoying thing I have come across!

CREATE TRIGGER orderT BEFORE UPDATE ON orders
FOR EACH ROW
BEGIN
IF (deliveryStatus = 'delivered' AND paymentStatus = 'paid') THEN
RAISE_APPLICATION_ERROR(-20000, 'A completed order cannot be updated') <--- WOULD I HAVE TO PUT A ; HERE?
END IF
END

Also, does anyone know why I get a validation error with this one?

The purpose of this trigger it to prevent modifications being made to an order tuple if deliveryStatus = delivered and paymentStatus = paid in that tuple.

Thanks

Chris

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Trigger Prob.


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway