Procedural code automatically executed in response to a database event.

learn more… | top users | synonyms (1)

2
votes
1answer
10 views

Howto implement correctly Businness Logic in database

I'm searching about how to disable triggers, and seems like it's not possible under MariaDB. My problem is, how to manage then, when you import data. I have a database where almost all business logic ...
0
votes
1answer
117 views

MySQL Trigger Update

How do I update 'emailupdate' date with a trigger when 'email' is updated through a script? +------+----------------+--------------+ | id | email | emailupdate | +------+----------------+-...
1
vote
1answer
33 views

Prevent UPDATE TRIGGER to fire when no changes made in SYBASE

In Sybase I have a main table test and an audit table test_a. The audit table is updated by triggers on insert, update and delete. Now the issue is, when I use update query with old data (no changes), ...
2
votes
1answer
192 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
1answer
38 views

Assignment of a column with dynamic column name

I get the name of a column to set in a (BEFORE UPDATE) trigger, I want to set it to the OLD value and ignore anything coming in. I've tried the following: CREATE OR REPLACE FUNCTION ...
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
10 views

Create trigger that Find, Parse and Insert to another table After inserting on table

I want to create a trigger that will insert to another table after inserting on my table. Scenario: I will insert on my inbox table. Then, on my inbox table there is a field named Msg. Next, I want ...
1
vote
1answer
10 views

Mysql auto insert record in primary table if not exist

Is it possible to auto insert a record into the primary table if the record does not exist when adding a foreign key? For example, assume these tables: - user(id, name, age) - topic(id, name) - ...
0
votes
1answer
31 views

PostgreSQL use NEW in query for INSTEAD OF trigger

I'm having trouble getting an INSTEAD OF trigger to work correctly, and I think I've misunderstood how to use NEW. Consider the following simplified scenario: CREATE TABLE Product ( product_id ...
0
votes
2answers
24 views

How can I fetch parent table's value within a trigger?

I have a PARENT table and a CHILD table. PARENT ------ ID BIGINT PRIMARY KEY NAME VARCHAR(255) NOT NULL CHILD ----- ID BIGINT PRIMARY KEY NAME VARCHAR(255) NOT NULL PARENT_ID BIGINT NOT NULL I ...
3
votes
1answer
117 views

Trigger/Event that fires when a Transaction finishes

I have a query that pulls from about 15 different tables. I am looking to materialize this into a table that stores it in xml/json. (To improve performance.) The problem I have is that these tables ...
0
votes
1answer
653 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 ...
0
votes
0answers
10 views

Security of SQL Trigger Using dynamically stored table name

I'm working with PostgreSQL 9.0 and am learning how to use Triggers to enable some useful functionality. I have an insert trigger on a table that looks like this: feature_id | layer_name| latitude | ...
0
votes
1answer
36 views

Trigger to delete with cascade effects [closed]

Hi I am new to Oracle triggers. Your help will be much appreciated! I have the following 2 tables: Product: CREATE TABLE Product (prodId varchar(10) NOT NULL PRIMARY KEY, prodName varchar(30) ...
0
votes
1answer
128 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 ...
2
votes
1answer
188 views

Determe the command type in a DDL trigger / get names and datatypes of new columns

Given strings corresponding to DDL commands, how can I determine which DDL command (column addition, constraint addition etc.) it precisely is? I have a DDL trigger on a database that will be fired ...
0
votes
1answer
113 views

MySQL - Force replication to statement for INSERT to a table to fire trigger on slave

We have a PROD DB which replicates into a slave DB using mixed replication. We want to add a trigger so that a row is added to our DW when a row is INSERTed into table_a (on master). The issue is that ...
3
votes
2answers
12k views

Trigger to audit table changes

I have created a trigger to audit changes to a table: CREATE TRIGGER [dbo].[iudt_AutoAuditChanges] ON dbo.CPTCategoryMaster AFTER INSERT,DELETE,UPDATE AS BEGIN SET NOCOUNT ON; ...
1
vote
2answers
762 views

Tables accessed during last period

I want to check which tables have been updated during a given period, for instance in descending order of access time per table. How can I get that for PostgreSQL?
0
votes
0answers
14 views

Postgresql - How to use NEW in subquery?

I have a table that I want to update. I wanna use the NEW in my subquery where clause but error says, Missing from clause entry for table "new". Additional Info details table - serial, ...
3
votes
1answer
121 views

Enable MySQL trigger for all users in mysql

I have setup triggers in my MySQL tables and when I applied them they were restricted to the account I used when creating the triggers, now I have multiple users in my MySQL and I want it so that the ...
1
vote
1answer
42 views

TSQL 2012 deleted table in INSTEAD OF and AFTER triggers?

My colleague ask me very simple, but difficult for me question: If I have deleted table with 10 records in INSTEAD OF trigger and I delete 8 of them how many records will I have in deleted table in ...
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
118 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 ...
3
votes
2answers
43 views

Insert if something changed other than specific column

I have a table with many columns but my snippet is simplified. I have the trigger shown below but how can I have it so that nothing is inserted if only the created_at column has changed? ALTER ...
0
votes
1answer
339 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 ...
1
vote
0answers
25 views

Question about MySQL triggers performance [duplicate]

I currently have a database that stores some transactions for several users, for example purchasing or selling products is stored as 1 entry in the transactions table. It can also store profits made ...
0
votes
2answers
119 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 ...
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
65 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
39 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
248 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
399 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 ...
18
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
31 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
26 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
20 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
41 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
108 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
64 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 ...
1
vote
0answers
16 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
185 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 ...
-3
votes
2answers
924 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
42 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
40 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
16 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
91 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
154 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 ...
1
vote
2answers
70 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 ...