Hi,
On Tue, Sep 6, 2011 at 9:17 PM, Thomas Mueller <[email protected]
> wrote:
> Hi,
>
> I will document it:
>
> "Check constraints can only reference objects that exist while the
> statement is executed."
>
I understand. I did a bit of parsing (including a carefully chosen subset of
SQL) and I've read the Parser. No easy fix, like throwing the table name
into hashmap and being done.
One potential solution would have been to decompose the original statement
to a series of CREATE TABLE, ADD COLUMN ..., ADD CONSTRAINT ... Still quite
a bit of work.
Still it's a pity since the ability of referencing the defined table
together with computed columns would allow some nice tricks. Like:
create table basket_impossible (
customer varchar (48) not null
references customer(name),
ord integer as
(select count(*) from basket_impossible as self
where basket_impossible.customer = self.customer),
-- other columns
primary key (customer, ord)
)
Natural Keys For Free!! Well, almost. Of course, it fails with table not
found.
I thought this will work:
create table basket_possible (
customer varchar (48) not null
references customer(name)
)
alter table basket_possible
add column ord integer as (select count(*) from basket_possible as self
where basket_possible.customer = self.customer)
but it fails with NPE (General error: "java.lang.NullPointerException")
Regards
--
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.