Well thanks for the reply, although I prefer to use the platform dependent way even if that sounds weird! I've taken care though to abstract all the methods in an interface and implement as needed.

So I guess I'll just have to go the way Masoud Kalali suggested if I finally decide to switch to Derby(eventhough I'll have to change a few more lines of code).

Thanks everyone. You've been most helpful.
 
Michael Segel <msegel@segel.com> wrote:
There are other ways of doing this, however each method has their own good
points or bad points.

One way you can do this is to create a counter table.
(This allows you to have multiple counters within a single table.)
Then you can write your own procedure that will fetch the value of the
counter, increment that value by a step and update that row to reflect the
new value.)

This is different in that you can create/delete/reset counters as needed. So
it can be used for a couple of different types of applications and it does
not
Note that there are issues like row level locking, etc ... are left to the
developer to deal with... ;-)

But that will let you have a way to generate a sequence that is platform
independent, as long as they allow for stored procedures.

Also note that your performance will vary....




On Sunday 30 April 2006 5:14 am, Panayiotis Vlissidis wrote:
> Thanks for the quick response!.
>
> I would rather not create a table as I have a generic code that updates the
> database tables(deletes, inserts, modifies tables) that works with the DB's
> metadata and a static declaration of all the DB schema that might change as
> the application's version changes. I would prefer not to have to declare
> the generators as tables as errors might occur(such as forgetting to
> declare the generator or deleting by mistake) that would cause the
> generators tables to be deleted and the sequence to be lost!
>
> So is this the only way for creating a generator? No built-in support for
> it? Is there any plan for supporting such a feature in the future, and if
> so when would that be?
>
> Thanks again for any responses.
>
> Masoud Kalali wrote:
>
>
> Yes It is supported , you can build a table with a field that will
> automatically increment due to inserting data.
> for example :
>
> create table tinc{
> idenCol integer not null generate always as identity,
> }
>
> also in case that you need sometimes to insert some values for the
> identity field you can use :
>
> create table tinc{
> idenCol integer not null generate by default as identity,
> }
>
> AFAIR , in Interbase we defined a generator and then we used that
> generator in a trigger which put a new value for a column , Am i correct ?
> it is a long time that i did not used that Interbase/FierBird thingy
>
> Panayiotis Vlissidis wrote:
> > Hello all!
> >
> > I just found out about derby( through Java DB) and I would like to know
> > if the feature of Oracle sequences(or Firebird generators) is supported
> > in order to automatically retreive and store a unique number, is
> > supported in any way?
> >
> > Thanks in advance.
> >
> > Panayiotis Vlissidis


New Yahoo! Messenger with Voice. Call regular phones from your PC and save big.