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:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old May 14th, 2004, 05:35 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
Cool Raise application error trigger

Hello All,

I have the following quesions about this trigger!

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
  #2  
Old June 17th, 2004, 01:06 AM
astrocanis astrocanis is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2004
Posts: 14 astrocanis User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via AIM to astrocanis
every statement must have a semi-colon as a terminator. DECLARE and BEGIN do not as they are considered complete with and END; statement. END IF must also be followed by a semi-colon

Reply With Quote
  #3  
Old June 17th, 2004, 07:42 AM
jim mcnamara jim mcnamara is offline
......@.........
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jun 2004
Posts: 1,307 jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level)jim mcnamara User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 1 Week 3 Days 4 h 28 m 57 sec
Reputation Power: 48
Code:
CREATE OR REPLACE 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');
END IF; 
END;


You need permissions, plus you may also have grant permissions. Ask your DBA for help.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Raise application error trigger


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