Procedural code automatically executed in response to a database event.

learn more… | top users | synonyms (1)

0
votes
1answer
46 views

mysql CREATE TRIGGER after insert on Update column with count

it gives error. I don't understand why. CREATE TRIGGER `estatecat_piece` AFTER INSERT ON `estate` FOR EACH ROW BEGIN UPDATE estate_category set piece = (Select count(*) from estate where estate....
1
vote
1answer
50 views

How to use trigger in VoltDB

As I know, trigger isn't supported in VoltDB. If anyone has updated news about trigger on VoltDB for nowadays, would you please let me know. So my question: is it possible to implement a trigger-...
0
votes
1answer
43 views

INSERT and UPDATE in Trigger

I have created a trigger so I could insert every row in a backup table CREATE OR REPLACE TRIGGER xyz AFTER INSERT ON table_1 REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN INSERT INTO table_2 (...
1
vote
1answer
63 views

Oracle: Query gives different answer when running from procedure

I guess my problem is somehow related with grant permissions. I have an "ADMIN" user, I grant it "dba" permissions like this: grant dba to admin Now in the "ADMIN" schema I have 2 tables: The ...
3
votes
1answer
47 views

How to maintain trees and their roots in SQLite

I have a (SQLite) database with a table representing nodes in a forest (set of trees): create table "Node" ( "id" Text primary key, "parent" Text references "Node" ("id") -- parent node ...
1
vote
1answer
52 views

Creating an Updating trigger

I have to create a trigger that calculate the the quantity in stock and this is my first one on PostgreSQL. When entering the quantity bought at a Provider (Fournisseur) or a delivery at a client, ...
0
votes
1answer
60 views

SQL Server Trigger When New Value <> Old Value

I need a trigger that update to Null a column averytime another column is changed. This is what I have now: ALTER TRIGGER [dbo].[ERROR_CLEAR] ON [dbo].[contact] AFTER UPDATE AS BEGIN SET NOCOUNT ON; ...
0
votes
1answer
53 views

using triggers to synchronize data

i've two database, Database1 and Database2! i'd like to synchronize data from the specific table of Database1 to Database2 whenever Database1 updates. I've used triggers to synchronise data and it ...
0
votes
1answer
63 views

Database design for a lot of rows with data archive

i'm new to database design on larger scale. I have some knowledge and experience with MySQL but now i have some performance issues. Currently i'm using MySQL with 3 databases: History Snapshot ...
0
votes
2answers
66 views

How to create an insert trigger?

This is 1/4 of an overall assignment and I need help with this part. The assignment question: Create a trigger on the Rental table that will check when a new rental is to be inserted, that the ...
0
votes
3answers
79 views

How to get currently inserted rows and sum them within Mysql trigger before insert

I have a mysql trigger that fires BEFORE INSERT. My php application is inserting multiple rows at once like so INSERT INTO table1(id,name,price) VALUES(1,'LH32400', 1990),(2,LH32401,2000); The idea ...
1
vote
2answers
59 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
39 views

Trigger with multiple inserts based on JSON data

I am using sqlite and have its json1 extension available. I have the following tables (reduced to a minimal example): -- table filled from external source, -- with only a little possible impact on ...
1
vote
1answer
26 views

Paged query against timestamp populated by trigger missing items

We're having a strange problem with a PostgreSQL 9.2 database that I've been racking my brain trying to figure out. First some background. We have a "tombstone" table that is populated using a ...
0
votes
1answer
50 views

Alternative of trigger to insert updated date in a column

I am looking for some best practice to insert the update date value in column whenever update query is run without using any trigger. So could anyone suggest me is there any best way except using ...
0
votes
1answer
99 views

How to commit transaction on an after update event trigger?

I'm new here in dba.stackexchange.com, so if I were to make any mistake, my apologies in advance. I kinda confused on how trigger work. So I have a trigger called updcredaccess on table A that ...
4
votes
1answer
91 views

Finding changed column values

Table 1 ID |COL2|COL3|COL4|COL5| ROW1| 1 | 1 | 1 | 1 | ROW2| 1 | 3 | 2 | 6 | ROW3| 1 | 1 | 1 | 1 | ROW4| 1 | 1 | 1 | 1 | ROW5| 1 | 1 | 1 | 1 | ROW6| 1 | 1 | 1 | 1 | Problem ...
0
votes
0answers
50 views

Query hung or way too long?

As part of the proccess of new items added to our system, some tables and relations are created programmaticaly via trigger, but it seems to be failing quite often right now. The DDL seems to be ...
0
votes
2answers
133 views

Can a trigger catch updates done by a select for update + lob.write()?

It's maybe a stupid question, but I didn't find an explicit answer... I want to catch any update on my oracle db, so I want to use triggers, but the triggers not been activated when using SELECT FOR ...
1
vote
4answers
63 views

User privileges error on server maria db Create trigger Drop trigger

User privileges error on server maria db User : user1 DB : db1 Error 15:00:46 DROP TRIGGER IF EXISTS audit_trigger Error Code: 1419. You do not have the SUPER privilege and binary logging ...
4
votes
1answer
128 views

How to use COLUMNS_UPDATED to check if any of certain columns are updated?

I have table with 42 columns and a trigger which should do some stuff when 38 of these columns are updated. So, I need to skip the logic if the rest 4 columns are changed. I can use UPDATE() function ...
6
votes
2answers
169 views

SQL Server using index scan instead of seek when updating a view that has an INSTEAD OF UPDATE trigger via a cursor

I have a 3rd party application which uses a cursor that updates rows in my SQL Server 2014 table. I am unable to modify this code and have therefore devised a scheme to point the cursor to a view ...
3
votes
0answers
31 views

Should I do the maths within PostgreSQL for ACIDity?

It is my first question on Database Administration Stack Exchange. Please be kind if something is not done the nice way.. I would like to be advised concerning the way I'm working on my database, in ...
0
votes
1answer
61 views

Set Field To Have Default Value Of Another

I am trying to create a trigger using the below syntax, however SSMS keeps barking at me with the below error. Msg 208, Level 16, State 4, Procedure test1, Line 1 Invalid object name 'data123'. ...
0
votes
1answer
19 views

InnoDB, Writing TRIGGER to INSERT into tables

Table1 "user_address" Field "u_id" Field "street_name" Field "locality_name" Table2 "street_master" Field "s_id" Field "s_name" I am supposed to write a trigger which BEFORE INSERT ON user_address(...
-2
votes
1answer
55 views

Trigger is not working in SQL Server 2012 on runtime? [closed]

In SQL Server 2012, I create two tables TABLE1 and TABLE2 After that, I created a trigger for TABLE1 Trigger name: PUSH_TABLE2 After creating the trigger PUSH_TABLE2, I test with below insert ...
2
votes
2answers
37 views

MySQL Trigger Query Not Deleting As Expected

I have a test database as shown below. If date is updated in tbl1, I would like for a trigger to fire that removes all entries from tbl2 where tbl1.host = tbl2.host2 AND tbl1.date = NEW.date. This is ...
2
votes
1answer
81 views

Inserting data into table in server B whenever table in server A gets updated

I want to synchronize data from table 1 in server A to tables 2 and 3 in server B, whenever table 1 gets updated. Tables from server A are not related to tables from server B, so I'd have to specify ...
1
vote
1answer
133 views

SQL Server Trigger does not update all table records

This is my first question so please go easy on me. We are using Access 2013 as a front-end and SQL Server 2012 with MS SQL Server Management Studio 11.0.2100.60 backend with ODBC connections. I am ...
1
vote
1answer
69 views

Trigger Not Updating

Do I have an issue with my syntax? I created this trigger as sometimes the sales personnel forget to input the sale date (I Know it should be automatically captured which is an update in progress) ...
1
vote
1answer
134 views

Can I emulate Oracle's autonomous transaction in MySQL?

I have a number of tables that have triggers on them that insert records in queueing and logging tables. The problem is that those inserts are then part of the same transaction. That means that any ...
1
vote
1answer
95 views

How to get value of last updated row from a table?

I want to insert the last updated row into a new table using a trigger? How to fetch that row if any of the column (value) from that table has been updated or changed? I am using this code: CREATE ...
0
votes
1answer
73 views

postgresql custom TEXT SEARCH CONFIGURATION with tsvector_update_trigger

I would like to use a custom text search configuration with tsvector_update_trigger to be able to update tsv field with french dictionary and unaccent. So I did that : CREATE TEXT SEARCH ...
0
votes
0answers
29 views

How to replicate SQL Server rowversion behaviour for some fields only

SQL Server version 10.50.4000. I have a table: create table people ( national_id char(16), full_name char(255), last_visited datetime ) I want to add a field that will work exactly ...
0
votes
0answers
20 views

Is automatic disabling of DML triggers possible during SSDT publish?

During ssdt deployment I am concerned about having DML triggers in place on tables that may slow down performance of table recreation a lot. We are facing the issue that the column order in the ...
0
votes
0answers
30 views

Backing up of database

I have a live MySQL DB and a Back up DB. What I would like to do is, once any changes are made to the live DB, the back up DB need to be immediately updated. I had thought about Triggers but the DB ...
1
vote
1answer
94 views

After Update/Insert trigger sometimes fails to do its job

I've got this trigger: CREATE OR REPLACE TRIGGER "DOKCENTRA"."INTDOC_AFTER" AFTER UPDATE OR INSERT ON "DOKCENTRA"."INT_DOC" FOR EACH ROW BEGIN IF UPDATING THEN IF ( :NEW.DOCNUMBER IS ...
0
votes
0answers
37 views

What is the Substitute of ALTER TRIGGER and CREATE or REPLACE TRIGGER in MySQL

I want to insert a new Question ID using trigger in MySQL table when I insert a new question in MySQL table from JSP page. Using Oracle this code will do the same thing but I don't know how to do this ...
0
votes
0answers
23 views

Is there a way to automatically set triggers to update a field that is computed as an aggregation of other fields?

Let's say that I have these tables: user, task, and submission. A user can create a submission which will be scored by the system, which will assign a value to submission.score. Now, everytime a ...
3
votes
2answers
76 views

Edit Application Name to Log Connection once for Logons on Pooled Connections

I am wondering if I can change the application name of a connection in SQL Server itself, e.g. in the logon trigger? Is that possible or is the application name "read only"? Edit to explain the ...
6
votes
1answer
269 views

Logon Trigger preventing any connection

I was testing a logon trigger to restrict connections to certain IPs. It looks like the trigger was not correct. Now I can't log in to the server even as SA. Is there a way to fix this?
4
votes
1answer
62 views

“TRUNCATE doesn't run ON DELETE trigger” true or false

I was searching on the topic of why TRUNCATE is placed in DDL instead of DML for which I found following answer here Why is truncate DDL? I this answer I found a sentence as given below "The fact ...
1
vote
1answer
142 views

Create MySQL trigger that updates position of each row when sorted by a specific field

Let's see an example, I've got this table that contains teams, each of them having a certain number of points: CREATE TABLE teams ( id INT(11) NOT NULL AUTO_INCREMENT, name VARCHAR(255) NOT NULL, ...
0
votes
0answers
54 views

How to add a trigger on table create in Mysql

I want to apply a trigger on all tables if my database. I already created a script in PHP which will add triggers in all existing tables. But if any new tables are added in database, I have to run ...
4
votes
1answer
52 views

Checking for fields not on SET clause on before update trigger on MySQL

I want to set a before update trigger that sets a column to a given value if an update query is done and that column has no new value on the set clause. The table I'm using. (Sort of) DROP TABLE IF ...
3
votes
1answer
52 views

Set the Priority for two different “after insert” triggers in SQL Server

I'm trying to create triggers by functionality,instead of DML operation. For exp,I have 2 triggers A and B. A is for "AFTER insert, update , DELETE" , and B is for "AFTER INSERT". how can I know ...
1
vote
1answer
46 views

Trigger for removing group with no users left in

I have three tables: USERS, GROUPS, and GROUP_MEMBERSHIP CREATE TABLE USERS ( ID BIGSERIAL NOT NULL, NICKNAME VARCHAR(20) NOT NULL constraint USER_EXISTS UNIQUE, PRIMARY KEY (ID) ); CREATE TABLE ...
0
votes
0answers
27 views

MySQL Trigger Replication between Master and Slave

we are running a rather highly loaded MySQL Application replicating between Master and two Slave instances. We are using Statement-based replication. Recently, we have upgraded our hardware and a ...
5
votes
2answers
155 views

Trigger to create symmetrical rows

I've got a table that describes some relation between two items. The items are referenced by ID. I'd like to create a trigger, so whenever you create a row (a,b), a symmetrical row (b,a) is created. I'...
1
vote
2answers
77 views

Serialize :new in trigger

I have a trigger that needs to create an Oracle Advanced queue message. The payload of that message should contain the new record that was created, that is accessible via :new. What I am looking for ...