db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From joe <fischauto...@yahoo.de>
Subject Re: self referencing column
Date Tue, 02 Feb 2010 09:51:00 GMT
Hi,
> Perhaps another way to work around this is to use GENERATED BY DEFAULT as
> IDENTITY.
>
>    

But how?
I dont want the user to define the id.

Ok i can use a helper table which holds the id
create table state_id
(
     ID int not null
)
insert into state_id values (0)

and doing the follwing two commands for every state insert:
update state_id set id = ((select id from state_id) +1)
insert into state values ((select id from state_id),  (select id from 
state_id))

Looks quite ugly for me.


Mime
View raw message