triggers

Create DB2 History Table Trigger

Hi, I want to create a history table to track field changes across a number of tables in DB2. I know history is usually done with copying an entire table's structure and giving it a suffixed name (e.g. user --> user_history). Then you can use a pretty simple trigger to copy the old record into the history table on an UPDATE. However, ...

SQL Server: trigger to fire only if a condition is met

I hope this is a simple enough question for any SQL people out there... We have a table which hold system configuration data, and this is tied to a history table via triggers so we can track who changed what, and when. I have a requirement to add another value in to this table, but it is one that will change frequently from code, and...

MS SQL Trigger update call dead lock?

I have two tables. Club and Coach. Between them is 0,1 - 0,1 relationship (coach can have zero or one club. club can have zero or one coach). When I want to change the coach of the given club, i have to update the club table. So i have to change idCoach of that club. Lets consider a new coach (the newly assigned coach of the given club) ...

SQL Action keyword

What does the SQL Action keyword do? Can I use this keyword in a trigger and determine if the trigger was called by an Insert, Delete or Update? ...

debugging postgresql trigger

I have this Trigger in Postgresql that I can't just get to work (does nothing). For understanding, there's how I defined it: CREATE TABLE documents ( ... modification_time timestamp with time zone DEFAULT now() ); CREATE FUNCTION documents_update_mod_time() RETURNS trigger AS $$ begin new.modification_time := now(); ...

SQL 2005 Trigger Question

Can I ascertain the name of the stored procedure that caused the trigger to fire from within the trigger? ...

WPF: Adding a Trigger to a Button

I am currently coding a program with a WPF UI and I have a button which is either close or cancel, depending on if there were any changes made on the page. To achieve this I want to use a trigger (wrapped in a style) on the button so that when the dependency property HasChanges is true the button will change from "Close" to "Cancel". S...

Autoincrement in Oracle

What are the other ways of achieving autoincrement in oracle other than use of triggers? ...

How do you identify the triggers associated with a table in a sybase database?

I am using SQL Advantage and need to know what the SQL is to identify the triggers associated with a table. I don't have the option to use another tool so the good old fashioned SQL solution is the ideal answer. ...

WPF Style Trigger

I change the FontSize of Text in a Style trigger, this causes the Control containing the text to resize as well. How can I change the Fontsize without affecting the parent's size? ...

SQL Server: Modifying the "Application Name" property for auditing purposes

As we do not implement the users of our applications as users in SQL server, when the application server connects to a database each application always uses the same credentials to attach to each database. This presents an auditing problem. Using triggers, we want to store every update, insert and delete and attribute each to a particul...

MS SQL Problem - Field length being limited

I have a MS SQL DB with various tables, and one field in particular is causing me grief. The Data type is set to varchar(100), however the field is limited to 60 characters. If I try to put any string with more than 60 characters into the field I get an exception, "String or binary data would be truncated". Although the string is short...

SQL Server history table - populate through SP or Trigger?

In my SQL Server backend for my app, I want to create history tables for a bunch of my key tables, which will track a history of changes to the rows. My entire application uses Stored Procedures, there is no embedded SQL. The only connection to the database to modify these tables will be through the application and the SP interface. Tra...

SQL Server 2005 trigger - how to safely determine if fired by UPDATE or DELETE?

I have the following code in a SQL Server 2005 trigger: CREATE TRIGGER [myTrigger] ON [myTable] FOR UPDATE,DELETE AS BEGIN DECLARE @OperationType VARCHAR(6) IF EXISTS(SELECT 1 FROM INSERTED) BEGIN SET @OperationType='Update' END ELSE BEGIN SET @OperationType='Delete' END My question: is there a situation in which @Operation...

Does anyone know how to listen to build events from an already running cctray process, in C#?

I have made a C# application and I am trying to figure out if I can tap into build events of cctray (cruise control tray)? I don't want to re-invent the wheel, I just want to know when my builds fail or succeed (on a client machine) so than my custom C# application may execute a specific set of routines. ...

Twitter-like "follow user" and "watch this" problem

What's the best way to handle many-to-many trigger relationships like the Twitter "follow this user" problem. I have a similar problem with users "watching" threads for replies. If there are 10,000 users watching a thread, and someone replies, how best to notify the watchers? All I can think of is the following: Upon insert, check th...

Should I use SQL triggers?

Hello, I am implementing a data base design that has a vehicle table, vehicle engine and vehicle gear table with SQL 2005. Each table has an ID that is a SQL identity number, and each engine and gear has a relation with the vehicle ID. So before I create a vehicle I must create an engine and gear. How could I know the vehicle identity...

How do I call a script when a table's data changes in Sybase 12.5?

OS is UNIX. I'd like to call a shell script to do external validation when the data in a table changes. Is it possible, and if so how. Many thanks. Updated: Ideally, I would like to call my external script once for any discrete operation: i.e. update... > call script once insert into... > call script once bcp into > call script onc...

Oracle function concurrency

I currently have an INSERT TRIGGER which in Oracle 10g runs a custom defined function that generates a funky alpha-numeric code that is used as part of the insert. I really need to make sure that the function (or even trigger) is thread safe so that if two users activate the trigger at once, the function used within the trigger does NOT...

ORA-04091: table [blah] is mutating, trigger/function may not see it

I recently started working on a large complex application, and I've just been assigned a bug due to this error: ORA-04091: table SCMA.TBL1 is mutating, trigger/function may not see it ORA-06512: at "SCMA.TRG_T1_TBL1_COL1", line 4 ORA-04088: error during execution of trigger 'SCMA.TRG_T1_TBL1_COL1' The trigger in question looks like ...