Procedural code automatically executed in response to a database event.

learn more… | top users | synonyms (1)

0
votes
0answers
9 views

Is it possible to replicate a trigger but prevent it from running during synchronisation?

We are using SQL Server 2008r2 as the publisher and Express editions as subscribers, with merge replication and pull subscriptions. A replicated table has an update timestamp, as a datetime column. ...
0
votes
1answer
15 views

What is the use of the select statement in SQL(ite) triggers?

In SQLite, triggers may contain four types of statements: insert, update, delete, and select. What is the use of the select statement, namely, how can I access the result-set of the select statement? ...
1
vote
3answers
61 views

SQL trigger when a row is updated question

My problem is as follows. I an creating a MySQL database for a company that whenever a row is updated on the DB i want to have a trigger that calls a cURL request to transfer the updated information ...
0
votes
0answers
15 views

MySQL Schema Design: One Possible Values Between Multiple Columns

I'm working on a schema for a MySQL database. I have tables which are derivatives of one another. For example, rather than a single "animals" table, I might have separate "mammals" and "birds" tables: ...
1
vote
1answer
20 views

MySQL “CREATE TABLE LIKE” include triggers

I'm using MySQL 5.6 (5.6.29-76.2-56-log Percona XtraDB Cluster) When I issue a CREATE TABLE LIKE the triggers on the tables are not copied - is it possible to get them on the new table as well?
0
votes
0answers
17 views

Trigger not working error column “G:\Work Orders\Work Orders” does not exist [on hold]

PSQL 9.5, OS Win7 Using information I gained from; Set a column's default value to the concatenation of two other columns' values? I built a trigger that is suppose to create a hyperlink in ...
0
votes
1answer
34 views

Default Value Of Table

In my example syntax below I want the field delayed to be the difference in days between gotitdate and dunitdate I know that this syntax will get me the result, and I was going to set this up as an ...
4
votes
2answers
35 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
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
12 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) - ...
1
vote
1answer
40 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
34 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 ...
0
votes
0answers
11 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) ...
1
vote
1answer
35 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), ...
0
votes
0answers
15 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, ...
1
vote
1answer
43 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 ...
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 ...
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 ...
1
vote
0answers
69 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
40 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
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
21 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 ...
18
votes
4answers
3k 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
0answers
45 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 ...
0
votes
1answer
66 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  &...
1
vote
0answers
17 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 ...
1
vote
1answer
43 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
42 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
97 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 ...
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 ...
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 ...
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
1answer
42 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 |...
0
votes
0answers
16 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
39 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
23 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 ...
1
vote
1answer
66 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,...
1
vote
2answers
74 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
0answers
65 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 ...
1
vote
1answer
52 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)...
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 --...
0
votes
0answers
16 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
0answers
38 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 ...
1
vote
1answer
104 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
34 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 ...
0
votes
1answer
36 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 ...