Procedural code automatically executed in response to a database event.

learn more… | top users | synonyms (1)

0
votes
0answers
30 views

Trigger For prevent inserting data [on hold]

i need a trigger that prevent some data from inserting in table According to a condition , before inserting any row in the table like this code create Trigger trigger_name on table_name for insert ...
0
votes
2answers
41 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
0answers
25 views

Get columns from NEW when execute update on postgresql [closed]

I need know if determide fields are into result of update execution, e.g. IF NEW.niveope is null THEN _new_nivope := 0; ELSE _new_nivope := NEW.nivope; END IF; When I execute: EXPLAIN ...
0
votes
1answer
13 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
58 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
13 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 ...
0
votes
0answers
55 views

SQL Server 2008 R2: After Insert Trigger and Query returning unexpected results for a split second

I am having trouble with an After Insert trigger and a query running right afterwards. The query goes and finds the most current record in each table by using OUTER APPLY with a table-valued ...
1
vote
1answer
37 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
47 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
25 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
26 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 ...
1
vote
0answers
39 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
16 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
52 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
36 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
141 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
28 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
45 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
57 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
28 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
87 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
17 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, ...
2
votes
3answers
129 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
109 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
52 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
32 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 ...
2
votes
0answers
76 views

AFTER DELETE trigger will not fire during a cascade delete

I've got two tables, corresponding to Nodes in a graph and Aisles to which they may belong. In addition, each Aisle has a Node at which it starts and ends. Aisle Table: Aisle char(4) Start_Node ...
1
vote
1answer
24 views

List with all visible meta data in AFTER UPDATE trigger

I have the following issue - something is updating particular table columns when such update is not allowed. I was not able to find the object (searching in T-SQL and ASP code, server jobs), so I ...
0
votes
1answer
26 views

How to limit schema size by a trigger

The problem: I am running on a Webhotel a MySql database with different schemas with a maximum size limit on each schema. I can't change any settings on the DBMS. To be able to keep the schema below ...
1
vote
1answer
23 views

Does trigger “see” all changes done in the transaction it was fired from?

Let me elaborate on the title. Suppose we have two tables, t1 and t2. t2 has a trigger t2_trgon it. Same transaction inserts/updates data in t1, then does insert/update in t2. t2_trg is fired and ...
0
votes
1answer
63 views

Log all table updates for all tables in MySQL

Is there anyway I can get the last updated time of a set of tables? By last updated time, I mean not only when the table's schema changed but when any of the rows changed or even when rows were ...
0
votes
0answers
38 views

How to ensure a field is populated before use in a trigger

When I assign a new bed number in a hospital, the number must be prefixed by the ward number the bed is in. How do I know my user is going to populate Ward_Id before Bed_Id? What does one do in a case ...
0
votes
1answer
50 views

Is it possible to modify an existing trigger definition in MySQL?

I am wondering if it is possible to update a trigger definition in MySQL. For example, I have a trigger T and I want to add some new functionality to it. My assumption is that I need to drop and ...
0
votes
2answers
81 views

Postgres: error message “does not exist” when dropping existing trigger

I have a trigger associated to a table. When i drop it via DROP TRIGGER IF EXISTS myTrigger on dummytable; postgres tells me NOTICE: trigger "mytrigger" for table "dummytable" does not ...
1
vote
0answers
29 views

How To Log Select Statements from 1 User On 1 Table Into a Permanent Log Table

We have a centralized authentication library that 100+ applications use to authenticate users. That library has its own DB credentials. It would be extremely useful to log every time that library/user ...
1
vote
1answer
161 views

Updating mysql trigger via information_schema — access denied?

I have some wrong "definer"s for some triggers in MySQL (actually MariaDB). I figured the easiest way of correcting them would be some version of: use information_schema; update triggers set ...
0
votes
0answers
50 views

Service Broker received an error message on this conversation

I will first have to say, I am still trying to wrap my brain around all the components of the Service Broker and how they work together, so it's very likely I'm missing something obvious... it's just ...
4
votes
1answer
139 views

How to determine if insert or update

Whenever INSERT is happened in the CUSTOMER table,I need to call the "StoredProcedure1"and UPDATE is happend in the CUSTOMER table,I need to call the "StoredProcedure2" in the Trigger. How to ...
0
votes
3answers
97 views

Instead of Trigger Continue with operation after custom logic?

I do not think what I am trying to do is possible, but I could not find any documentation on this. I have an INSTEAD OF UPDATE, INSERT, DELETE that always inserts data into a history table before ...
2
votes
1answer
91 views

How would I implement interprocess communication from Oracle (10g R1) trigger using DBMS_ALERT?

Let me state up front that I'm not proficient in Oracle at all, MS SQL yes but not Oracle; which is why I'm asking this. Current Setup Oracle 10g Release 1 running on Red Hat Ent. 3 (no support) ...
2
votes
1answer
61 views

How to resolve logon trigger and EXCEPTION_ACCESS_VIOLATION?

My production sql server is running... Microsoft SQL Server 2005 - 9.00.4035.00 (X64) Sep 18 2014 16:17:31 Copyright (c) 1988-2005 Microsoft Corporation Standard Edition (64-bit) on Windows ...
0
votes
1answer
19 views

Is it possible to run a trigger on Table Creation in MySQL

Simple Question. Is it possible to create a Trigger that runs everytime a Table is created. The goal is to create a metadata table for each table, but I can worry about dynamically passing the table ...
2
votes
1answer
57 views

Delay Trigger Execution

Let me explain the scenario first before asking the question. I have a database with a set of tables. One table, say Table A, contains username details, and other table, say Table B, contains user ...
0
votes
1answer
121 views

Oracle Text CTXCAT Domain Index, Transactional, and Before Insert/Update Trigger

TLDR: The CTXCAT index is supposed to be transactional, but Before Insert triggers that modify the indexed column don't seem to induce an update. I'm running on Oracle 9i. (Actually, I'm running on ...
0
votes
1answer
45 views

Choosing a RULE instead of a TRIGGER

I my current database schema, there are hundreds of tables that reference another single table (called transaction_entry), that stores generic information about each row (when it was created, last ...
2
votes
1answer
40 views

trigger can't access column loop

SSCCE: The following script: $ cat test.sql CREATE TABLE public.foo ( loop INTEGER ); CREATE OR REPLACE FUNCTION public.foo_fun(loop INTEGER) RETURNS BOOLEAN AS $$ SELECT TRUE; $$ LANGUAGE SQL; ...
0
votes
0answers
24 views

On deleting a record from a table, Save that data in another table.

I need help on trigger.i am deleting a record, i need to use a trigger which will save that record in other table. can anyone give me a general code which will help me?
1
vote
1answer
73 views

Can a PostgreSQL Trigger be used to ignore an insert?

I've got a situation where there are dozens of various triggers in our database that trigger a record being inserted into another (single) table within the database. I was hoping that while testing ...