|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here! |
|
#1
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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
|
|
#3
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Raise application error trigger |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|