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
0
votes
1 answer

Postgres syntax error near if

I have the following code, this is the shrunk version of the function for the trigger on the table i want to apply the trigger, the table actually has many fields: Create OR REPLACE FUNCTION PRC_EPV_() RETURNS trigger AS $PRC_EPV_$ begin …
0
votes
1 answer

How to pick a default value to the column in the trigger?

We implement some triggers which perform some operations with insert data before committing them to the database and when some conditions fail the trigger should pick up the default value for corresponding column. How to perform it inside the…
Igor
  • 2,619
  • 6
  • 24
  • 36
0
votes
0 answers

Using sql trigger or the code to add new records conditionally

I am working on a Facebook-alike app (ASP.NET MVC). Based on the number of likes on an entry, there are different badges to be assigned: On the 5th like, Badge A should be assigned, on the 10th like, Badge B should be assigned, and so forth.…
0
votes
2 answers

Token unknown error in update Trigger

Here's the update trigger I'm trying to create for a view. It's pretty clear what I'm trying to achieve: SET TERM !! ; CREATE TRIGGER SST_Insert FOR SpaceSpaceTypes BEFORE INSERT AS DECLARE VARIABLE NEW_TYPE_ID; BEGIN NEW_TYPE_ID=(SELECT…
small-j
  • 309
  • 1
  • 4
  • 12
0
votes
1 answer

Working with Date functions mysql and adding day to date while keeping track

So I have this table CREATE TABLE `chittytransactions` ( `ChittyTransactionID` int(11) NOT NULL, `AuctionID` int(11) NOT NULL, `ChittyAccNo` int(11) DEFAULT NULL, `Date` datetime DEFAULT NULL, `Amount` double DEFAULT NULL, `Description`…
luffy
  • 70
  • 10
0
votes
1 answer

Database trigger before insert and Calculations

So I have these tables: CREATE TABLE `chittytransactions` ( `ChittyTransactionID` int(11) NOT NULL, `AuctionID` int(11) NOT NULL, `ChittyAccNo` int(11) DEFAULT NULL, `Date` datetime DEFAULT NULL, `Amount` double DEFAULT NULL, …
luffy
  • 70
  • 10
0
votes
2 answers

Inserting running total

Problem to insert running total in MySQL transactional database. need your help for solutions and opinion. Table structure of my table is, create table `wtacct` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `ACCOUNT_NO` varchar(16), `AMOUNT`…
Faiz
  • 13
  • 2
0
votes
0 answers

AFTER UPDATE TRIGGER with Conditional Replies

I've written an After Update Trigger on tblVisitLog when a specific field, TimeOUT gets updated a new record is INSERTED in tblClinicalDoc. There is a possibility that a record with an identifying ID (Encounter_code) is already in the Target Table,…
JackW9653
  • 37
  • 6
0
votes
0 answers

oracle triggers - how to use count

fairly new to triggers so just trying to get my head round on how to create certain triggers. i have to make a doctors practise with patients and the trigger has to count if a patient has made 4 or more appointments their details will be stored into…
0
votes
1 answer

Oracle SQL - ORA-04079: invalid trigger specification

I have an EMPLOYEE table, which I want to create a trigger to log for when the employee commissions change (EMPCOMM). I have created an EMPLOYEE_COMM_AUDIT table to handle this. I have come up with the following code: CREATE OR REPLACE TRIGGER…
Big Green Alligator
  • 1,175
  • 3
  • 17
  • 33
0
votes
1 answer

How to create trigger to update columns that is calculated from another updated table

I have three tables: Product(pid, pname, pbrand, pprice) ShoppingCart(cartid, cid, active, totalprice) ShoppingCart.cid references to Customer.cid CartItem(cartid, pid, iprice, iquantity) CartItem.cartid references ShoppingCart.cartid,…
Vicky
  • 1,465
  • 2
  • 12
  • 21
0
votes
1 answer

Add two timestamp variable in mysql trigger

I have written my trigger like this CREATE TRIGGER `update_total_duration` AFTER UPDATE ON `sales_activity` FOR EACH ROW thisTrigger:BEGIN IF(NEW.activity_id=4) THEN LEAVE thisTrigger; ELSEIF NOT EXISTS (SELECT 1 FROM…
Mad Adh
  • 95
  • 9
0
votes
0 answers

MySQL Error while creating trigger

I am trying to execute the following trigger. But,resulting in MySQL error. Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF (max_dis_id IS…
ramya
  • 275
  • 1
  • 5
  • 13
0
votes
1 answer

identifier 'UTILS.IDENTITY_VALUE' must be declared

I am creating DDL scripts to create a DB model based on an existing DB. Basically polishing what I got from expdp. As the DB is Oracle 11gR2, it does not support the 12c Identity Columns yet…
Radek Skokan
  • 1,358
  • 2
  • 15
  • 38
0
votes
1 answer

MySQL trigger to drop and create table upon insert (through mysqlimport)

I am importing with mysqlimport (batch file) records to a specific table every 5 minutes, in order to get in this table online guests on my website. I currently send 2 .sql executed on a Windows batch file to a remote database: 1 SQL command to drop…
R_life_R
  • 786
  • 6
  • 26
1 2 3
99
100