database-trigger

sql triggers I have error while storing column name in variable and use it for OLD.myvar in sql triggers

为君一笑 提交于 2020-01-11 13:51:09
问题 MySQL said: #1054 - Unknown column 'TMPCOL' in 'OLD' BEGIN DECLARE TOTAL,I INT; DECLARE CURRENT_CLOUMN VARCHAR(255); DECLARE TRIGGER_ON_TABLE VARCHAR(255); DECLARE TRIGGER_OP VARCHAR(255); DECLARE olddd VARCHAR(255); DECLARE newwww VARCHAR(255); SET TOTAL=0; SET I=0; SET CURRENT_CLOUMN='atulbaldaniya.com'; SET TRIGGER_ON_TABLE='atulbaldaniya'; SET TRIGGER_OP='UPDATE'; SET olddd=''; SET newwww=''; SELECT COUNT(COLUMN_NAME) INTO TOTAL FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = TRIGGER

MYSQL: IF having OR condition & REGEXP match

余生长醉 提交于 2020-01-06 12:21:54
问题 Goal : To block inserts into database table using trigger having multiple conditions Description : Trying to block lots of irrelevant entries in contact table. I have created a profanity table having lot of bad/swear/dirty words and a regular expression filtering URL. If any entry comes to DB having these bad words or URL then it should not be inserted. Analysis : Searched many different solution over SO and could be duplicate but didn't found any answer having multiple condition and regexp

Counting number of updates

。_饼干妹妹 提交于 2020-01-06 05:47:09
问题 Hi Every one I created this trigger function to count number of rows affected by an update . create table smt ( id serial primary key, num int ) CREATE OR REPLACE FUNCTION count_updated() RETURNS trigger LANGUAGE 'plpgsql' AS $BODY$ DECLARE n int; BEGIN IF(TG_OP = 'UPDATE') THEN get diagnostics n = row_count; insert into smt (num) values (n); return null; END IF; END; $BODY$; CREATE TRIGGER count_updt AFTER UPDATE ON test FOR EACH ROW EXECUTE PROCEDURE count_updated(); what I want to do is

How to disable triggers in MySQL?

喜欢而已 提交于 2019-12-29 04:13:26
问题 In my MySQL database I have some triggers ON DELETE and ON INSERT . Sometimes I need to disable some triggers, and I have to DROP e.g. DROP TRIGGER IF EXISTS hostgroup_before_insert // and reinstall. Is there any shortcut to SET triggers hostgroup_before_insert = 0 like we have for foreign keys: mysql> SELECT version(); +-------------------------+ | version() | +-------------------------+ | 5.1.61-0ubuntu0.10.10.1 | +-------------------------+ 1 row in set (0.00 sec) EDIT Answer There is no

DB2 “Triggers” on actions beyond update, insert and delete

吃可爱长大的小学妹 提交于 2019-12-25 18:56:07
问题 After researching triggers, I've only come up with thing showing how to update, insert and delete. It seems like that's even part of the syntax itself. DB2 Docs on Triggers Is there any kind of trigger, or something similar, which would let me track a larger set of actions, things like SELECT and ALTER TABLE ? We (unfortunately) share a database with some teams which we don't strictly trust to not do things like run insane SELECT statements (locking up the databases) or ALTER TABLE without us

T-SQL Update Trigger

旧街凉风 提交于 2019-12-24 23:52:33
问题 I'm trying to create the following trigger in SQL Server, but SSMS throws an error and I have no clue what it is. Any thoughts ? Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'trigger'. Code: IF NOT EXISTS(SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[trAfterUpdateInfoDoc]')) CREATE TRIGGER [dbo].[trAfterUpdateInfoDoc] ON [dbo].[InfoDocs] AFTER UPDATE AS BEGIN DECLARE @infodoctemplateid INT; DECLARE @infodocid INT; DECLARE @requireccount FLOAT(2);

PlSQL trigger error ORA-0000 ORA-06512:

☆樱花仙子☆ 提交于 2019-12-24 12:29:21
问题 create or replace TRIGGER "SUP" AFTER INSERT ON "EMP_REPORT" REFERENCING OLD AS "OLD" NEW AS "NEW" FOR EACH ROW DECLARE miclaim_supervisor_count number; employee_company_code VARCHAR2(10); employee_businessunit number; projMgrs NUMBER; supId NUMBER; cursor projMgrsCursor is select b.BU_MEMBER_ID from BU_MEMBER b, EMP_SUB_DIV s where s.EMP_NO = :NEW.EMP_NO and s.SUB_DIVISION_CODE = '01' and s.DIV_CODE = '2' and b.BU_ID IN (select BU_ID from BU_MEMBER where BU_MEMBER_ID = :NEW.EMP_NO); BEGIN

Problems Creating a trigger using Oracle

半世苍凉 提交于 2019-12-24 11:23:23
问题 My question is: A Trigger which automatically stores in a separate table called ‘ExcellentSale’ the Sales Agent name, car model and manufacturer name, each time the agreed price of a SalesTransaction is more than 20% of the car’s asking price. (Note: You need to create the ‘ExcellentSale’ table before implementing this trigger. To create the primary key, use a sequence that starts at 1 and increments by 1). I am using theses tables Manufacturer(manufacturerID, name, region) Model(modelNo,

Why is my “before update” trigger changing unexpected columns?

我只是一个虾纸丫 提交于 2019-12-24 07:14:31
问题 I have a table USERS with a varchar column LoginId . I am trying to use a before update trigger to change the incoming value to lower case. This is what I have done so far. It changes the value to lower case. But it also changes all other column to their default values. CREATE TRIGGER TOLOWER BEFORE UPDATE ON USERS REFERENCING NEW AS N OLD AS O FOR EACH ROW MODE DB2SQL set N.LoginId= lcase(N.LoginId) Is this trigger correct? If not then what changes should should I do ? 来源: https:/

How to call restful service from SQL Server trigger

≯℡__Kan透↙ 提交于 2019-12-24 04:53:13
问题 I need to call a restful web service with a single parameter from the insert event in a SQL Server database table. I know this is not ideal design but I don't have control of either end point. The usage of this functionality will not exceed 100 events/min at max load. I'm open to other ideas but the two options I came up with were; insert trigger - service broker - .NET windows service to call web service C# CLR trigger to call restful service directly I have been working on option 2 and