Procedural code automatically executed in response to a database event.

learn more… | top users | synonyms (1)

1
vote
1answer
346 views

Can Execute trigger in SQL Server 2008 R2

I'm trying to create a simple trigger to update a table's column after it was inserted. But when I execute the trigger it produces an error: Cannot execute script. Additional information: Unable ...
0
votes
1answer
72 views

how to use trigger to make SQL Job's step success or fail

Step 1. Call a script to trigger application process. When the application process start, it will insert a record to a specific table. And once the process ends, that record will be deleted from ...
0
votes
1answer
333 views

trigger - Sql2008 - Msg 7391 - “no transaction is active/unable to begin trans”

I have a trigger on my SqlServer, located in server7. It inserts a data on another server ( server5 ), after insert, as you see the code below: CREATETRIGGER [dbo].[trgSPTInsereDepartamento] ON ...
0
votes
1answer
33 views

Can I fail the current transaction from within a trigger?

Table DDL: CREATE TABLE trigtest(a INTEGER IDENTITY(1,1) PRIMARY KEY, b INT) I currently have CREATE TRIGGER MaxDelete ON trigtest INSTEAD OF DELETE AS IF @@rowcount < 1000 DELETE trigtest ...
0
votes
0answers
15 views

getting an error in trigger while invoking a procedure in it

i have created a procedure name 'prd' which contains 3 parameters (pmat_amt,pstartdate,pstopdate) which is used to update a column in the table rd_details contains 3 columns which are ...
1
vote
1answer
62 views

Trigger AFTER INSERT on tables with different columns

I'm writing a trigger that works after an insert. This is what I have: create trigger trgInsereQuestao on tblquestaoOpcao after insert as begin set nocount on; insert into ...
1
vote
1answer
189 views

UPDATE/INSERT into Dynamic Columns

I am trying to update columns based on the value of the inserted column of the table 'my_table'. I want to be able to record the timestamp of the values changed. I am using the triggers but I can't ...
0
votes
0answers
34 views

MySQL : How to know if Trigger was fired

Someone can help me please , I want to log error about triggers in MySQL 5.5 I'll like to know if it's possible to know if a trigger was'nt fired ?
0
votes
0answers
50 views

Did this trigger break replication?

I added a trigger to a replicated database. DELIMITER $$ USE `database`$$ DROP TRIGGER /*!50032 IF EXISTS */ `some_ins_after`$$ CREATE /*!50017 DEFINER = 'user'@'%' */ TRIGGER ...
1
vote
0answers
41 views

How to set the trigger when field(contain json value) is updated?

I have one table in which there is one field called info.This field hold json value. I want to create trigger on this field.I want to split this json format string into record I mean I want to insert ...
0
votes
1answer
280 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
0answers
47 views

mysql trigger, let trigger recalculate throug whole table after correction of errors

Raised this question before but no answer found I have one table (table1) with energy data updated every 5 min I am using a trigger to calculate day values on every update and fill another table ...
0
votes
2answers
309 views

Error in trigger: table X is mutating, trigger/function may not see it

Having looked at the following Trigger, still getting the Row 2 error: "ORA-04091: table SUMMITTEST.APL_LOG is mutating, trigger/function may not see it" Please can anyone provide any help in ...
0
votes
0answers
54 views

how to update 'update trigger fired record's column?

I'm new on this task. I tried to update when I/F table insert after trigger. but it wasn't work.. There is my trigger source like.. create trigger T_ATABLE_I after insert on ATABLE for each row ...
1
vote
0answers
25 views

Error when creating Trigger (PostgreSQL 9.4)

I created a table 'Company', and I want to create a trigger so a company can only present in one city, but it can be present in several different cities in the same country. For example, there's only ...
2
votes
0answers
92 views

Oracle instead of trigger update performance issue

I have a large table containing over 15million records with 4 columns that form a compound key. Because we use a development environment that doesn't support compound keys I was required to create a ...
1
vote
0answers
55 views

Make the SQL Database manage CRUD operations

Is it possible to have a client app send a transaction of INSERTs to a table. Then have the table triggered somehow to run through the inserts and either INSERT the row or UPDATE an existing row? If ...
0
votes
1answer
58 views

Alter trigger Oracle

Does alter trigger hang if a table is locked by some DML operation ? What kind of exception does it throw? Resource busy 0054 or some other exception...? I have tried to reproduce this scenario but ...
0
votes
1answer
73 views

Using dynamic database name for DML in trigger

I am using SQL Server 2008 in my application. Here I need to do database operations between multiple databases. The complexity is database names are user defined except one masster database. I can ...
2
votes
1answer
326 views

Subquery returned more than 1 value. This is not permitted + Trigger Error SQL Server

This trigger will update Is_Confidential_or_VIP column to 1 or 0 based on the text inserted or updated into ConfidentialRegistrationFlag and VIPType columns : create trigger ...
0
votes
2answers
49 views

Error in setting a value in sql server trigger [closed]

I'm trying to make a trigger that checks which staff member have the least amount of assigned tasks, before adding the task, and assign it to that member. What I came up with was something like this: ...
1
vote
1answer
231 views

Insert rows in a table, via a row-level trigger, activated after insertion in that same table

I have to design a schema and trigger system in SQL that will save words and their synonyms. I thought of this basic schema: create table words ( id int primary key auto_increment, word ...
1
vote
1answer
41 views

Trigger that records values for 5 columns from 3 tables when a value for column Z in table 3 is of a certain value

I am new to triggers and SQL in general. Sorry in advance if this forum is only for experts and this is a newbie question... I need to create a trigger that fires when someone tries to submit a ...
2
votes
1answer
231 views

Why can't trigger be dropped from database?

One of the databases I manage is provided by my company's vendor which we restore in order to pull data out for our data warehouse. I'm writing a stored procedure to go through the database users and ...
0
votes
1answer
81 views

MySQL error #1064 while creating a trigger [closed]

DELIMITER $$ DROP TRIGGER IF EXISTS brandRep $$ CREATE TRIGGER brandRep AFTER UPDATE ON sales_flat_order FOR EACH ROW BEGIN IF (NEW.status <> OLD.status AND OLD.applied_rule_ids <=> ...
0
votes
2answers
267 views

insert inserted id to another table

Here's the scenario: create table a ( id serial primary key, val text ); create table b ( id serial primary key, a_id integer references a(id) ); create rule a_inserted as on insert to a do ...
0
votes
1answer
25 views

Update Trigger in MYSQL

Here is my requirement :- I have a table called "users" and field called "Admin". Field "id" is primary key. Wants to update "Admin" field to "1" if id=1000; Tried this ,but not working.I tried ...
1
vote
1answer
143 views

How to retreive deleted records in a trigger on a table with composite primary key

I am trying to optimize a trigger on a table in a database from a 3rd party. I am not allowed to change or add any columns to the schema. The table has a composite primary key, one column is an ...
0
votes
1answer
822 views

Trigger syntax on phpmyadmin

I can't make this work. I want to create a trigger that deletes the child foreign keys before I delete the parent primary key. This is the code that I am using on phpmyadmin: delimiter // CREATE ...
1
vote
1answer
70 views

XACT_ABORT OFF vs COMMIT in trigger

I have a trigger on a table that kicks off several other processes. However, I would like to ensure that even if the other processes fail, the insert is successfully committed to the original table. ...
-1
votes
1answer
57 views

what is the syntax for insert trigger?

I am very new to sql. feel a little stupid to ask this question Say I have this table Warehouse(shipperid, name , state). Then I define another table warehouse_maine (shipperid, name, state) which ...
0
votes
1answer
96 views

SQL Server 2012 Replication, how to ignore action with specific trigger?

SQL Server 2012. Database is in merge replication, no conflicts presented. Current example is simply for understanding, but real schema is very huge to describe. Schema and trigger at SQLFiddle for ...
0
votes
1answer
120 views

PostgreSQL - retrieving max primary key column to insert a new row - any alternatives?

We are using a software that needs to request the max primary key column value to add a new row into the table that was requested. I know that there are some alternatives like: Sequences, and GUIDs ...
2
votes
0answers
60 views

Prevent row from being inserted with a trigger

I'm trying to prevent a row being inserted if a certain condition is met using a trigger. I'm using a user defined exception to do this, however the row is still being inserted, despite the exception ...
1
vote
1answer
76 views

MySQL: Adding an IF condition to trigger?

We've got a trigger that is overwriting the uuid value before insert. The vers.1 of our API depended on the DB to generate the UUID's, but I'm writing v2 which is using a library that generates the ...
0
votes
1answer
56 views

why is my trigger called even when the underlying table didn't change?

I have a quite basic trigger defined as such: CREATE TRIGGER dbo.foo ON dbo.bar FOR INSERT, UPDATE, DELETE AS ... I also have a stored procedure which at some point does something like this: ...
1
vote
1answer
68 views

MySQL created_by or updated_last-by [closed]

I've been giving the task of taking SQL DDL from data modeler and to transcribe it into mySQL for an internship. The only thing I cannot figure out is how to take Created_By VARCHAR2(30) DEFAULT ...
2
votes
4answers
246 views

Getting new and updated data with an archive column

I am trying to optimize an SSIS package that retrieves data from a very large transaction table that gets millions of new records daily. The data is being collected from several hundred field servers ...
0
votes
2answers
61 views

SQL Server De-duplication Trigger

I have a table that contains columns of Country, City, Location, Description. Due to the size of the description field it's not possible to bind the four fields into a composite key to prevent ...
1
vote
1answer
103 views

how to define trigger scope variable [closed]

My trigger is meant to calcalute the grade of a student base on the column value for every insert.But if a column value for the column is modified it the corresponding Grade should change. Currently i ...
1
vote
1answer
140 views

Can I trigger events based on timestamp data or should I use polling?

I'm asking this question for SQL Server 2008+ but this could really be for any DBMS. Imagine you have scheduled data, something like: ID Data Timestamp 0 NULL 2014-11-22 1 ... ...
1
vote
2answers
37 views

Schema/Structure to handle secondary computed data

I'm trying to design a LAMP-based website for my pinball league, which plays competitive pinball every week in match play. One of the features of our league is that we convert raw scores to ...
0
votes
2answers
995 views

How to update a column with values from the same newly inserted row on a SQL Server 2014 trigger?

Using SQL Server 2014, I have this: Table1 Tab1_id int identity(1,1) primary key Tab1_val1 smallint Tab1_val2 smallint Tab1_valInfo varchar(10) -- not yet implemented, will be used ...
0
votes
1answer
85 views

Triggering a shell script from MySQL without any 3rd party libraries

Is it possible to call a bash script file in linux using a trigger in MySQL? I've been searching for the answer online and I ran into this articles: ...
0
votes
0answers
18 views

mysql trigger help

I need to create a MySQL trigger. I don't know very well MySQL syntax but I've written something, maybe you would understand what I need, I need to insert the difference from 2 rows into a new row, ...
3
votes
3answers
610 views

Passing info on who deleted record onto a Delete trigger

In setting up an audit trail I have no problem tracking who is updating or inserting records in a table, however, tracking who deletes records seems more problematic. I can track Inserts/Updates by ...
-1
votes
2answers
34 views

I can't find the problem? [closed]

CREATE TRIGGER request_internal_trigger AFTER INSERT ON request_internal_analysis FOR EACH ROW BEGIN INSERT INTO user_action (User_Name , Request_number , Actions , DateOfAlter , ...
1
vote
2answers
247 views

Assign to NEW by key in a Postgres trigger

In the trigger body, how can I assign a value to NEW by it's field name? That's what I want to do: some_key = "some_column"; NEW[some_key] = 5;
-1
votes
1answer
83 views

SQL Server 2008 Trigger

New to triggers. I have two tables. One for users & other for circulated mails. The circulated mails table has [Sender, Receiver...] users table has [Personal Number, Names, Email]. when we have ...
0
votes
0answers
82 views

mysql trigger Update a row after insert according to condition

I am writing a MySQL trigger. In which I would like to update branch_form_no with auto increment form number according to branch id. How should I do? I have table hcm_staffing_applicantform with ...