I’m attempting to create a SQL database for an Auction company I work for. The issue I’m running into is creating triggers that update other inventory tables from the main inventory. I’ve tried quite a few different things, but can’t wrap my head around how to get this to work. The lat…
Tag: triggers
How to create a trigger for this situation?
I have a problem inserting values into a Class table. I want to write a trigger to prevent happening “an instructor teaches in different class_Id at the same time”. How can I do this? This is the trigger which I’ve created: Answer Use inserted and JOIN to the Class table. Check for existence…
MySQL after update trigger with number of affected rows condition
In MySQL, I want to create a trigger with AFTER UPDATE triggering event for my user table. In next, I have a table named user_log which is use to store the modifications that occurred on the parent table user after any update commands. So, data in user_log table need be as follows: As you can see from the dat…
How to create trigger that will insert into table old and new value on update/insert
I have looked a lot through the internet the past 3 hours but I cannot manage to make the trigger work. Here is my setup: There is a user USER1 that has granted UPDATE on view_faktura only. Making UPDATE statement on the view will change the underlying faktura table data. What I want to do is log into another…
MySQL trigger not functioning correctly
I currently working my AWS RDS MySQL through R notebook. I have a table like this: With a trigger like this I could create table and trigger without problems; however, when I insert something like this The insertion was successful but I would get an instance of fruit with ‘C’, instead of ‘A&…
How to create a trigger which will auto create sequence ID
I have been trying to implement the logic. But as only basic knowledge on SQL. I have a below following table I have following data in it I need to write some trigger as soon as the insert is performed depending upon createddate a sequence should be automatically inserted to sequence column for respective rec…
PostgreSQL: Trigger INSERT INTO SELECT from other table
I’m trying to create a trigger that will add a new row processed entry to a destination table each time a new row is created in the source table. Step 1 Create destination table: Step 2 Create trigger function: ** The Select query inside function work normally when single running. Step 3 Create trigger:…
PL/SQL table mutation and trigger Format
I just started with triggers, I want the trigger to give me the msg error if the new tauxHoraire is 50% greater than the current tauxHoraire (so *1.5 >). The trigger compiles but I’m getting ORA-04091: table name is mutating, trigger/function may not see it. There might a problem in how I wrote it. O…
How to insert data into table even if trigger fails?
Oracle 11.1 I have custom logging table where I insert data: I have a trigger that runs on a specific table which does some checkings. My problem is: when the trigger fails, I want to be able to log some data into the log_table. Trigger: The following code doesn’t work. I tried to use EXECUTE IMMEDIATE …
Adding constraint in PostgreSQL that requires information from another table
I have the following schema in PostgreSQL How can I enforce the constraint that studentmarks.marks_scored <= exam.total_marks such that the behaviour is just like the CHECK constraint? Answer Use trigger. You need to create trigger function first. Then create trigger. NOTE I have tested in postgres