Procedural code automatically executed in response to a database event.

learn more… | top users | synonyms (1)

1
vote
1answer
124 views

MySQL After Update Trigger apparently not running

I have the following After Update trigger on a MySQL table: CREATE DEFINER = 'root'@'localhost' TRIGGER phpbb_rathermenacing.phpbb_bbdkp_memberlist_AUPD AFTER UPDATE ON ...
1
vote
0answers
36 views

PostgreSQL Partitioned table update trigger

I have a date-partitioned table (inheritance partitioninng just like the one pg_partman does) which is referenced by quite a few tables in my database. To resolve the FKs checking for referenced field ...
1
vote
0answers
33 views

Modify data using trigger

I have the following requirements in SQL server. I want to get updated/inserted values, edit it save to one column using SQL trigger. Say I have column named customer_name, when someone updates/...
0
votes
2answers
230 views

Logging the Execution times of dynamically constructed mysql stored procedures

I have a MySQL Server. The MySQL server contains a huge network data collection. The client API's will connect to the MySQL server and execute some dynamically created stored procedures and delete ...
2
votes
2answers
388 views

Java Spring application Database triggers auditing - how to provide the right user that made the change

We are developing a new web application. one of the most basic requirement is to audit all entities changes into a separate table. We would like to use DB triggers for that purpose. We use MySQL as ...
17
votes
4answers
2k views

How to limit maximum number of rows in a table to just 1

I have a configuration table in my SQL Server database and this table should only ever have one row. To help future developers understand this I'd like to prevent more than one row of data being added....
0
votes
1answer
29 views

Get previous field's value in MySQL trigger

I am using a MySQL database and I have this kind of table. IDRefHandler 1 x    299       2 x    300   &...
0
votes
0answers
23 views

trigger/trigger function to work on all column but 1

I need a trigger/trigger function to fire on all insert/updates for all changes in all columns but 1 if a user changes the value in that column, it is not significant and the trigger does not need to ...
0
votes
0answers
19 views

conditional trigger function for history table

I have a history table that tracks modifications to attributes/geometry for each layer I need to set a condition that if the attribute is 'Y' for the column "export" in the "span1" layer, the trigger ...
0
votes
0answers
34 views

Trigger to Get Last Row Value and Set

I have been having a problem with this one. Granted this is the first trigger I have ever made (pretty new to this). I think it's a formatting issue. I have a table called filleradown. I need for ...
6
votes
1answer
106 views

Retrieve logon trigger from backup

A logon trigger was added and dropped from our production database. I have full backup of master after the trigger was added, and before it was dropped. I am trying to recover from the backup but I ...
0
votes
1answer
1k views

Deadlock caused by INSERT trigger - thread looking for lock it already has?

Using MySQL 5.6.17. I have a table with an INSERT trigger that reads values from that table and 4 other tables, combines the results and writes that to a sixth table. Ever since I added this trigger, ...
0
votes
1answer
62 views

Reset value each year with a trigger

I want to set up a trigger which will increment a value (based on previous record). But this will also reset the value if the year of date_creation is different of the current year. ref  &...
3
votes
2answers
2k views

How to specify trigger execution order under PostgreSQL?

I'm using "classic" time-based partitioning using triggers. I have found a need for a separate trigger, which runs on the original table. CREATE TABLE twitter_interactions(...); CREATE OR REPLACE ...
2
votes
1answer
183 views

MySQL stored procedure updates twice

I have this stored procedure: DELIMITER $$ CREATE PROCEDURE updateTrendContentStats(IN mongoid VARCHAR(255),IN numericid INT,IN points INT,IN ctype INT,IN activity INT,IN created INT) BEGIN DECLARE ...
1
vote
0answers
13 views

Howto restore Trigger filesystem copy (*.TRG and *.TRN files) in addition to mysqldump?

We use mysqldump for backup (without Trigger/Events/Routines included). mysqldump --opt --flush-logs --single-transaction --ignore-table=mysql.event --all-databases The triggers we copy with cp to ...
2
votes
1answer
173 views

executing command prompt command in MySql trigger

I have one table called table1. In it there are two fields, let say field1 and field2. What I am trying to do is that, when there are records inserted into table1, the values of field1 and field2 get ...
0
votes
1answer
625 views

Oracle trigger error: table %s.%s is mutating, trigger/function may not see it

I am having some issues while trying to use triggers over tables where I need to get the reference of custom data type from a table. I can't seem to get it to work, here are the scripts I am using ...
-3
votes
2answers
860 views

UPDATE() Function (Insert and Update Triggers)

Is there a way to have the column name dynamic in this function? For example, passing a parameter to a variable named @FldName = 'Name'. e.g. UPDATE(@FldName). Basically, what I want to do is to have ...
1
vote
1answer
41 views

Use trigger to populate another column

I have two counters in a mysql table. I would like to have another column that contains the difference between counter column 1 and counter column 2. Could I use a trigger after counter column 2 is ...
1
vote
1answer
33 views

trigger to delete records with same value from another table after inserting record in another table

i have two tables normal and abnormal,i want to create a trigger that will be able to delete records from normal table once i insert the same details in the abnormal table for example if a person is ...
1
vote
0answers
14 views

How do you add data to a table dynamically from a trigger in T-SQL

I have a Uni assignment due, part of it requires this: "Create a database trigger called “TRG_PREVENT_VIEW_DROP” that will prevent the dropping of any view The trigger must log the action in a ...
3
votes
1answer
80 views

Creating SQL Server triggers to copy a record from one table and populate another

I want to create a trigger that will copy a record from one table and populate another after an insert or update. Users will enter a date in an inspection table and I want that date inserted or ...
3
votes
2answers
152 views

“Upsert” trigger writing mass duplicates from SSIS

I have a problem with an "upsert" trigger, being triggered by a SSIS package with fastload. (FIRE_TRIGGERS is enabled) CREATE TRIGGER [dbo].[MP_VOL_UPSERT] ON [dbo].[vwMP_VOL] INSTEAD OF ...
0
votes
1answer
122 views

Locking because of triggers mysql

I have a memory table and I am updating it somewhere around 3000 updates per second. I setup a another table in Innodb and then created a Trigger so that all data can be send to the innodb table as a ...
1
vote
2answers
62 views

Read only postgres table, except by trigger

Suppose the following situation: I have a product_stock table and a stock_transaction_log table. Currently whenever there is an increase/decrease in a product's stock, I update the product_stock ...
0
votes
1answer
31 views

MySQL Trigger Validate Before Insert [closed]

I am new to MySQL TRIGGER. I want to know is it possible to check before insert using last record found? Table AccountChecking ==================================================== || ID || ACID |...
4
votes
1answer
2k views

SQL Server: update trigger fires before insert trigger

I have an application with a SQL Server-hosted database. I do not have access to the application code, but I do have full access to the database. I have added my own custom auditing to a table to ...
0
votes
1answer
125 views

How to profile trigger database performance impact

I want to set up some triggers on a DB2 box (LUW, 9.7). The DBAs are concerned that if the trigger fires too often, it will adversely affect general performance. What's a reasonable cheap approach ...
0
votes
0answers
37 views

INSERT Trigger not inserting values

I have a table called tbemissoes. When there is an insert, I need to execute this procedure : create procedure exec pr_replicaRemessa --49 , 2016 @RemessaNumero int, @RemessaAno int AS Begin --...
1
vote
1answer
64 views

Composite Primary keys and auto increment?

i'm developing SaaS app with multi-tenancy, and i've decide to use single DB (MySQL Innodb for now) for client's data. I chose to use composite primary keys like PK(client_id, id). I have 2 ways here,...
0
votes
2answers
113 views

MySQL Trigger: Can you turn a query updating multiple columns to multiple queries where each update one column?

Here's what I'm trying to achieve: use a trigger to divide an update query which updates more than 1 columns into several update query and each of the query updates just 1 columns. For example, the ...
0
votes
0answers
13 views

Recursive Conditional trigger for insert in table MYSQL

user[ user_id, parent_user_id] user_id parent_user_id 1 null 2 1 3 1 4 1 5 1 user_assigned_role [user_assigned_role_id, role_id, ...
1
vote
1answer
31 views

MySQL trigger to update a key if record exists

I'm trying to build a trigger in MariaDB to follow this logic: 1. If the primary key val exists, increment the counter column 2. Else, insert the primary key into the table Here is my prosed ...
0
votes
0answers
18 views

Postgres: How to log materialized view refresh

I would like to keep a record of when various Postgres materialised views are refreshed. As far as I can see there are no built in logs. The next obvious choice is to create a trigger, however it ...
0
votes
0answers
45 views

Using a trigger to check whether a matching record exists

I have a database model set up as in the picture above, modelling a student's enrolment into a unit with an associative entity to facilitate the m:n relationship. I wish to code a trigger that will ...
0
votes
1answer
334 views

Update query in a trigger

I have a configuration table: Table: refdatecol - id int(11) startdatecol varchar(100) enddatecol varchar(100) datecolTable varchar(100) This table holds the user configured column names ...
2
votes
2answers
898 views

How to speed up audit trigger?

The task: write a trigger to log all updates within tbl1 table for future audit users' actions. The tbl1 table: id INT(11) y SMALLINT(6) country SMALLINT(6) -- really here ~20 fields but only some ...
1
vote
2answers
61 views

Trigger performance - UPDATE statement joining on INSERTED

I have a trigger (MS SQL Server) on TABLE_A that fires on an update that looks basically like the following (I've changed the names of the tables/trigger to simplify): CREATE TRIGGER [dbo].[...
1
vote
1answer
38 views

Copy a single record to a replica table before update using trigger (Oracle 12c)

I want to insert a complete record (before updating original record) to a replica table using trigger. Following are the sample tables: create table customer ( cID number, cName varchar2(30)...
1
vote
0answers
32 views

ORA-00604 (error occurred at recursive SQL level string) hides the real error

My multithreaded program inserts records into a table. ORA-00001 (unique constraint violated) should not be fatal. But prod environment has a complex configuration with read-only schema and the table ...
0
votes
0answers
10 views

How to get old and new values on Redis notification?

I need to implement a feature like: once any specific key in Redis is updated, call a C function with the old and new values as arguments. Currently, I know Redis notification and I could use ...
0
votes
1answer
35 views

Capture the Query Text of a DML Change

It may not be possible, but without doing a JOIN from the inserted/updated from the records coming in and adding them to an audit table column-by-column, is it possible to just capture the full DML ...
0
votes
0answers
34 views

MySQL: Calculations and Triggers across multiple tables

I'm new to sql and I'm having trouble with a calculation involving two of my tables. I have a table, payroll, which looks something like this: CREATE TABLE payroll ( id INT(6) UNSIGNED AUTO_INCREMENT ...
2
votes
1answer
75 views

MySQL running delete trigger on truncate

I have a table that has an on delete trigger that updates another table. THe table I'm trying to truncate has 130,000 rows. I have duplicate schema and data on my dev server as well as the client's ...
0
votes
1answer
111 views

MySQL - using result of Procedure in Trigger to Insert in new table

I'm guessing I'm doing something that's prohibited by MySQL, but can't see what. Basically, I have a set of tables that hold lists of things (item name, item types, item groups etc.), and I need to ...
1
vote
1answer
93 views

Oracle Triggers - before any UPDATE or DELETE or INSERT

I am trying to create a database trigger in Oracle SQL Developer that would fire before any UPDATE, DELETE, or INSERT statement occurs on the sessions table. My sessions table: CREATE TABLE sessions ...
0
votes
2answers
38 views

Is there a way to reference a column dynamically within a trigger?

I asked a similar question a few months back and I'm improving upon my solution! I have an Oracle database where I would like to trigger a procedure to do additional work on a column upon updating of ...
1
vote
2answers
3k views

Trouble with triggers and insert .. on duplicate key update

I have two tables with identical schemas. one is a "main" table that is pruned periodically and kept small. The other is a "reporting" table that is an archive of everything that ever was. For ...
0
votes
2answers
30 views

How to Add AFTER Delete Trigger in My case?

I am Making a Database Management System of Hospital in MySQL WorkBench, and i Want to Make a After Delete Trigger in my case. The scenario is i have two Tables 1) The Patients which are currently ...