Hi,
If anything, I blame Joe and his books. Anyway, here's the problem
this works:
create table accounting_period (
merchant varchar(48) not null
references merchant(name),
period varchar(8) not null
check (period in ('DAY', 'MONTH')),
n integer not null
check (n in (1, 7, 14)),
starting timestamp not null,
ending timestamp
as dateadd(period, n, starting),
primary key (merchant, starting)
)
alter table accounting_period add constraint no_overlapping_periods
check (not exists (
select * from accounting_period as self
where accounting_period.merchant = self.merchant
and accounting_period.starting >= self.starting
and accounting_period.starting < self.ending
))
But if I move the constraint into the create table statement it fails with
"Table 'accounting_period' not found".
It is rather obvious what is happening here. When the "inlined" constraint
is parsed, the table does not exist yet.
Of course, it would be nice if this could be fixed. Or, if no one (including
me) will think that it is not worth the effort, this limitation can be
documented.
--
Vasile Rotaru
--
You received this message because you are subscribed to the Google Groups "H2
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/h2-database?hl=en.