Most voted "trigger" questions
A database server is a code of procedure executed automatically in response to certain events in a given table or view in a database.
Learn more…211 questions
Sort by count of
-
15
votes3
answers15156
viewsList all triggers in SQL Server
Is there any command, that lists all the triggers from a database in SQL Server?
-
8
votes1
answer7625
viewsDifference between Triggers and Stored Procedures
What are the differences between Triggers and Stored Procedures?
-
7
votes1
answer982
viewsUpdating application(C#) in real time with Database (Mysql)
I am creating a server client application, the application would run on several machines using the same database(mysql) on an online server. I would like that once the data of a table were changed,…
-
6
votes1
answer462
viewsWhat is the difference between the Mysql Trigger and Mysql Event exception?
I would like to create a e-mail trigger scheduler, without the use of cron, and would like to know if it is possible to do this through Mysql. Searching the Internet I saw some examples of event…
-
6
votes3
answers3659
viewsIn Trigger we have INSERTED and DELETED. Why not "UPDATED"?
Example scenario: I have the table/fields: documentos id documento pessoa item qtd valor The system gives INSERT and then UPDATE on this table in a continuous sequence (which would not come to the…
-
5
votes4
answers1585
viewsHow to make a "Generic Trigger" in SQL Server?
Hello I have in my database in all tables the following fields Datetime Criadoem | Datetime Modificadoem I wonder if you have a way to make a generic Rigger to control these fields, because when…
-
5
votes2
answers7608
viewsHow to create a Rigger that is fired every time you have an insert event in the table?
I need to create a Trigger that is triggered every time there is an insertion event in the table, before the insertion is made, it checks a condition, if the condition is met it changes the value of…
-
5
votes1
answer609
viewsIs there a parameter passage in a Rigger?
I have two tables, one with the sessions and the other with the activities. Within the table activities I have two fields, available and saleable and within session I have vacancies. I would like to…
-
5
votes2
answers7097
viewsHow to create a trigger in Mysql?
I have the tables usuarios, usuario_voto, and classificacao_usuario. Usuarios: system users table. usuario_voto: table that stores a user’s vote on another. classificacao_usuario: table that stores…
-
5
votes1
answer1048
viewsCan I invoke Function on a Trigger?
My Function done on Sql-Server: CREATE FUNCTION dbo.getQuantidade(@idProd char) RETURNS float AS BEGIN DECLARE @QTD float SET @QTD = (SELECT (prod.Quantidade) FROM Produto prod where @id_prod =…
-
5
votes1
answer1602
viewsHow to avoid deletion of relational data through referential integrity in MYSQL?
I have the tables SIMULATED and QUESTAO, where a simulated can have several questions, but a question can only be for a simulated (relationship 1-n). MOCK TABLE: simuladoId simuladoNome TABLE…
-
5
votes1
answer228
viewsA Rigger can "undo/undo" the action that triggers it?
Example scenario I have a table telefones where I have a Trigger that is fired while performing the instruction Insert. Doubt I can use the Trigger for verify a condition and before the return,…
-
4
votes1
answer415
viewsHow to send data from one table to another with the Deleted command
Guys I’m creating this trigger in the SQL Server, but I’m not getting the id to send the data to another table and delete from this table. CREATE TRIGGER MoveComprador ON comprador INSTEAD OF DELETE…
-
4
votes2
answers112
viewsWhat is the best way to monitor a value in a database?
I am working on an item management system, in which I need to constantly monitor the amount of items available. Upon reaching a predefined minimum threshold, the system shall issue the item in an…
-
4
votes1
answer1010
viewsTrigger para update before Insert
My database has two tables, notification and attendance, as shown in the image. In the notification table the default value of the status is "open". I tried to make a Rigger that updates the default…
-
4
votes1
answer145
viewsTrigger without replicating data - SQL Server 2012
Guys, I have a Trigger in the FRM_46 table that would replicate the data right after the Insert or update to the FRM_31 table, however, it is not replicating, I already analyzed and made the tests,…
-
3
votes1
answer1426
viewsTrigger UPDATE write TXT file
How can I create a Rigger that is fired every time I have one UPDATE in x column, grab the new value create new txt file and insert inside it. ( for synchronization purposes ). For example: produtos…
-
3
votes1
answer111
viewsHow to restrict the time of manipulation of a table?
I would like to know a way to create a trigger in sql-server to restrict the time of handling a table between two working days (8:00 to 18:00).
-
3
votes2
answers763
viewsTrigger in Mysql VS logic in PHP application?
I am doing inventory control system, and I would like to know the advantages and disadvantages between two forms of implementation to subtract the number in stock after a sale/output. 1) Carrying…
-
3
votes2
answers616
viewsPostgresql Trigger apos update
Let’s imagine the following scenario: CREATE TABLE invalido ( ds_valor character varying(255) ) CREATE TABLE email ( email character varying(255) ) now I need a trigger that every time I run a…
-
3
votes2
answers489
viewsSqlserver Trigger after update
Let’s imagine the following scenario: CREATE TABLE invalido ( ds_valor character varying(255) ) CREATE TABLE email ( email character varying(255) ) now I need a trigger that every time I run a…
-
3
votes1
answer89
viewsHelp with MYSQL TRIGGER
I need to assemble a Trigger that before deleting a user it checks if there are occurrences linked to the user in question, and if there is, not allow delete, but never worked with Triggers. Someone…
-
3
votes1
answer205
viewsImplement Triggers in Postgre
It has how to implement a Rigger to work in a column that is present in all tables of the database?
-
3
votes1
answer454
viewsHow to cancel an INSERT event on Trigger?
Hello, I created a Rigger that every time the user performs a sale is made the debit in the quantity of items, but if I do not take care the quantity can be negative because the user can sell more…
-
3
votes1
answer43
viewsCreation of Trigger
I need to develop a Rigger in which any change that occurs in one of these fields below the Task table should send the task information to the Instruction table. TASK TABLE TarefaID Vencimento…
-
3
votes1
answer56
viewsdoubt with date in sql tables
good, I have a table with the following information usernum / type / expiredate 1 1 2019-03-03 13:04:42.710 What I wanted to do was to have a trigger in this table that would check the date and when…
-
3
votes2
answers388
viewsHow do replace in all fields except one?
I have a table with several fields, and I need to make a insert or replace on each line. I receive the data coming from a software and if it does not exist, I enter, otherwise I replace. I get a…
-
3
votes1
answer106
viewsMysql - Phpmyadmin error running Trigger
Hello, when I try to run the following Rigger, I get this error: #1064 - You have a syntax error in your SQL next to line 11 Follow the Trigger: CREATE TRIGGER atualizacao after update ON cliente…
-
2
votes2
answers1832
viewsMysql Automatically Change Data
Good afternoon, I wanted to implement a system that would make my database automatically, change the value of one of the fields of an element when the expiration date field was higher than the…
-
2
votes1
answer248
views"create temp table" in Rigger in Postgresql
It is possible to create an Insert Trigger in a "Table1" using "CREATE TEMP TABLE" in its structure and feed a "Table2"?
-
2
votes0
answers281
viewsTrigger in Mysql for movie rentals?
I need a little help because the teacher said not to use FUNCTIONS and PROCEDURES, ONLY the TRIGGER. It follows image of what he is asking. I’m really not able to do. For me there had to be before a…
-
2
votes1
answer548
viewsSql Server Error: is not a recognized Function name
I have two functions in sql server that are not being recognized by the database -- Não loga conexões de usuários de sistema IF (ORIGINAL_LOGIN() IN ('sa', 'AUTORIDADE NT\SISTEMA', 'NT…
-
2
votes2
answers204
viewsSave values whenever a new line is added via Trigger
I need help to solve a problem, I tried it halfway, but it’s not working. I have two tables to which I have to perform this activity and create a trigger called trg_line_total to save the value of…
-
2
votes2
answers1894
viewsCreate total sales (value) per customer (SQL)
I need to make a procedure to install the column cli_TotalCompras of the customer table with the total (in value) of the customer’s purchases. On the table vendaProduto have the value…
-
2
votes2
answers212
viewsError in Trigger
I am making a system that deals with monitoring cattle and I have a question about creating triggers after update. The situation is as follows: in my bank there are several tables that have foreign…
-
2
votes2
answers60
viewsCalculation for year "turn" with Trigger
How to treat the Trigger below so that the operations carried out between 21/11/2016 and 20/12/2016 return date 20/01/2017 instead of 20/01/2016. DECLARE P_COUNT NUMBER(5); DIA_VENDA VARCHAR(2);…
-
2
votes2
answers1472
viewsTrigger that updates record in a table
I need to update an X table whenever there is a change in table Y. I have found numerous examples of how to save the changed records in table Y, both when deleting a record from table X and when it…
-
2
votes1
answer816
viewsUpdate Trigger in Mysql
I don’t know much about Mysql and need to make a Trigger to update a line right after its insertion. When the user registers an order he selects how many orders he wants. In the database is saved in…
-
2
votes1
answer732
viewsCreate a precedent in Postgresql
I have created a database in Equipment Allocation Postgresql where one or many Equipments can be Allocated by one or many Sectors. That is, I have 3 tables in this relation: One is the Sector Table…
-
2
votes2
answers814
viewsDelete triggers by query
Consultation To consult all the triggers of a database, use: SELECT * FROM sys.triggers Failed attempt I tried to exclude all or some of these triggers contained in the result: DELETE FROM…
-
2
votes1
answer231
viewsUse ON UPDATE CURRENT_TIMESTAMP when changing specific field
Example scenario Table: usuarios Campos: id, nome, sobrenome, senha, timestamp_alteracao Question The field timestamp_alteração, should only be updated when the field senha is amended. Doubt There…
-
2
votes2
answers304
viewsTriggers INSTEAD OF Update, How to filter by date
Hello, First of all thank you for all your time in the community. Come on! I will throw the information and then try, in the best possible way to explain the problem. I have 3 tables: Person List…
-
2
votes1
answer302
viewsBetter shape in Firebird, taking safety and lightness
I’m developing a software in Delphi, using Firebird. My goal is to have a lightweight, fast, but, software that has security, regarding errors, corruption in the bank, resist as far as given to…
-
2
votes2
answers269
viewsUpdate tables using Trigger from a main table
I have the following structure: A main table X, where the "header" of the sale is stored. A Y table, where the sale items are stored. A Z table, where some sales data will be saved, from the…
-
2
votes0
answers34
viewsTrigger that validates the percentage of each tranche in a purchase note greater than x value
Good morning, I’m having a hard time creating a Rigger that checks on the Insert and update a higher apportionment number than x ( I’m using 30 for testing) on each purchase note. This is the first…
-
1
votes1
answer1813
viewsCreating Trigger to change status once you delete employee
I’m creating a Rigger that the moment you delete an employee she changes the status from 1 (active) to 0 (inactive) then save this change in a table (employees dismissed) to access if you need,…
-
1
votes1
answer1171
viewsUpdate in another row in the same table by Trigger
Is there any way to update in the same table, being in another row, through a after insert or before insert?
-
1
votes1
answer1607
viewsTrigger for a Select
I would like to know if it is possible to execute a Trigger when a SELECT is performed in a given table, for example: CREATE TABLE IF NOT EXISTS "Conversa" ( "idConversa" SERIAL NOT NULL,…
-
1
votes1
answer930
viewsError running a Firebird Trigger
I have the following Trigger generated in my database: SET TERM ^ ; CREATE OR ALTER TRIGGER ATUALIZA_CODNCM FOR EST_ADICIONAIS ACTIVE BEFORE INSERT OR UPDATE POSITION 0 AS begin UPDATE…
-
1
votes2
answers582
viewsHow to create a function that returns the lowest expiration date between batches of a given product?
How I create a function that returns the shortest expiration date between batches of a particular product? Dry my SQL code: create database Exemplo; use Exemplo; create table produto (codProduto…