Questions tagged [database-trigger]

A database trigger is procedural code written in the current database DML, that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database.

A database trigger is procedural code written in the current database , that is automatically executed in response to certain events on a particular table or view in a database. The trigger is mostly used for maintaining the integrity of the information on the database.

1659 questions
4
votes
1 answer

Database-Trigger to Delete row where condition True:

I need trigger That Deletes row where in table paym both columns table1 and table2 are not empty. Example in tables below: table: paym ID username table1 Table2 +-------+-------------+-------------+-----------+ | 1 | …
anonymous
  • 119
  • 1
  • 10
4
votes
2 answers

MYSQL Error when cloning database with sql dump- ERROR 1359 (HY000): Trigger already exists

I've got a MySQL database I'm using for a live project and I want to create a copy of it on the same server that I can use for development purposes. I have used MySQL dump to create a copy of the live database. I did this as follows: mysqldump -u…
Jay Black
  • 107
  • 2
  • 12
4
votes
2 answers

Fix for Maximum length allowed for char in Oracle 4000 character

I am currently using Oracle 11g. As per my requirement, I need to store first 4000 (max limit) characters to my variable (used in triggers). For that I am using VarName = SUBSTR function(VarName, 1, 4000), but it seems like it is storing nothing (I…
Sumit Suman
  • 71
  • 1
  • 6
4
votes
1 answer

Trigger to create record from JSON object in PostgreSQL

Concept: a trigger what creates a new record in a table after a new JSON object has been created in another table. I don't want to make any modifications yet, just to "convert" JSON objects to records with a trigger.
Bence László
  • 494
  • 2
  • 5
  • 14
4
votes
1 answer

SQL Trigger (as) is not a valid input at this position error - MySQL

I am not sure why I am keep getting the error on line number 3. (as) is not a valid input at this position? CREATE TRIGGER PendingPublish AFTER INSERT ON TopicPending AS BEGIN IF NEW.TopicApproved = 'YES' THEN INSERT INTO Topics…
sach jot
  • 570
  • 4
  • 16
4
votes
2 answers

What should return trigger BEFORE DELETE

I am trying to make simple trigger function (Postgresql) but I am getting same error 'function did not return any row' in all these cases (just simple examples): New: UPDATE somewhere SET something = something - 1; RETURN NEW; Old: UPDATE somewhere…
Úca
  • 43
  • 1
  • 6
4
votes
1 answer

Trigger to update a column on update

I have written this function and this trigger: CREATE OR REPLACE FUNCTION test4() RETURNS TRIGGER AS $BODY$ BEGIN UPDATE "cf" SET vol=(area*alt); RETURN null; END; $BODY$ LANGUAGE plpgsql trigger CREATE TRIGGER trig_upd AFTER OR UPDATE ON…
Giocor
  • 43
  • 1
  • 4
4
votes
3 answers

SQL Server trigger with loop for multiple row insertion

I've created trigger for my database which handles some insertion but when I add multiple values in 1 SQL query it doesn't work: ALTER TRIGGER [dbo].[ConferenceDayTrigger] ON [dbo].[Conferences] AFTER INSERT AS BEGIN DECLARE @ID INT DECLARE…
Maciek Trystuła
  • 49
  • 1
  • 1
  • 4
4
votes
1 answer

Sequelize Migration - Create Trigger in PostgreSQL

I need to create Trigger on one of my Table using Sequelize Migration in Node and PostgreSQL. I haven't found enough documentation around it. Currently I am using sequelize version 3.23 and quite familiar with PostgreSQL triggers, but not able to…
Viren Ajmera
  • 101
  • 2
  • 6
4
votes
0 answers

Error Code: 1422 Explicit or implicit commit is not allowed in stored function or trigger. when calling sp in trigger

What am I doing wrong ? Create a trigger that automatically calls the payFees procedure whenever a film is returned. You will have to decide how to name the trigger, when to fire it and for what table to fire it: DROP TRIGGER…
4
votes
1 answer

Mysql database trigger

I'm still new in msyql database trigger. I would like to ask about my lines: CREATE TRIGGER secure_dml3 BEFORE DELETE ON t_pembelian BEGIN IF (SELECT TO_CHAR (SYSDATE,'DY') IN ('SUN')) OR (SELECT TO_CHAR (SYSDATE, 'HH24:MI') NOT BETWEEN '09.45'…
rhog23
  • 311
  • 2
  • 16
4
votes
2 answers

How do I alter a trigger in Oracle?

I am trying to change the trigger script for my database. My trigger name is ARCH_USER_UPD_TRG and this puts any updates or deletes on the USER table into a Z_USER table I am dropping a column from the USER table and now need to modify the trigger…
user906153
  • 1,218
  • 8
  • 30
  • 43
4
votes
1 answer

What can make a trigger to fail and what happens if it fails

I've created a trigger (never done it before). My goal is: WHEN one or more rows are INSERTED into the table 'userlite' IF there are rows with 'IdLite' as in the new row inserted in the table 'litedetails' THEN add a row to the table 'informations'…
genespos
  • 3,211
  • 6
  • 38
  • 70
3
votes
2 answers

How to get number of rows affected by a statement when inside that statement's trigger

I have a statement level trigger that fires whenever INSERT UPDATE or DELETE operations are performed on a table (called customers). I want to display a message (to DBMS_OUTPUT) containing the number of rows that were inserted/updated/deleted. I…
dav83
  • 312
  • 1
  • 2
  • 15
3
votes
2 answers

Using StoreGeneratedPattern.Identity with database-trigger-generated primarykey values not possible?

This question is related to another question i asked here ( Entity Framework 4.2 - How to realize TPT-Inheritance with Database-generated Primarykey Value? ) and should simply clarify, if my assumptions, regarding the problem stated in the topic,…