Questions tagged [database-trigger]

A database trigger is procedural code written in the current database DML, that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database.

A database trigger is procedural code written in the current database , that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database.

1659 questions
0
votes
1 answer

MySQL How to reset the field to old value that has a trigger when the trigger fails?

I have a field called currentItem , this field has a trigger that calls a stored procedure (with transaction) sp_TransferData to perform some transfers of information to a worktable. If the stored procedure fails - I would like to restore the old…
Ken
  • 2,518
  • 2
  • 27
  • 35
0
votes
1 answer

Can I use a trigger to add combinations of foreign keys?

I'm in the situation where I want to do multiples inserts on a table with a trigger after insert. Here the python code to understand the objective first: d = dict() d["Table1"] = ["1", "2"] d["Table2"] = ["A","B"] from itertools import…
0
votes
0 answers

UDF on DB2 invoked in a trigger

In my application, I need a Java process to run by a trigger-- whenever a change has been made to field dateLastChanged of TrackTable, that process should fire. I followed through these steps for this: 1.) compiled the following code: public class…
0
votes
1 answer

How to solve the Oracle DB trigger error?

I wrote a DB trigger to monitor an insert action. After inserting a new record, I would like to automatically set the CREATION_DATE to sysdate. I get an error when I want to insert a new record: error ORA-04091: table REPORT is mutating,…
de li
  • 882
  • 1
  • 13
  • 25
0
votes
2 answers

MySQL trigger: conditional insert syntax error

I have two tables: Person and Student. I am trying to write a trigger which, after inserting a new person, inserts into the student table if the person is less than 18 years old. Here is the code of the trigger: CREATE TRIGGER test_trigger AFTER…
Eutherpy
  • 4,471
  • 7
  • 40
  • 64
0
votes
2 answers

How to write a DB2 function for a Linux shell script

I have a trigger on one of the DB2 tables. What i need is, every time that trigger runs, it should invoke a Linux shell script. How to do this-- same as any other process? If my trigger was to invoke a Java process instead of a shell script,…
user6401178
  • 183
  • 2
  • 11
0
votes
1 answer

SQL Trigger doesn't work (based on schedule)

I want to create a trigger that will allow insert to execute on work hourse (Mon to Fri from 9 am to 5 pm). I currently have this CREATE DEFINER=`root`@`localhost` TRIGGER `noWorkHour` BEFORE INSERT ON `empleado` FOR EACH ROW BEGIN IF…
0
votes
0 answers

Oracle triggers not firing

I have one problem with my trigger; they are getting fire on DDL statement on the tables applied. I could see the data being inserted and updated in the tables which I have applied but no data in the log tables. For example: ADDRESS is one sample…
Avinash.Byalihal
  • 137
  • 2
  • 7
  • 22
0
votes
1 answer

SQL Server trigger: how to increase column's value in table when another table's column value increased?

Table component: Table material: How can I write a trigger to decrease the material_quantity value in the material table when component_quantity is increased? By the way the component is made from material so when one component's quantity is…
zhiyuan
  • 23
  • 5
0
votes
1 answer

Multiple commands in a Trigger (Update multiple columns with different conditions)

I have an issue which i'm hoping someone out there will be able to assist. I'm trying to write a trigger which takes the datetime stamp and puts just the date into a new column. But likewise, also if a value in a different column is equal to x,…
C Davies
  • 21
  • 2
0
votes
0 answers

Audit/log table cleanup - Adding the missing columns

I have data tables and respective log tables which will capture all the CRUD transactions entered in the data tables using triggers. For example: Address data table ------------------ Address1 Address2 City Country Zipcode Address log…
Avinash.Byalihal
  • 137
  • 2
  • 7
  • 22
0
votes
1 answer

Dynamically assign trigger name postgresql

Hi I have a Registra_cambios () function; which want to assign to all tables in my database, I wonder if you can concatenate the trigger name with the record (table name) my cursor to not have the same trigger name on all tables create trigger…
Dev. Joel
  • 1,127
  • 1
  • 9
  • 14
0
votes
1 answer

SQL trigger to check previous value

I have a trigger on table tblA if the status is closed it inserts a record to table tblB. The below code is working, but I want it to be executed only if the previous status was NOT closed. How can I check it? ON tblA AFTER UPDATE AS BEGIN SET…
fishmong3r
  • 1,414
  • 4
  • 24
  • 51
0
votes
3 answers

DECLARE not working in MYSQL TRIGGER

this is my first trigger and my very first pl/sql code. the variable declaration in the following trigger is not working and I can not check for the other errors. [CREATE TRIGGER insert_rollno BEFORE INSERT ON exam_candidate FOR EACH ROW BEGIN …
Asif Ahmed
  • 93
  • 1
  • 8
0
votes
1 answer

Oracle trigger before and after insert

Is it possible to create only one trigger in Oracle that fires before and after data got inserted into a table? begin if inserting THEN -- This code should be run before insertion: :new.cr_timestamp := SYSTIMESTAMP; IF :NEW.id IS NULL…
ZerOne
  • 1,296
  • 6
  • 20
  • 40