Discussions
Categories
- 196.9K All Categories
- 2.2K Data
- 239 Big Data Appliance
- 1.9K Data Science
- 450.4K Databases
- 221.7K General Database Discussions
- 3.8K Java and JavaScript in the Database
- 31 Multilingual Engine
- 550 MySQL Community Space
- 478 NoSQL Database
- 7.9K Oracle Database Express Edition (XE)
- 3K ORDS, SODA & JSON in the Database
- 546 SQLcl
- 4K SQL Developer Data Modeler
- 187.1K SQL & PL/SQL
- 21.3K SQL Developer
- 295.9K Development
- 17 Developer Projects
- 138 Programming Languages
- 292.6K Development Tools
- 107 DevOps
- 3.1K QA/Testing
- 646K Java
- 28 Java Learning Subscription
- 37K Database Connectivity
- 155 Java Community Process
- 105 Java 25
- 22.1K Java APIs
- 138.1K Java Development Tools
- 165.3K Java EE (Java Enterprise Edition)
- 18 Java Essentials
- 160 Java 8 Questions
- 86K Java Programming
- 80 Java Puzzle Ball
- 65.1K New To Java
- 1.7K Training / Learning / Certification
- 13.8K Java HotSpot Virtual Machine
- 94.3K Java SE
- 13.8K Java Security
- 204 Java User Groups
- 24 JavaScript - Nashorn
- Programs
- 443 LiveLabs
- 38 Workshops
- 10.2K Software
- 6.7K Berkeley DB Family
- 3.5K JHeadstart
- 5.7K Other Languages
- 2.3K Chinese
- 171 Deutsche Oracle Community
- 1.1K Español
- 1.9K Japanese
- 232 Portuguese
Ayuda con Trigger

Estoy tratando de insertar en una tabla llamada cuotas, con este triggers, al momento que me realicen una inserción en la tabla transacciones
Answers
-
Hi
What is yout question please ?
-
1.See this:
CREATE OR REPLACE TRIGGER tr_ins_cuotas
BEFORE INSERT ON transacciones
FOR EACH ROW
...
SELECT ... FROM transacciones ...
Read about "Mutating-Table Restriction" in:
http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/triggers.htm#LNPLS759
2. ROLLBACK command will never be executed:
WHEN OTHERS THEN
RAISE_APPLICATION_ERROR ...
ROLLBACK;
END;
Replace with:
WHEN OTHERS THEN
ROLLBACK;
RAISE_APPLICATION_ERROR ...
END;
Regards,
Zlatko
-
Zlatko Sirotic wrote: Replace with
You can't rollback/commit in non-autonomous transaction a trigger. ROLLBACK must be removed.
SY.
-
Yes, of course.
I found two mistakes, and I did not see the third.
I have to start wearing glasses.
Or is it better to leave the Informatics and start to get involved in politics.
Regards,
Zlatko
-
i change all, but did´t works.... where is my error
CREATE OR REPLACE TRIGGER TR_INS_CUOTAS
AFTER INSERT ON transacciones
FOR EACH ROW
DECLARE
v_quincena NUMBER := 15;
v_mensual NUMBER := 1;
v_cuota NUMBER := 1;
v_montocuota NUMBER(18,4);
v_fechacuota DATE;
BEGIN
IF (:new.metodoplazos = 'D') THEN
v_fechacuota := :new.fecha + v_quincena;
v_montocuota := ((:new.monto * :new.tasa)/100)/2;
ELSIF (:new.metodoplazos = 'M') THEN
v_fechacuota = add_months(:new.fecha, -v_mensual)
v_montocuota = (:new.monto * :new.tasa)/100
END IF;
INSERT INTO cuotas (cuotaid, transaccionid, nocuota, montocuota, fechacuota)
VALUES (s_transacciones.NextVal, :new.transaccionid, v_cuota, v_montocuota, v_fechacuota);
END TR_INS_CUOTAS;
-
CREATE OR REPLACE
TRIGGER TR_INS_CUOTAS
AFTER INSERT
ON transacciones
FOR EACH ROW
DECLARE
v_quincena NUMBER := 15;
v_mensual NUMBER := 1;
v_cuota NUMBER := 1;
v_montocuota NUMBER(18,4);
v_fechacuota DATE;
BEGIN
IF :new.metodoplazos = 'D'
THEN
v_fechacuota := :new.fecha + v_quincena;
v_montocuota := ((:new.monto * :new.tasa)/100)/2;
ELSIF :new.metodoplazos = 'M'
THEN
v_fechacuota := add_months(:new.fecha, -v_mensual); -- missing colon and semi-colon
v_montocuota := (:new.monto * :new.tasa)/100; -- missing colon andsemi-colon
END IF;
INSERT
INTO cuotas(cuotaedid,transaccionid,nocuota,montocuota,fechacuota)
VALUES(s_transacciones.NextVal,:new.transaccionid,v_cuota,v_montocuota,v_fechacuota);
END TR_INS_CUOTAS;
/
SY.P.S. Are you sure sequence s_transactiones should be used for table cuotas?
-
THANKS FOR ALL, IT'S WORKING. I DIDN'T SEE THAT THE MISSING.