Subject | Re: [firebird-support] Re: Locking columns |
---|---|
Author | Paul Schmidt |
Post date | 2003-08-04T14:01:24Z |
On Mon, 2003-08-04 at 06:15, Olivier Mascia wrote:
otherwise you could get multiple ID's one per record, and that would not
be what you intended.
> rajsubramani wrote:Make sure the table being used has one and only one record though,
>
> > I have not looked at Generators before.
>
> Please, do so. They are what you're looking for.
>
> > I have a server side faced to
> > separate the SQL from other Java code (so that DB migration is easier
> > to achieve). I guess if I can use a Generator via JDBC/SQL then I
> > guess thats the only way for Firebird. Select for Update was what I
> > was used to and well, I quite like it.
> > :-(
>
> GENERATORS won't involve your client side. One you have a generator in
> place (in the db) and a trigger to assigns its next value to your column
> on inserts, all the client has to do is to insert a new row. The column
> will take its unique incremented new ID automatically.
>
> Should you need to know the id on the client side for anything, you can
> also proceed this way : first grab the next value from the generator by
> some SELECT GEN_ID(my_generator, 1) FROM RDB$DATABASE (or any other
> table for this purpose - that's just a placeholder).
otherwise you could get multiple ID's one per record, and that would not
be what you intended.