Procedural code automatically executed in response to a database event.

learn more… | top users | synonyms (1)

0
votes
1answer
9 views

Postgres Partition Table Trigger inserting duplicate records

I have a trigger applied on my database table. But when i insert data into it via hibernate jpa it creates duplicate rows in master table. Here is the trigger CREATE OR REPLACE FUNCTION ...
2
votes
1answer
25 views

Trigger Logic (from SQL 6.5 )

I have a database that was originally implemented in SQL 6.5 and has been migrated to SQL2000, SQL2005 and now SQL2008R2 (Compatibility Mode = 10). Through the migration many new tables, functions, ...
9
votes
2answers
76 views

How often will a FOR EACH STATEMENT trigger execute if the operation is caused by an FK constraint with UPDATE CASCADE?

I understand that a trigger on table t defined with FOR EACH STATEMENT will run once when I execute an UPDATE t .... Now, when t is defined with FOREIGN KEY ... REFERENCES a ... ON UPDATE CASCADE, ...
1
vote
1answer
28 views

Periodically update a table with new records from another server

I have databases on two different servers. I need to regularly retrieve new records from a table on server A, and process them in order to use them to update a table on server B (with a different ...
0
votes
0answers
27 views

Mysql trigger on insert on another table

I have three tables all three have [product_id] column, what all i want to do is when there is new entry of quantity of respective [product_id] in table A and table B i want show the sum of the ...
1
vote
0answers
18 views

Trigger failing when called using sp_executesql

We have a recursive trigger on a table that executes AFTER INSERT. There is a check to ensure the trigger does not recurse more than 32 levels deep: IF(SELECT TRIGGER_NESTLEVEL()) >= 31 ...
0
votes
1answer
15 views

Use a value for a Postgresql setting in a trigger

We're using a trigger to track changes in various database tables. This works fine. Now we want to be able to track the changes back to the web request that caused them. I'd like to be able to use ...
0
votes
1answer
13 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 archive: 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 ...
0
votes
0answers
30 views

Which technologies should I consider using for creating a calculated view?

I use SQLServer, but I suppose this question is general enough for any type of database. Suppose I wish to build an application that allows people to rate geographic regions on where they would like ...
1
vote
1answer
21 views

Unable to update table after creating an After update trigger

I have a table like this /*Table: pageprivilege*/ ------------------------ /*Column Information*/ ---------------------- FIELD TYPE COLLATION NULL KEY DEFAULT Extra ...
-1
votes
0answers
6 views

Creating Trigger Leading zeros by instead of update

with reference to your very useful answer at http://stackoverflow.com/questions/15237100/how-to-insert-leading-zero-in-sql-server i need to know how to write the code for [instead of update] to put ...
0
votes
1answer
38 views

Scale MySQL trigger for thousands of inserts per seconds

We are using MYSQL database for an Analytics app. I have two table token and token-big (for overview of actual data) both have id(int) unix_starttime(int) unix_endtime(int) details(varchar 256) A row ...
1
vote
1answer
47 views

Why Update trigger makes Insertion slow in mysql?

I had create one table, that Table contain Log of meters. Name of that table is "paramgraph_ems" This table contain 1M rows, and insertion per minute is 350 rows. 10 Min takes for inserting 3500 rows. ...
1
vote
1answer
35 views

What does: SET @Variable1 = (Select field1 From INSERTED) mean?

I'm trying to understand an existing Trigger on one of my tables (DocumentDistribution), that it seems is the bridge table between DocumentInfo and DocumentSource tables. I don’t understand how this ...
0
votes
0answers
11 views

Mysql copying from varchar column to a decimal coulmn [migrated]

I have a column in MySQL table (First table) has varchar data type, I used JDBC driver to insert data of numerical data type on the mentioned column . Why I choose varchar data type of this type? ...
0
votes
0answers
35 views

Creating a trigger on Oracle 11g (beginner question) [migrated]

I need to create a trigger that updates another table whenever the trigger table has an insert into command, or an after insert trigger. I need to pull the id that's being inserted into the table in ...
2
votes
0answers
23 views

creating deadlock for distributed database in mysql-(Testing purpose)

I need to create a deadlock for distributed database in MySQL for testing purpose with a simple sql query(without front end), can anyone good with MySQL query help me out in this with sample query. ...
1
vote
0answers
14 views

MySQL performance of trigger when many rows are affected

I have a question on MySQL triggers which I hope someone might be able to help with. As part of our platform, we have a table (accounting), which grows rapidly. We also have an archived version of ...
0
votes
1answer
37 views

Oracle SQL Complications With Multiple Triggers

Hey all so I am creating a DB that is used going to be used for managing utilities of a system. My DB has 3 tables: Users, Utilites, and Files (leaving Files table out because question shouldn't ...
1
vote
1answer
54 views

trigger or check constraint insert values based upon existence of others

For simplicity (and since it captures the essence of my problem), suppose I have a table with data. CREATE TABLE my_practice_table ( my_id NUMBER(12), field_2 VARCHAR2(20), field_3 ...
0
votes
0answers
37 views

Indexing on cached data from related table using triggers — Is there a better way?

Edit: Schema details per request from Aaron Betrand -- I'll break the schema down to the relevant fields of the two tables. Orders (ID int IDENTITY, Status char(1)) Services(OrderID FOREIGN KEY ...
0
votes
0answers
15 views

Mysql 5.0 and 5.6 INSERT_LAST_ID() difference

Migrating from MySQL 5.0 to 5.6 i noticed that the INSERT_LAST_ID() function behaves different when using inside a trigger. My simplified situation: Table A has the trigger: insert into table_B ...
0
votes
1answer
25 views

On triggers and replication in MySQL

I have a classical statement-based replication between the master and the slave. Triggers were created on the master and replicated on the slave as well. Assuming that I have, say an ON UPDATE ...
-2
votes
2answers
46 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 ...
0
votes
2answers
29 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 ...
0
votes
1answer
45 views

MySQL: Capture every 5 values from column a in Table A to create one row in Table B

I have submissions of a form from a web page records in a database. the table has the following schema submit_time form_name field_name field_value field_order file the form has 5 fields, ...
1
vote
0answers
72 views

SQL Server inserted/deleted tables [closed]

I have the following logic flow Start transaction insert record 1 into table1 insert record 2 into table1 insert record 3 into table1 commit transaction I have a trigger on table1 that is using ...
0
votes
1answer
24 views

Can I setup database triggers to run on a defined secondary set of servers only? [closed]

This might sound a bit off, but here's what I have been thinking for a while now: Use Case You want to build an activity log for each user action on your application using database (postgreSQL) ...
2
votes
2answers
90 views

Upgrading a database from SQL Server 2005 to 2012 uncovered a syntax error

I recently upgraded from SQL Server 2005 to 2012. During validation however, a bug was discovered. A certain trigger was coded as follows: CREATE TRIGGER [dbo].[trigger] on [dbo].[foo] FOR UPDATE, ...
0
votes
2answers
44 views

How to use a trigger to only insert one row

I am doing a third year project using an intel galileo that reads an RFID card, and signs a student into a class, and I am using multiple tables. I have nearly completed it as all reads are been ...
0
votes
1answer
98 views

Trigger function check if all NEW.* fields exist in another table

In PostgreSQL I need to code a trigger function that checks if all the fields in NEW.* exist in another table that has the exact same name as the table that fired the trigger but appended with "_hv". ...
0
votes
0answers
69 views

PostgreSQL trigger copy record to another table with different columns order

I have a trigger that before every update on hundreds of tables it inserts into a table with the same name and the _hv suffix a copy of the record being updated to maintain a kind of historical ...
0
votes
1answer
101 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 ...
1
vote
0answers
32 views

How do I ensure that bulk inserts must fire my DML trigger?

I have a table using a DML trigger to ensure data integrity. Although authors of SSIS packages, BULK INSERT queries, and bcp executions can enable DML trigger execution, which is disabled by default, ...
0
votes
1answer
38 views

how to delete all rows with empty field via function/trigger combo in Postgres v 9.3?

In PostgreSQL 9.3 I am trying to write a trigger function that will be called after updates to table test2 and that will delete rows of test2 where field "email" is empty. Here's my attempt: CREATE ...
0
votes
1answer
37 views

SQL Server Transactional Replication With subscriber trigger returning a value

I have transaction replication setup on on SQL server 2008 R2. The subscriber has a after trigger on the published article that inserts into another table on the subscriber's database and returns the ...
0
votes
0answers
30 views

Do Statement-level AFTER triggers occur asynchronously after the statement returns?

I'm using an AFTER INSERT OR DELETE OR TRUNCATE ... FOR EACH STATEMENT trigger on a table to refresh a materialized view, and I'm concerned that it will significantly affect the performance of those ...
1
vote
1answer
62 views

Concurrency when simulating autoincrement with triggers on MySQL

I am updating an old application to implement virtual tenancy, which involves adding a tenant_id column to the primary key of every single table. The application uses auto-incrementing columns ...
0
votes
0answers
30 views

Oracle SQL Updating Trigger Statement

Hey all so let me see if I can clearly explain what I would like this trigger to exactly do. First of all the trigger will deal with 2 tables: Delivery Table: DeliveryNum |ItemName | Quantity | ...
1
vote
1answer
24 views

Trigger to apply user mapping to logins on database creation [closed]

Does anyone have any example triggers that apply user mapping on database creation?
0
votes
1answer
27 views

MySQL Replication, Can i add a trigger to the SLAVE db?

Is it possible to do so? The trigger will insert some rows into a unique table that exists only on the slave.
0
votes
0answers
22 views

Efficient Trigger updating in Postgresql

So I have a big table that often needs specific columns updated for a large number of rows. So right now I have it set up so that there is a 'staging' table that has the update-able columns. Then upon ...
1
vote
3answers
1k views

How to create a SQL trigger to execute a stored procedure when a table is updated

i need some help with creating a trigger to run a qf.stored_procedure when a qf.table is created. AT the moment, i have a job t run the stored procedure every 15 minutes but changing that is not an ...
0
votes
0answers
41 views

Delete data from related Tables with condition

I have Table a (id, id_d); --fk contraints = on delete cascade Table b (id, language_code); Table c (id_a, id_b); --fk contraints = on delete cascade Table d (id); I want to delete an entry from ...
0
votes
1answer
32 views

MySQL Local Variable Scope and Triggers

I have a couple triggers that automatically update invoice data and set some statuses in the database. However, it appears that if 2 Triggers have variables that are named the same, they get ...
0
votes
0answers
41 views

Better way to create an Events table?

I working on a medium sized PostgreSQL database with some schemas, each with some tables. In almost every schema there are tables that represent event tables, where something that has "happened to" ...
1
vote
1answer
119 views

MYSQL-BEFORE UPDATE Set value of Column A to value in Column B if Column A is to be updated

I have a nightly scheduled event which updates all rows in 'products' table with the newest 'unit_price' from a price list table where 'price_list.active-date' is >= the CURDATE(). What I need to do ...
0
votes
1answer
103 views

Unable to update or insert values table with DateTime column defaulted to GETDATE

I have atlered table by adding Datetime column. This column is not null and also default value from GETDATE(). ALTER TABLE myTable ADD myDateColun DATETIME NOT NULL DEFAULT (GETDATE()) I'm trying ...
1
vote
2answers
46 views

Need to convert date to word using trigger

I have created a datetoword function in Mysql. Checked the function working fine. Now using this function need to convert the date from field1 (date-datetype) to field2 (Varchar-datatype) within the ...
1
vote
1answer
337 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 ...