Questions tagged as 'trigger'

1
answer

How to check if a trigger exists or not before creating it?

I want to create a trigger in table_X but first I would like to check if it already exists on my base .... how do I? CREATE TRIGGER IF NOT EXISTS before_update_tableX ... ect     
asked by 16.12.2016 / 17:02
2
answers

Trigger to retrieve Last Record Inserted into table in PL-SQL

I have a trigger that after inserting a new user in the table tFuncionario I have to fill another table tPlanoSaude with the data of the official. Employee table HealthPlantable TriggersCodeCREATEORREPLACETRIGGERINSERTFUNCIONARIOBEFOREINS...
asked by 08.02.2018 / 21:02
3
answers

Create a trigger that is executed whenever a product is deleted

How to create a trigger that is executed whenever a product is deleted by performing the deletion action on all batches related to the deleted product. Here's my SQL code: create database provafinal; use provafinal; create table prod...
asked by 26.11.2014 / 17:36
1
answer

What is the error of this trigger?

I have this table: create table alecrim( id_alecrim int not null auto_increment, sem_epi int not null, p1 smallint, p2 smallint, p3 smallint, p4 smallint, p5 smallint, p6 smallint, p7 smallint, p8 smallint, p9 smallint, totOvos int, pend t...
asked by 09.01.2018 / 18:01
1
answer

"gen_id ()" or "select max ()" for Auto Increment in a PK field?

I currently use a Trigger with this SQL code to get an Auto Increment to be assigned in the primary key field ( PK ) of tables: create or alter trigger TRI_CLIENTES_BI for CLIENTES active before insert position 0 as begin if (new.ID is nul...
asked by 07.11.2017 / 16:53
1
answer

Trigger to update stock

I'm trying to create a trigger to update my product inventory, when the status of my purchase is closed (CF = Buy Closed). However, it is giving me an error, and I could not identify what is causing this error to be generated. Anyone h...
asked by 23.08.2017 / 23:30
1
answer

Insert same data into two MySQL columns

Hello! I have a table with the name tabx and two columns y and z, when I will insert the values in the column and I need a trigger to copy this value to the z-column. Have I tried some solutions but unsuccessfully can someone help me?     
asked by 06.01.2017 / 23:15
2
answers

How to create a trigger to save updates of two tables?

I have two tables: table1 : with three columns product_id , product_name , product_price ; table2 : with four columns tag_name , product_id , tag_name , tag_name li> I've created a new table3 : with three columns product_id ,...
asked by 16.12.2016 / 12:46
1
answer

How to execute trigger sqlserver

How can I perform a trigger on unit tests. I have a trigger I have a trigger as an example: ***-- Create one trigger with two inserts:*** create trigger trg_I_Table_1 ON Table_1 FOR INSERT as insert into Table_2 (Col_1, Col_2, Col_3)...
asked by 18.04.2016 / 20:12
1
answer

mysql trigger if not update

I'm having a question when creating a trigger, I need it to be executed only if the field has not been updated: ProductIntegration, if any other field is updated it should be executed. DELIMITER $$ CREATE TRIGGER 'cadastro'.'trgProdutos' A...
asked by 25.03.2015 / 14:15