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
-
1
votes1
answer1194
viewsCreate Mysql Trigger increment/decrement attribute
I have the following tables -> app(id_app, nome_app) -> category(id_category, nome_category, total_apps) -> app_category(id_app_fk, id_category_fk) What I want to do is this, that whenever…
-
1
votes1
answer43
viewsChoose second smallest occurrence on a Rigger
Trigger that prevents a candidate who has stayed in the penultimate place during the last two months to apply for a new job so what I need to do is before entering the data into the table…
-
1
votes1
answer353
viewsTrigger prevents table change
I need to make a Rigger that prevents the same employee from being part of more than one crew on the same day. The crew table is as follows: Tripulação = {id_Voo, data, id_Funcionário } The 3…
-
1
votes1
answer1578
viewsDelete record when a column date is reached
I have the tables: In anuncios got the spine expiracao which receives the amount of days that that notice is valid, I want each day that the database automatically decreases 1 in this column, a…
-
1
votes2
answers54
viewsError while running a Trigger
I have a problem in a Rigger that when I do an input of a record I want to automatically pass a value that comes by default is 1 to 0 only it is always giving this error. Can’t update table…
-
1
votes2
answers234
viewsTrigger that accumulates the Mysql result
Considering the following tables: Gambler( id; name number. ) j equipe_ficticia( id; user name; name; dot_fictitious; ) Ef equipe_ficticia_player( id; equipeFicticiaId; pilotoId; ) efj step( id;…
-
1
votes0
answers35
viewsHow to resolve this Trigger in Mysql?
create trigger tr_kmanterior before insert on t_consumos for each row set new.kmanterior_c = (preview.kmatual_c); OR create trigger tr_kmanterior before insert on t_consumos for each row set…
-
1
votes3
answers855
viewsTrigger to update modification date in Firebird
I have a table of clients with the fields of Registration Date of the Registry and Date of Registry Modification someone would know how to create a trigger updating the column of Date of…
-
1
votes1
answer613
viewsCalculation of Order for Sale jquery items
I am with a problem that I am not able to solve I have a sales order screen where it has to do the quantity calculation X unitary value = (fill in the total value and add in the total order), how do…
-
1
votes0
answers423
viewsMysql Trigger with more than one cursor
I have a Trigger where I have 3 cursors, but it only runs correctly one of them(soma_pointo_cursor), the other two run incorrectly, I’ve tried with three separate loops, and it didn’t work either.…
-
1
votes1
answer489
viewsHow to fire a Rigger with jquery?
I’m working with radio type button and I can’t fire a Rigger. Can someone help me solve? $("input[name='estimate_method']").on('change', function() { $(this).prop("checked", true);…
-
1
votes1
answer63
viewsHow to make modification records in a Mysql Table (without using triggers )?
I wonder if there is another technique to make records of modifications in the tables without going through triggers ?
-
1
votes1
answer148
viewsDelete duplicate lines with postgresql conditionals
My code takes information from the internet and inserts it into the database, however, it inserts the same information more than once a day. I need to leave only 1 record information per day, IE,…
-
1
votes1
answer328
viewsTransfer JSON table columns in Postgres Trigger
I am creating a Trigger in Postgres and would like to turn all columns into JSON to insert in a single column of table 'LOG', I would like to turn for example 'OLD.*' into JSON and add it in column…
-
1
votes0
answers403
viewsFirebase Database - Event-based notifications
I have a project that needs to send notifications when certain data is added to Firebase. I did a lot of web searches, but I couldn’t find a way to implement this notification. I saw in the…
-
1
votes1
answer252
viewsRunning a system command with parameter inside a Function in Postgresql
I’m having a hard time create a function in the Postgres execute a command shell linux, with one detail: it is a function in a Trigger after insert and I need to use some columns from NEW. In Mysql,…
-
1
votes2
answers605
viewsTrigger updates only to 1 record
Considering the following trigger: CREATE TRIGGER tgr_vendas_d ON vendas FOR DELETE AS BEGIN DECLARE @valor DECIMAL(10,2), @data DATETIME; SELECT @data = d.data, @valor = d.valor FROM deleted d…
-
1
votes2
answers62
viewscensor a registered word in a database
Is there a way to censor and replace a word registered in Mysql through a precedent or Trigger for example? The word in the case would be Flash House and I need it replaced by Old School.…
-
1
votes0
answers96
viewsProblem with changing Trigger
I have a table that receives data all the time, almost every second. This table has a Trigger that after inserting a new row inserts this record in another table. I need to include a new Rigger in…
-
1
votes1
answer182
views -
1
votes2
answers479
viewsTrigger to connect multiple records
I have 3 tables: Usuarios (id, nome) Desafios (id, descricao) Usuarios_tem_desafios (id_usuario, id_desafio, status) The goal is, when adding a new user, to fill the table Usuarios_tem_desafios with…
-
1
votes1
answer96
viewsRandom character insert - Postgresql
I have a Function that makes an Insert when a certain action occurs, I’m trying to insert together random letters but I’m not finding anything related to this, It is possible to do this in…
-
1
votes0
answers313
viewsTrigger does not work
I don’t have much practice in Mysql and need to create a Trigger to update a column of a table when a new record is inserted, but when you insert a new row, nothing happens. I’ve changed everything…
-
1
votes1
answer1158
viewsList tables that have Trigger
Is there any way to know which tables have at least 1 Trigger ? For example, I have a system with 10,000 tables, and I would like to know which one has Trigger.
-
1
votes1
answer49
viewsWrong update on Trigger on Oracle
I have the following problem at Trigger, When there is an INSERT in table TB_DJE_PREPUBLICACAO, it has to be checked if the column DT_DISPONIBILIZACAO is null, if it is and if the column…
-
1
votes2
answers415
viewsTrigger automatically blocks the table (LOCK TABLE)?
About TRIGGER in any table: To TRIGGER blocks (LOCK) the table until the end of its execution? If not, when should I block it out? How do I do that blockade?…
-
1
votes1
answer130
viewsHow to create a "trigger" function when a variable changes value?
Watching pygame.Surface.get_rect(), I realize that when I change a variable, for example left, pygame automatically recalculates all class variables (center, right, etc.). I’d like to know how it’s…
-
1
votes1
answer186
viewsUpdate an attribute according to two other tables
Table Company CREATE TABLE empresa ( cnpj char(18) PRIMARY KEY, nome varchar(60) NOT NULL UNIQUE, receita float NOT NULL, pais_sede varchar(26) NOT NULL ); Target table CREATE TABLE destino( cidade…
-
1
votes1
answer1299
viewsCreate Trigger after update in the table itself and in another table
First I have a table: create table alecrim( id_alecrim int not null auto_increment, sem_epi int not null unique, p1 smallint, p2 smallint, p3 smallint, p4 smallint, p5 smallint, p6 smallint, p7…
-
1
votes1
answer1034
viewsHow to delete records automatically with postgresql?
Recently manage to catch a project that is a blog, the user will perform the posts of various news, however I am using the server Heroku with the free account that entitles there are only 512 Megas…
-
1
votes2
answers1931
viewsError: "Column Count doesn’t match value Count at Row 1" when inserting value in table with Trigger
After creating the Trigger: DELIMITER # CREATE TRIGGER BACKUP_PRODUTO_INS AFTER INSERT ON PRODUTO FOR EACH ROW BEGIN INSERT INTO BACKUP.BKP_PRODUTO VALUES(NULL, NEW.IDPRODUTO, NEW.NOME, NEW.VALOR,…
-
1
votes2
answers108
viewsCreate a Sequence, through a Trigger. Oracle
I’m trying to create a sequence in a trigger. When trying to create by Execute Immediate, I’m getting the following feedback: ORA: 4092 - Cannot commit in a Trigger. For all I’ve researched, use the…
-
1
votes1
answer28
viewsInclusion of First Record using a select SUM
In certain routine I have a Trigger that runs a code similar to the one below. I’m having trouble in the first record, as in the first record does not have any code, the sum of + 1 is not being…
-
1
votes0
answers148
viewsHow to update data from another table using a Trigger
I am trying to register a product in a cart, every time it is registered la significa q was purchased, so whenever this happens I want to decrease the amount in stock, tried with Trigger below, but…
-
1
votes1
answer577
viewsI’m trying to create a Mysql Trigger but is giving syntax error
CREATE TRIGGER comissao ON tb_Pedido FOR INSERT, UPDATE, DELETE AS BEGIN DECLARE v_codFuncionario INT DEFAULT NULL; DECLARE v_dataPedido DATETIME(3) DEFAULT NULL; DECLARE v_valorComissao…
-
1
votes1
answer51
viewsTrigger gives error with date
I made a Trigger to count the working days. It accepts the dates of the month 06 very well, but other dates gives the following error: INSERT INTO `teste` VALUES ("2018-05-01") #1292 - Incorrect…
-
1
votes1
answer541
viewsMysql trigger to be fired whenever a field is edited
Good colleagues, I have a problem I haven’t solved yet. I intend to create a Rigger that whenever the product quantity column undergoes an update it triggers an action to another table, to allow the…
-
1
votes0
answers17
viewsMysql grouping problem inside a Trigger
I have the following Rigger code, where it makes a select on the main tables (DADF311, DADF313.. ) to insert the result ready in the secondary table (DADF514): DELIMITER $$ CREATE TRIGGER ta_dadf311…
-
1
votes2
answers246
viewsPostgres: How to compare json to create audit Trigger and display only differences
According to the structure below, I would like that when it was updated I could memorize only the differences. Example in the table produto I have the fields: prodcodigo = 1 proddescricao = 'FILTRO…
-
1
votes0
answers99
viewsUpdate after Insert field
I’m trying to create a Trigger to update a value after inserting, or earlier if it worked. I have the following table: test Remembering that the field type date is timestamp and the default value is…
-
1
votes1
answer367
viewsWhen firing an Update Trigger, one of the fields only updates after a second Update
I created a Rigger to inform the fine about the delay of returning rented movies, however, when firing the Rigger once (giving an UPDATE), the field "Total Fine" does not update (only it). But when…
-
1
votes2
answers1911
viewsCreate Trigger to change record only when modifying a field
I have a SQL Server registration table, I have a column that shows the status of this registration ('A','I','S','C'). I created a field with name Update_data, that you will receive a datatime every…
-
1
votes2
answers127
viewsPrevent Insert or Update If date is in a Registered range
I am with the following doubt: I have the table: Escala Data_Atuacao_Inicial, Data_Atuacao_Final, tipo The guy can be 1 or 2 I want to create a Rigger to stop the Insert or update of this table, if…
-
1
votes1
answer55
viewsHow to know which columns were modified in an UPDATE using TRIGGER?
Good afternoon, everyone. I am creating a TRIGGER AFTER UPDATE in a table in the BD, and I need to know which columns were changed (regardless of the value that was placed), and put the column names…
-
1
votes0
answers100
viewsUpdate Datagridview in c# via Trigger UPDATE SQL
Hello, I have the following question. I’m running a c# application with SQL Server database. I have a Datagridview where he is carried via Datatable, the information loaded is from people: Name,…
-
1
votes1
answer139
viewsRecover Select from Any Trigger
How can I get one back select of a trigger? Example: CREATE TABLE PESSOA2 ( ID INTEGER IDENTITY NOT NULL, NOME VARCHAR(250) ) CREATE TRIGGER SELECIONAR_NOME2 ON DBO.PESSOA2 AFTER UPDATE AS BEGIN…
-
1
votes0
answers92
viewsTrigger to ban scale insertion that is already working on that SQL Server date
Thank you for your time! 1° I’ll put the data and then I’ll point out my doubt, I’ve tried a thousand times and I can’t get the logic that works. I have the following table Scale Table CREATE TABLE…
-
1
votes1
answer109
viewsCreation of Trigger that saves information on file
I need to save in a TXT file all the closing codes made in a Postgresql database. The table closures has the following fields: codigo | data | nome -------|------------|--------- 1 | 2019-08-01 |…
-
1
votes1
answer129
viewsHow to use new in SQL?
My goal is: so insert an element into banco1.Clientes the same is inserted in banco2.Clientes via a Trigger. If this element is already in the bank, there should be an update. But I cannot use the…
-
1
votes0
answers108
viewsPerform two actions on the same Trigger in Postgres
I’m having trouble with Trigger where: The table itens_compra_fornecedor through the column valor_compra calculates the resale price of the column valor_revendaon the table produto that has no…