triggers

Why "Subquery returned more than 1 value. This is not permitted.." for same query in trigger and not as execute normal query

Hi, I am still trying to get of triggers right, but when is working it seems the other starts (failing) again. Annoying.. but also educational :-) When i executed the following SQL in MS SQL server is completes successfully, but when it is executed in a AFTER UPDATE trigger it fails with the error Msg 512, Level 16, State 1, Proc...

Capturing MySQL Statement and inserting it into another db via trigger

I want to be able to keep a log of every sql statment that edits a specific table, and I think the best way would be with a trigger. However, I don't know how to get the statement that triggers the trigger. For example if I run: $sql = "INSERT INTO foo (col_1) VALUES ('bar');" I want to be able to craft an insert statement like: ...

SQL Trigger - Maximo Workorders - Supervisor/Owner Initialization

I am working with an IBM Maximo database that issues workorders automatically. When the workorders are issued (aka Inserted into the database workorder table), I would like to auto-assign a supervisor, owner, and owner group based on a set of criteria. This only needs to happen IF the supervisor, owner, and owner group aren't already ass...

MSMQ Trigger on Windows 2003 not firing

I'm having a strange issue with an MSMQ trigger. This is what I've done. On Windows Server 2003 I've installed MSMQ I then installed MSMQ triggers I created a private queue called "TestQueue" I created the rule as follows: Name: "TestRule" Condition: "Message label contains '-'" (All my message labels contain '-') Invoke standalone ex...

PostBackTrigger control id

Hi, I have an button ("export") to export data from grid to excel. But it's inside an update panel. So I'm registering postback trigger. What should I assign to PostBackTrigger.ControlId ??? Thanks! ...

SQL CLR DDL trigger written on C#

Is it possible to create a database/DDL trigger in C#? And, if so, then how? [EDIT] Basically, I decided to use CLR for the database trigger because I want to utilize C# SMO to script the objects that change and insert the object script into a table that tracks versions of database objects. ...

Update panel can not find the button which trigger it.

Hi, I have a button is inside a another table(s) inside the update panel. <Update panel> <ContentTemplate> <table> <table> <Button> <table> <table> </ContentTemplate> </Update panel> I would like to add a button to Update panel's trigger. But am getting an err says "Update panel can not find the button which trigger it". I ...

In an OUTPUT clause in an INSTEAD OF INSERT trigger, is it possible to reference both INSERTED tables?

SQL Server 2005+ I have a view with an INSTEAD OF INSERT trigger. Inside the body of the trigger, I want to use a statement with an OUTPUT clause which references both INSERTED tables: the outer INSERTED table for the INSTEAD OF INSERT trigger the inner INSERTED table for the OUTPUT clause MSDN says this: If a statement that inc...

I would like to use psql triggers in rails app? HOw do i use this line of code - createlang plpgsql database_name?

If i am gonna use postgres triggers in rails app, i can use execute { create triggger } for creating trigger in migration file. But where am i suppose to write these lines of "createlang plpgsql databasename;" ...

How to properly implement "per field history" through triggers in SQL Server (2008)

Hi, so, I'm facing the challenge of having to log the data being changed for each field in a table. Now I can obviously do that with triggers (which I've never used before, but I can imagine is not that difficult), but I also need to be able to link the log who performed the change which is where the problem lies. The trigger wouldn't be...

Is there anything wrong with this mysql trigger?

I have a product, sales_order, and sales_order_product table. The nature of the products dictate frequent changes to price and weight. The customers often times save orders for a few days before submitting and paying for them. Because of this lag and the price/weight fluctuations, we allow them to freeze in the price/weight at the ...

How to make a MySQL trigger run only when at least one OLD field is different from NEW fields ?

Hi, I am trying to audit table changes on MySQL but i want the "before update" trigger to run (add a line into an audit table) only when there is at least one changed field. Is there a way to easily check all fields for changes between OLD and NEW ? Thank you ! ...

Compute hash-value of entered value when insert or update using sql server 2008 by triggers

Hi, i have a table with two column {FlatContent, HashedContent}. Now i want to automatically compute hash value of FlatContent when new row was inserted or an existing row was updated. To date, i'm never used from trigger, so i can't do this by trigger or another approach which is exist to solve this issue. Thanks if anybody can help me...

Track changes on column X and update the value of column Y by Trigger in Sql Server

CREATE TRIGGER ChangesTracker on [SearchEngine].[Urls] FOR UPDATE, INSERT AS UPDATE [SearchEngine].[Urls] SET [IsNormalized] = 0 WHERE [AbsoluteUrl] NOT IN or <> or != (SELECT [AbsoluteUrl] FROM INSERTED) What's wrong? UPDATE Thanks @codeulike for your help. I put correct trigger t-sql to an answer. ...

Prevent inserting overlapping date ranges using a SQL trigger

I have a table that simplified looks like this: create table Test ( ValidFrom date not null, ValidTo date not null, check (ValidTo > ValidFrom) ) I would like to write a trigger that prevents inserting values that overlap an existing date range. I've written a trigger that looks like this: create trigger Trigger_Test on Test for i...

How to get a MySQL Trigger to fire from multiple accounts

Hi folks, Here's my situation: I have a MySQL database in which I'd like to use triggers to automatically manage the updating of date creation and date modified fields in a few of my tables. Later, I'd like to expand them into logging data changes, but that's neither here nor there at the moment. The triggers work fine and update the...

Sql Server Triggers

I have a table which have 4 fields. Col1 Guid Primary-Key (FK to another table) Col2 Guid Primary-Key (FK to another table) Col3 Int Primary-Key Col4 Int Now i want to do this: when a new record inserted by user which have same value as a record exist before on the table like below: There was this Record: X Y Z 2 New record X Y ...

preventing a specific record from being deleted

I want to prevent a specific record from being deleted. This trigger works fine for that specific record. However, other records still remain when they're being deleted. Why? ALTER TRIGGER [Globalization].[CountriesTracker] ON [Globalization].[Countries] INSTEAD OF DELETE AS BEGIN SET NOCOUNT ON; IF ((Select COUNT(*) from [Delet...

Inserting new record by stored proc

I want to insert/update record with a specific stored-procedure which performs some business-logic on new record values. I can do this by trigger to ignore new record from directly to be inserted and pass new record values to my stored-procedure to perform appropriate action for passed values? ...

Why does jQuery not affect content generated after a Ajax call

I'm attempting to hide all li's within a div which is dynamically generated when a use clicks a button. The content of the div is pulled through an Ajax call and I then assign to a div on the page. For some reason though, any attempt to alter the style with jQuery doesn't have any affect. I notice I also have to apply $(selector).live(...