constraints

How can I alter a smalldatetime column with a default to be datetime?

I have a number of columns in my database that were originally created as smalldatetime and that really need to be datetime. Many of these columns were created with the DDL: [columnname] smalldatetime not null default getdate() ...which means that in order to alter the column's type, I first have to drop the default, and then re-crea...

Changing column constraint null/not null = rowguid replication error

I have a database running under Sql server 2005 with merge replication. I want to change some of the FK columns to be 'not null' as they should always have a value. SQL server won't let me do that though, this is what it says: Unable to modify table. It is invalid to drop the default constraint on the rowguid column that is us...

Why can't we use sealed classes as generic constraints?

Can you guess what is the reason to not allow sealed classes for type-constraints in generics? I only have one explanation is to give opportunity to use naked constraints. Sorry, for editing. I think you need to rephrase the question title. It should be "Why we can’t use sealed classes as generic constraints?" – this.__curious...

Mysql Constraign Database Entries in Rails

I am using Mysql 5 and Ruby On Rails 2.3.1. I have some validations that occasionally fail to prevent duplicate items being saved to my database. Is it possible at the database level to restrict a duplicate entry to be created based on certain parameters? I am saving emails to a database, and don't want to save a duplicate subject line...

Inherit from a generic base class, apply a constraint, and implement an interface in C#.

This is a syntax question. I have a generic class which is inheriting from a generic base class and is applying a constraint to one of the type parameters. I also want the derived class to implement an interface. For the life of me, I cannot seem to figure out the correct syntax. This is what I have: DerivedFoo<T1,T2> : ParentFoo<T1, T...

Problems with abstract types and interafaces as generic type params with the new() constraint

I need to have the generic type parameter as an interface, however I would like to instantiate the type in the generic class (SomeGenericType) as follows: class Program { static void Main(string[] args) { var val = new SomeGenericType<ISomeInterface>(); Console.ReadKey(); } } internal class SomeGenericType<...

Grails domain class constraints for relation between fields

Hi, I need to write Domain class constraint in Grails which says that one integer field must be greater or equal than the other. When I write the code like this: class MyDomain { String title int valueMin = 1 int valueMax = 1 static constraints = { valueMin(min:1) valueMax(min:valueMin) } } I'm getting error: Caused by: ...

How to alter length of varchar in composite primary key?

In MSSQL I have a table created like this: CREATE TABLE [mytable] (fkid int NOT NULL, data varchar(255) CONSTRAINT DF_mytable_data DEFAULT '' NOT NULL); ALTER TABLE [mytable] ADD CONSTRAINT PK_mytable_data PRIMARY KEY (fkid, data); Now I want to increase the length of the 'data' column from 255 to 4000. If I just try: ALTER TABLE [...

Detect which dataset row violates the DB unique constraint during insertion

I'm inserting rows into a table from other tables in the SQL Server management Studio and some records violates a unique constraint because initial data is 'dirty' and is inconsistent. How can I find which records violate? ...

MVC Route Constraint for bool

What would be a valid regex for a MVC route constraint passing a bool? For example, I have the below route: routes.MapRoute("MenuRouteWithExtension", "Menu.mvc/{action}/{projectId}/{dealerId}/{isGroup}", new { controller = "Menu", action = "RedirectUrl", projectId = "", dealerId = "", isGroup = "" }, new { projectId = @"\d+", dealerId ...

How to set constrains on generic in Java?

Hi folks. First of all I'm only aware of Java basics. Now I have the following scenario: If have a generic class: public class ListObject<T> { // fields protected T _Value = null; // .. } Now I want to do something like the following: ListObject<MyClass> foo = new ListObject<MyClass>(); ListObject<MyClass> foo2 = new L...

Bullet Physic Library: Apply torque to joint or constraint between twice bodies

I'm beginning look themes about simaletion-based character and once topic say about constraint or joint calculation torque to character pose, and I want implement this using Bullet, but its constraint has not methods that allow to calculate constraint's torque. Someone would help me about this.....thanks in adavance.... ...

hash functions-sql studio express

I need to create a hash key on my tables for uniqueness and someone mentioned to me about md5. But I have read about checksum and binary sum; would this not serve the same purpose? To ensure no duplicates in a specific field. Now I managed to implement this and I see the hask keys in my tables. Do I need to alter index keys originally cr...

Oracle find a constraint

I have a constraint called users.SYS_C00381400. How do I find what that constraint is? Is there a way to query all constraints? ...

Is it possible to create a collection of generic contrained types in .net?

Is something like this possible? Dim l As New List(Of T As Type Where GetType(BaseClass).IsAssignableFrom(T)) Note, my collection will be a collection of Types, not objects of type T - which I know is possible. ETA: The answers I've had so far are as expected - I didn't think it was possible. What I'm trying to get my head round is...

how can I generate integers that satisfy some restrictions?

Can anyone give me a hand with techniques to generate integers that satisfy certain restrictions. For example, say I need to generate integers x and y such that 100 > x and y < x + 5 And I don't mean this particular example but some generic techniques to generate integers that satisfy certain conditions. Thanks a lot! Manue...

Hibernate: constraintName is null in MySQL

Hello, I have a code using JPA with Hibernate 3.3.x. This Java code can be used with schemas stored either on Oracle 10g or MySQL 5.1.x. Tables are defined with constraints to define unique records. When a constraint violation occurs, I want to retrieve the constraint name from the exception. With Oracle, the constraint name is properl...

SQLite: Table1.id <> Table2.id for each id in Table1, Table2

I need the primary keys of 2 sqlite tables (say, id1 and id2) to be related such that no id1 can be equal to any id2 and viceversa. This is because I need to obtain from these 2 tables the same type of xml element, with unique attribute id. Is there a way either in sql as understood by sqlite or in "classic" sql to express such constrain...

importing geonames database into postgres for django project - problem with foreignkey constraints

The geonames database has two models that refer to each other. In a postgres database, reference is provided by foreign key relationships. The problem is writing data to the database - writing to one table without having the referenced id in the other table violates a foreign key contraint. Class Geoname id = IntegerField(primary_...

Model login constraints based on time

Good morning, for an existing web application I need to implement "time based login constraints". It means that for each user, later maybe each group, I can define timeslots when they are (not) allowed to log in into the system. As all data for the application is stored in database tables, I need to somehow create a way to model this id...