Procedural code automatically executed in response to a database event.

learn more… | top users | synonyms (1)

0
votes
0answers
24 views

What is the story about Oracle CREATE TRIGGER … CALL syntax?

I was able to use the CREATE TRIGGER ... CALL SOMEPROCEDURE; syntax but I'm a little bewildered about it. I expected to see some implicit arguments like TABLE%ROWTYPE new but that doesn't seem to be ...
4
votes
1answer
46 views

Is it possible to return a custom error for a logon trigger?

I'm trying to get a logon trigger to return a custom error. Thus far everything I have tried causes it to return the standard error: My trigger looks like this: CREATE TRIGGER Test_Logon_Trigger ...
0
votes
0answers
23 views

How to update Status using IF Condition in Mysql trigger

I'm trying to write an update trigger that will Design_Update_Status to Customized when a date is entered in Custom_Design_Update_Date field and if nothing is entered that field it should update ...
2
votes
1answer
79 views

How should I limit a table to N rows, discarding oldest?

I have a SQL Server table which I use to store events. I only want the table to contain the 1000 most recently added rows, when row 1001 is inserted, row 1 should be deleted. I have both a ...
2
votes
1answer
63 views

How to reuse an update trigger for multiple tables in postgresql?

In the database for a new project, I've started the convention of having each table have a last modified timestamp column. To implement this, I wrote a trigger for each table: CREATE TRIGGER ...
0
votes
0answers
25 views

How to analyze incoming DML in SQL Server 2005?

I have database and specifically one table that is used for batch data transfer from another organization. With each run the table is truncated and rows are re-inserted. I want to handle that process ...
0
votes
1answer
32 views

How to ensure a trigger is fired after variable number of inserts?

I have a 1:N relationship between two tables - let's call them "foo" (the parent table) and "bar". I have some triggers on both "foo" and "bar" tables. I insert data in a single transaction, first to ...
3
votes
1answer
42 views

Can't update trigger because of activity

Trying to add a line to a trigger that is attached to a table that is constantly in use ALTER TRIGGER [dbo].[name_of_trigger] ON [dbo].[name_of_table] AFTER UPDATE BEGIN IF ORIGINAL_LOGIN() in ...
3
votes
1answer
62 views

How to access NEW or OLD field given only the field's name?

I'm writing a validation trigger. The trigger must validate that the sum of an array equals another field. Since I have many instances of this validation, I want to write a single procedure and create ...
0
votes
0answers
15 views

Any possible solution for triggers associated with a table which is renamed to new name as trigger code still points to old table name

If there are any triggers associated with a table which is renamed to new name as trigger code still points to old table name As mysql document it says statement fails with the error Trigger in ...
1
vote
2answers
27 views

Basic trigger in PL/pgSQL, to flip a boolean field if another field has text

I want a BOOLEAN field to be set to TRUE when a sibling TEXT field is set to a non-empty string. Vice versa, the BOOLEAN is set to FALSE when TEXT field is set to empty string. The following function ...
0
votes
2answers
48 views

How to autoincrement Prod_id based on Product_Name using trigger in mysql

Product_Details table : (Fields) Prod_id(Primary key), Product_Name, Prefix and Slno(Auto incremented) i need to increment Prod_Id based on the product name field and prefix field (Input will be ...
-2
votes
1answer
64 views

how to autoincrement varchar datatype depending upon the product details name using trigger

I have a product details table, the fields in the table are *Prod_Id, Product_Name, Quantity, Slno*. Now i have created trigger for varchar data type field and implemented auto increment for Prod_Id ...
2
votes
3answers
43 views

How to update cust_id from Customer table to order table Cust_id field while inserting customer name using trigger

I have two tables 1. Customer_details and 2. Order_details. 1.Customer_details table -->fields--> Cust_Id(Primary Key) and Customer_Name, 2.Order_details table --> fields-- Ord_Id(Primary ...
0
votes
2answers
53 views

Triggers After Insert and After Update - Good Practice

It is a good practice to have a separate trigger for After Insert and another one for After Update or there is no problem in having both in the same logic? Also from a perspective of performance it ...
0
votes
0answers
43 views

Issue with a where clause by using Oracle

I'm currently facing a problem while I'm adding a trigger to the database that I use at home. I'm using : Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production The problem ...
0
votes
2answers
31 views

Anyway to get the trigger to work?

I want to insert last insert query to the another column.For that i wish to use TRIGGERS -- -- Triggers `sync_log` -- DROP TRIGGER IF EXISTS `tg_sync_id_insertbgnn`; DELIMITER // CREATE TRIGGER ...
3
votes
1answer
58 views

Update DATE field when another field in the same table changes value. (Completely noob my google-fu didnt help.)

I'm awfully noob, so excuse my ignorance. I tried to google this but somehow i can't find an example on how to do this I hava a table, say: - id (autoinc pk) - name (varchar) - description ...
0
votes
1answer
62 views

PLS-00049 bad bind variable when compiling a trigger

I'm trying to implement a dedupe trigger to a table. CREATE OR REPLACE TRIGGER USER.TBL_ACTION_DEDUP BEFORE INSERT ON USER.ERRORTABLE REFERENCING NEW AS NEW OLD AS OLD FOR EACH ROW BEGIN IF ...
0
votes
1answer
44 views

Mysql - Select To XML

I'm Building Audit Trail with Trigger, and want to convert the inserted / updated / deleted value into XML and store it into another table. my trigger look like this: DELIMITER $$ CREATE ...
0
votes
1answer
29 views

How can I create a TRIGGER in MySQL from this Oracle syntax?

I'm teaching myself RDMSs through a text book. I'm used to using MySQL so I'm sticking to it, but the book uses Oracle. I'm trying to create a trigger in MySQL with the Oracle command CREATE OR ...
2
votes
0answers
55 views

logon trigger to send an email

I want to create a simple login trigger. basically if user = test , then send an email to me. CREATE TRIGGER ServerLogon ON ALL SERVER WITH EXECUTE AS 'test' FOR LOGON AS BEGIN IF ...
0
votes
1answer
42 views

Execute SQL query after execute TRUNCATE in a table

I have a table called fos_user_user where I have a default record "always". Since I'm testing all the time and sometimes I need to clean that table I'm asking if there is any way to run the following ...
2
votes
0answers
20 views

Setting up triggers based on exposed columns in a view's source table

I have a table where I want to do a AFTER UPDATE trigger if one of the columns modified was in a specific view CREATE VIEW [dbo].[iv_EmployeesView] AS SELECT EMPLOYEE_GUID AS EmployeeGuid, ...
0
votes
1answer
30 views

Implement a deduplication trigger in Oracle

I am new in Oracle DB. We are using Toad for Oracle. I need to implement a deduplication trigger for our table. It's an alarms table and a third party vendor will be sending alarms to our database. ...
1
vote
1answer
22 views

Trigger to restrict users from creating a new table in the database

How do I create a SQL Server trigger that will restrict any users from creating a new table in the database? Please help me with this. Thanks & Regards, Ritesh.
0
votes
2answers
63 views

How to make a trigger work after a certain UPDATE

I would like to know if it's possible to create a trigger on Oracle that is invoked only when a certain UPDATE is done. For example: UPDATE colors SET tastes_good = y WHERE color_name = 'Apple'; ...
3
votes
2answers
90 views

Insert RECORD into a table in a trigger function

I would like to insert a RECORD data type variable (NEW variable) into a table in a trigger. What would the SQL look like? The following attempts were unsuccessful: EXECUTE 'INSERT INTO my_table ...
1
vote
1answer
108 views

How to create trigger to update timestamp when record is updated or inserted in another table

I have a table t_task and a table t_taskaction with a foreign key to t_task. I would like to update timestamp from t_task that is refering the foreign key form t_taskaction with every update in ...
1
vote
1answer
83 views

Is it possible to raiserror within a For Delete Trigger that rolls back the deletes

There is a claim at the end of this accepted answer that if an error occurs within a "For Delete" trigger, the delete action would be rolled back because it is part of an implicit transaction. ...
0
votes
1answer
44 views

Using count in triggers to update another table

Say i have a table called trx_request with the following data id | confirmed(TIME) | finished(TIME) ------------------------------------- 1 | 12:05:00 | NULL 2 | 13:11:00 | NULL and ...
0
votes
1answer
112 views

row-based replication with slave triggers

I'm replicating a prod MySQL database to an analytics one. I need to drop several tables with sensitive data from the analytics and also redact several columns of several remaining tables, replacing ...
0
votes
1answer
49 views

What does this TRIGGER do? [closed]

I have this trigger in DB2 that I need to convert to ORACLE, but I don't know how it works in DB2 so i can translate it to a ORACLE one, I think it doesn't do anything. CREATE TRIGGER ERRLOG_TRIGGER ...
5
votes
2answers
149 views

Error using triggers with SQL Server Profiler Tables

After noticing 100's of sort_warning errors in a recent analysis of the default trace output, I am trying get the text of the queries causing those warnings. SQL Server Profiler has an event ...
1
vote
1answer
56 views

Can I execute an external process via MySQL on table change?

When using triggers, if an update is done to a table then a trigger is executed. This is very convenient. But what I would need is to execute an external script. Is it possible to configure MySQL ...
0
votes
1answer
83 views

column auto updated after 24 hours in mysql

i have a table T1 with column : Name State time mon 1 2014-01-09 11:23:00 tue 0 2014-01-07 14:40:00 wed 2 2014-01-08 09:23:00 thu ...
2
votes
1answer
56 views

How to call stored procedure inside trigger?

I have made stored procedure that will update product quantity as per product id. That works fine for me. Following is code : DELIMITER $$ CREATE DEFINER=`root`@`localhost` PROCEDURE ...
1
vote
1answer
86 views

how to prevent dropping sysadmin user by another user in sql server

I have a legacy application installed on my server which has configured to work only with one user "sa" and there is time bomb like script written inside this application which whenever it finds ...
5
votes
2answers
154 views

Optimize queries from MySQL SP/Triggers/Functions

I have to investigate a MySQL Production server,While investigating I found a DELETE query in "SHOW PROCESSLIST" which was taking more than 400 second in preparing state, I tried to find the query in ...
-2
votes
1answer
83 views

Trigger not working, why? [closed]

What i'm doing wrong? CREATE TRIGGER `Calc` AFTER INSERT on `test`.`bookings` FOR EACH ROW BEGIN UPDATE `test`.`article` AS `ST` SET `ST`.`stock` = SUM(`test`.`bookings`.`amount`) WHERE ...
0
votes
0answers
38 views

MYSQL, how to build this Trigger

I have two tables in mysql Table: objects 1: ID (Auto Increment) INT eg: 1 2: Object (like "Flower) TEXT eg: Flower 3: Rank (like 90, calculated) FLOAT eg: 90 ...
1
vote
2answers
58 views

Creating a mysql trigger without hard-coding database name

Is there a way to create a trigger in mysql without hardcoding the database name? Doing a typical create trigger will stop working if I dump the database and then import it into a database of a ...
1
vote
2answers
127 views

DB2: Cannot use RUNSTATS/REORG in trigger definitions?

CREATE TRIGGER MY_TRIG AFTER INSERT ON MY_TBL FOR EACH ROW BEGIN IF SOMECONDITION THEN DELETE FROM MY_TBL WHERE PK IN (SELECT PK FROM MY_TBL WHERE SOMEOTHERCONDITION FETCH ...
1
vote
1answer
125 views

Call multiple functions from trigger?

I run PostgreSQL-9.2.4 Is it possible to call 2 functions from a trigger? Let's say I have two functions for two different tables to be executed if following trigger fires: Trigger: CREATE TRIGGER ...
3
votes
1answer
40 views

selective undoing of commited transactions in PostgreSQL

I have inherited a small (<1M rows) PostgreSQL DB which contains complex business rules split across several tables. Updates are very light, reads not so heavy, but the data is extremely valuable. ...
1
vote
0answers
80 views

DDL trigger AFTER ALTER ON SCHEMA behavior

Can anyone please tell me what's going on here: CREATE TRIGGER afr_alt_trig AFTER ALTER ON SCHEMA cols ora_name_list_t; BEGIN IF (ora_dict_obj_type = 'TABLE') THEN select column_name bulk ...
0
votes
1answer
54 views

Creating a My SQL Trigger

I want to create a trigger such that whenever a user is inserted in TABLE A(userid,type) his "userid" along with some predefined value depending in his "type" is inserted in TABLE B(userid,value) ...
0
votes
0answers
37 views

Should triggers be used as an extra precaution to enforce business rules? [closed]

I'm new to SQL Server, and I was wondering: how often do DBA's use triggers to enforce business logic? As long as your security is tight and no user has db_datawriter (or some other all-writing ...
-1
votes
1answer
333 views

how to log insert,delete,update queries in mysql

I want to log every insert,delete,update (successfully written) queries using mysql ? I tried following ways 1) used triggers ( but i can't get the SQL query ); 2) show processlists ( only showing ...
0
votes
1answer
72 views

Trigger After Insert is preventing insertion

I have two tables that must have similar information, and one of them can be considered the base table for to other, so in order to have the info in the two tables, I create this trigger: ALTER ...