database-trigger

SQL Server : DDL trigger, controlling table creation

风格不统一 提交于 2019-12-23 15:15:58
问题 I'm using SQL Server 2008. I'm creating a DDL trigger like this: CREATE TRIGGER tName ON database FOR CREATE_TABLE as print 'A table has been created' Can I get that table that has been created !? Something like inserted or deleted in the normal table triggers ?! 回答1: Try this: CREATE TRIGGER TRG_TABLES ON DATABASE AFTER CREATE_TABLE AS BEGIN SET NOCOUNT ON DECLARE @TABLE_NAME SYSNAME SELECT @TABLE_NAME = EVENTDATA().value('(/EVENT_INSTANCE/ObjectName)[1]','SYSNAME') ... END GO 回答2: I believe

How can I find all the db triggers in MySQL?

扶醉桌前 提交于 2019-12-21 07:16:10
问题 I created a trigger using SQL, how can I see the trigger using MySQL in phpMyadmin? 回答1: Click on the 'SQL' tab and enter this query: SHOW TRIGGERS 回答2: select * from information_schema.triggers where trigger_schema = 'your_db' 回答3: to see all your routines the code is... select * from information_schema.routines 来源: https://stackoverflow.com/questions/5420812/how-can-i-find-all-the-db-triggers-in-mysql

Oracle trigger error ORA-04091

空扰寡人 提交于 2019-12-17 14:56:50
问题 I get an error (ORA-04091: table DBPROJEKT_AKTIENDEPOT.AKTIE is mutating, trigger/function may not see it) when executing my trigger: CREATE OR REPLACE TRIGGER Aktien_Bilanz_Berechnung AFTER INSERT OR UPDATE OF TAGESKURS OR INSERT OR UPDATE OF WERT_BEIM_EINKAUF ON AKTIE FOR EACH ROW DECLARE bfr number; Begin bfr := :new.TAGESKURS - :new.WERT_BEIM_EINKAUF; UPDATE AKTIE SET BILANZ = TAGESKURS - WERT_BEIM_EINKAUF; IF bfr < -50 THEN DBMS_OUTPUT.PUT_LINE('ACHTUNG: The value (Nr: '||:new.AKTIEN_NR|

SQL - Trigger Update Error

大憨熊 提交于 2019-12-13 21:46:35
问题 I am beginning to learn SQL, and have made a database of Houses where I have a table for Houses, Rooms, Hallways, etc. I have a column in Houses called NumberOfRooms, and a column in Rooms called HouseName. I am trying to make a trigger so that when a room is added to a house, the House attribute "NumberOfRooms" is incremented. This is the query I am trying: CREATE TRIGGER UpdateNoRooms AFTER INSERT AS UPDATE Houses SET Houses.NumberOfRooms = SELECT COUNT(Room) FROM Rooms WHERE Rooms

SQL trigger to stop update when a condition is met

不问归期 提交于 2019-12-13 06:22:26
问题 I have 3 tables: Projects , Components , and Suppliers . What I am trying to do is writing a trigger that doesn't allow the value of city to be modified if the component and the project have the same city as the supplier. What I have tried so far: create or replace TRIGGER Supplier_control BEFORE UPDATE of city ON Suppliers BEGIN DECLARE v_counter NUMBER := 0; SELECT COUNT(*) FROM (SELECT * FROM Suppliers s JOIN Projects p ON (s.city=p.city) JOIN Components c ON (c.city=s.city)) INTO v

SqlDependency vs SQLCLR call to WebService

只愿长相守 提交于 2019-12-12 19:04:37
问题 I have a desktop application which should be notified on any table change. So, I found only two solutions which fits well for my case: SqlDependency and SQLCLR . ( I would like to know if there is better in .NET stack ) I have built the both structure and made them work. I only able to compare the duration of a s̲i̲n̲gl̲e̲ response from SQL Server to the client. SqlDependency Duration: from 100ms to 4 secs SQLCLR Duration: from 10ms to 150ms I would like this structure to be able to deal with

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

血红的双手。 提交于 2019-12-12 15:43:30
问题 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, are right or not. The Problem (in detail): I want to use EF (4.1) to access a database, that already exists the database has some restrictions regarding the generation of primary key values for its tables (there is a UDF that takes a tablename and

How to save a data with comma in character varying that passes through a trigger?

家住魔仙堡 提交于 2019-12-12 06:59:42
问题 I have a field of type character varying but I get an error when trying to save a data that contains decimal. I want to save that data without problem. This is my trigger: CREATE TRIGGER "public.usuarios_trigger_process_audit" BEFORE INSERT OR UPDATE OR DELETE ON usuarios FOR EACH ROW EXECUTE PROCEDURE process_audit(); This the PROCEDURE: DECLARE newtable text; col information_schema.columns %ROWTYPE; txtquery text; line_old TEXT; tmpquery text; i int; columns_old text[]; BEGIN IF ( TG_TABLE

Mysql error 1442 when triggering an action to update two columns after inserting a row

北城以北 提交于 2019-12-12 04:42:23
问题 After inserting data, for example, a date into a event_date column, I want a trigger to update two columns of that same table and row the corresponding values of 'event_quarter' and 'event_year'. I have this test table with four columns: id , event_date , event_quarter , event_year I have been struggling with this code to make it work: DELIMITER $$ CREATE TRIGGER `fill_event_quarter_and_year` AFTER INSERT ON `test_table` FOR EACH ROW BEGIN DECLARE event_date_ DATE; SELECT event_date INTO

Find different in two jsonb , PostgreSQL trigger function

好久不见. 提交于 2019-12-11 23:34:52
问题 user CREATE TABLE IF NOT EXISTS "user"( "id" SERIAL NOT NULL, "create_date" timestamp without time zone NOT NULL, "last_modified_date" timestamp without time zone, "last_modified_by_user_id" integer, "status" integer NOT NULL, PRIMARY KEY ("id") ); user_track CREATE TABLE IF NOT EXISTS "user_track"( "date" timestamp without time zone, "by_user_id" integer, "origin_value" jsonb, "new_value" jsonb ); function CREATE OR REPLACE FUNCTION user_track_insert() RETURNS TRIGGER AS $$ BEGIN INSERT INTO