How to: Create trigger for auto update modified date with SQL Server 2008

My approach: define a default constraint on the ModDate column with a value of GETDATE() – this handles the INSERT case have a AFTER UPDATE trigger to update the ModDate column Something like: CREATE TRIGGER trg_UpdateTimeEntry ON dbo.TimeEntry AFTER UPDATE AS UPDATE dbo.TimeEntry SET ModDate = GETDATE() WHERE ID IN (SELECT DISTINCT ID FROM Inserted)

Populating django field with pre_save()?

Most likely you are referring to django’s pre_save signal. You could setup something like this: from django.db.models.signals import pre_save from django.dispatch import receiver from django.template.defaultfilters import slugify @receiver(pre_save) def my_callback(sender, instance, *args, **kwargs): instance.slug = slugify(instance.title) If you dont include the sender argument in the decorator, like @receiver(pre_save, sender=MyModel), the callback will be called for … Read more

MySql Error: Can’t update table in stored function/trigger because it is already used by statement which invoked this stored function/trigger

You cannot change a table while the INSERT trigger is firing. The INSERT might do some locking which could result in a deadlock. Also, updating the table from a trigger would then cause the same trigger to fire again in an infinite recursive loop. Both of these reasons are why MySQL prevents you from doing … Read more

Get first date of month in postgres

You can use the expression date_trunc(‘month’, current_date). Demonstrated with a SELECT statement . . . select date_trunc(‘month’, current_date) 2013-08-01 00:00:00-04 To remove time, cast to date. select cast(date_trunc(‘month’, current_date) as date) 2013-08-01 If you’re certain that column should always store only the first of a month, you should also use a CHECK constraint. create table … Read more

Setting a property with an EventTrigger

Just create your own action. namespace WpfUtil { using System.Reflection; using System.Windows; using System.Windows.Interactivity; /// <summary> /// Sets the designated property to the supplied value. TargetObject /// optionally designates the object on which to set the property. If /// TargetObject is not supplied then the property is set on the object /// to which the … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)