Re: [sqlite] enum in SQLite

2006-01-05 Thread Derrell . Lipman
Michael Scharf <[EMAIL PROTECTED]> writes: > Jim C. Nasby wrote: >> On Thu, Jan 05, 2006 at 01:39:02PM -0600, Kurt Welgehausen wrote: >> >>> create trigger EnumTrg before insert on MainTbl for each row >>> when (select count(*) from EnumVals where val = new.EnumCol) = 0 begin >>> select

Re: [sqlite] enum in SQLite

2006-01-05 Thread Kurt Welgehausen
> ... you'll also need to write an update trigger ... True, and you may want to protect EnumVals with triggers after you populate it, or put EnumVals is a separate read-only database and attach it. On the other hand, being able to change the allowed values without changing the schema may be an

Re: [sqlite] enum in SQLite

2006-01-05 Thread Jim C. Nasby
On Thu, Jan 05, 2006 at 01:39:02PM -0600, Kurt Welgehausen wrote: > create trigger EnumTrg before insert on MainTbl for each row > when (select count(*) from EnumVals where val = new.EnumCol) = 0 begin >select raise(rollback, 'foreign-key violation: MainTbl.EnumCol'); > end; Wouldn't that

Re: [sqlite] enum in SQLite

2006-01-05 Thread Clay Dowling
Kurt Welgehausen said: >> SQLite doesn't support enums natively. You could emulate it using >> triggers, although it would be somewhat hidden and definitely a pain in >> the tucus to use. > > It's not really so hard. > > create table MainTbl ( > ... > EnumCol SomeType references EnumVals, >

Re: [sqlite] enum in SQLite

2006-01-05 Thread Kurt Welgehausen
> SQLite doesn't support enums natively. You could emulate it using > triggers, although it would be somewhat hidden and definitely a pain in > the tucus to use. It's not really so hard. create table MainTbl ( ... EnumCol SomeType references EnumVals, ...); create table EnumVals (val

Re: [sqlite] enum in SQLite

2006-01-05 Thread Clay Dowling
Rajan, Vivek K said: > I would like to know the following: > > *Does SQLite support enum like MySQL? If yes, how to use it > > *If not, is there another way to model enumeration in SQLite? > And/or any plans going forward to support enums natively in SQLit

[sqlite] enum in SQLite

2006-01-05 Thread Rajan, Vivek K
I would like to know the following: *Does SQLite support enum like MySQL? If yes, how to use it *If not, is there another way to model enumeration in SQLite? And/or any plans going forward to support enums natively in SQLite? Rajan